DEV Community

Cover image for # Crypto Profits Tracker (feat. Notion API) using Python

# Crypto Profits Tracker (feat. Notion API) using Python

TnvMadhav⚡ on July 04, 2021

Crypto Boom of early '21 A crackle involving cryptocurrencies took off late 2020, and early 2021 saw a portion of it go mainstream. C...
Collapse
 
benjiblaine profile image
Ben Blaine

I got an error

Traceback (most recent call last):
  File "/notion-crypto-integration-main/read.py", line 102, in <module>
    MyIntegration().UpdateIndefinitely()
  File "/notion-crypto-integration-main/read.py", line 20, in __init__
    self.getDatabaseId()
  File "/notion-crypto-integration-main/read.py", line 31, in getDatabaseId
    self.my_variables_map["DATABASE_ID"] = response.json()["results"][0]["id"]
KeyError: 'results'
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tnvmadhav profile image
TnvMadhav⚡

Hello Ben,

I can help you out!

Can we connect on twitter DMs? That way we can resolve things without bloating public threads

Collapse
 
benjiblaine profile image
Ben Blaine

Please do @benjiblaine

Thread Thread
 
benjiblaine profile image
Ben Blaine

Thanks for the help @tnvmadhav ! It's working now.

I simply forgot to remove the "<" and ">" in the my_variables.yml file 🤦‍♂️

Thread Thread
 
tnvmadhav profile image
TnvMadhav⚡

😄 Thank you for stating the solution to this problem Ben!

👍🏻 This will surely help others as well.

PS: I have also updated the post regarding the same.

Collapse
 
zopear profile image
Jane Doe • Edited

I got up to the last step and ran the python.3 read.py (I'm on mac) and received an index error: list index out of range

Any suggestions to get around this one?

Thank you!

Collapse
 
tnvmadhav profile image
TnvMadhav⚡

Apologies for the delayed response.

Sure. I would love to help. Can we take this to twitter DMs if you don't mind?

Collapse
 
zaxkiller profile image
zaxkiller

Got the same error, any suggestion?

Thank you!!

Thread Thread
 
pierre_fortin_ee47ea55404 profile image
pierre fortin

Got the same error

IndexError: list index out of range

Any ideas?

Thread Thread
 
tnvmadhav profile image
TnvMadhav⚡

Hi Pierre Fortin,

Can we take this to twitter DMs if you don't mind?

...that way we can prevent this public thread from bloating up!

Thread Thread
 
pierre_fortin_ee47ea55404 profile image
pierre fortin

Sure, but there's no option to DM you on Twitter though.

Thread Thread
 
tnvmadhav profile image
TnvMadhav⚡ • Edited

Hey Pierre Fortin,

Apologies for the delayed response.

Could you follow me on Twitter? and maybe when I follow you back, we could initiate DM!

Collapse
 
giodsiyow profile image
Info Comment hidden by post author - thread only accessible via permalink

Hi! awesome what you could accomplish with a bit of python. I have the same problem as the first guy though--the script won't run, returning

KeyError: 'results'

this means that results don't exist right?

Collapse
 
linkard profile image
Robin Playe 🌐

Can't get this to work for the life of me. Could use a video tutorial

Collapse
 
tnvmadhav profile image
TnvMadhav⚡ • Edited

Thank you for your feedback! I will definitely improve on the setup instructions for my future products!

But for the time being, would you mind sharing where exactly you are stuck at?

Collapse
 
linkard profile image
Info Comment hidden by post author - thread only accessible via permalink
Robin Playe 🌐

I followed the instructions, but it's just not working for me. I'm able to download the zip file, launch the first python command, modify one of the file with my secret key and launch the final command, but my Notion page never updated with the API after that.

Note that I have no experience with Python, so I am following the instructions with minimal knowledge of what everything does.

 
tnvmadhav profile image
TnvMadhav⚡ • Edited

Don't worry! Python is an incredible language and you would get better and better as you proactively try to find your weak spots and improve :)

I have a couple of questions:

  1. Have you added any crypto currencies to your dashboard table under the 'Name' Attribute? If you haven't I would recommend adding a test coin first

  2. Do you see any errors when you run python script?

Thread Thread
 
linkard profile image
Robin Playe 🌐
  1. No at first, Yes later. Got the same result both times
  2. I did it again from the beginning, here is the last block of text I get when I launch the last command "Traceback (most recent call last): File "C:\Users\linka\OneDrive\Documents\Backend\Notion\Python\Crypto Wallet\Binance\python3-notion-crypto-dashboard-bundle\read.py", line 102, in MyIntegration().UpdateIndefinitely() File "C:\Users\linka\OneDrive\Documents\Backend\Notion\Python\Crypto Wallet\Binance\python3-notion-crypto-dashboard-bundle\read.py", line 20, in init self.getDatabaseId() File "C:\Users\linka\OneDrive\Documents\Backend\Notion\Python\Crypto Wallet\Binance\python3-notion-crypto-dashboard-bundle\read.py", line 31, in getDatabaseId self.my_variables_map["DATABASE_ID"] = response.json()["results"][0]["id"] KeyError: 'results'"
Thread Thread
 
tnvmadhav profile image
TnvMadhav⚡ • Edited

Thank you for informing. I will be de listing the product for now and try to reproduce this.

I will get back to you soon.

Edit:
I am not able to reproduce this.

BTW, what is the output of print(response.json()) in the method getDatabaseId() ?

Can we take this in twitter dms?

Edit:
Issue is fixed ✅

Thread Thread
 
linkard profile image
Robin Playe 🌐

Sure! I'm not sure what your last question means but i followed you on twittter

Collapse
 
vickzerh profile image
Victor Delaune • Edited

Hey Madhav, thanks a lot for your work! What a useful tool.

Small question: how can I get the price in Euro € instead of USD $ ?

I track all my crypto investments in euro and it would be a big pain to change everything...

EDIT: I managed changing USDT to EUR in 51th line of the read.py code.

Collapse
 
tnvmadhav profile image
TnvMadhav⚡

Sorry, for being late.

Did it work out?

Collapse
 
leo_feroces profile image
Leo Feroces

I got the same error as @benjiblaine

Traceback (most recent call last):
  File "/Users/jeanduporte/Downloads/notion-crypto-integration-main/read.py", line 102, in <module>
    MyIntegration().UpdateIndefinitely()
  File "/Users/jeanduporte/Downloads/notion-crypto-integration-main/read.py", line 20, in __init__
    self.getDatabaseId()
  File "/Users/jeanduporte/Downloads/notion-crypto-integration-main/read.py", line 31, in getDatabaseId
    self.my_variables_map["DATABASE_ID"] = response.json()["results"][0]["id"]
IndexError: list index out of range
Enter fullscreen mode Exit fullscreen mode

Any ideas?

Collapse
 
leo_feroces profile image
Leo Feroces

I did not forget to remove <>

Collapse
 
callusvn profile image
Jame Kane

Traceback (most recent call last):
File "read.py", line 102, in
MyIntegration().UpdateIndefinitely()
File "read.py", line 21, in init
self.getNotionDatabaseEntities()
File "read.py", line 42, in getNotionDatabaseEntities
self.my_variables_map["NOTION_ENTRIES"].update({v["properties"]["Name"]["title"][0]["text"]["content"]: {"page": v["id"], "price": float(v["properties"]["Price/Coin"]["number"])}})
IndexError: list index out of range

I got this error

Collapse
 
anesgroup profile image
AnesGroup

i got an error

Collapse
 
tnvmadhav profile image
TnvMadhav⚡ • Edited

Hello,

I would love to help you out.

Can we connect using Twitter DMs so that this thread isn't bloated with minute details?

Collapse
 
anesgroup profile image
AnesGroup

Sure @anesgroup on Twitter.
Thank you.

Collapse
 
theshadowgit profile image
Info Comment hidden by post author - thread only accessible via permalink
TheShadowGit

Hey Madhav, Thanks for the guide. I have imported your repository to my github. Now where do i edit and run the python file ? will it be on my desktop ? I just want to know because that will mean, I will have to always remember to run this script before looking at my tracker in notion ? is that how it is supposed to be ?

Collapse
 
tnvmadhav profile image
TnvMadhav⚡

Hey there,

Apologies for the delayed response!

Now where do i edit and run the python file ?

You just have to paste your notion integration secret token into the my_variables.yml file and run your python script!

I just want to know because that will mean, I will have to always remember to run this script before looking at my tracker in notion ? is that how it is supposed to be ?

Yes, as long as the script is running, the crypto data will be fetched and the notion database will be updated automatically!

Collapse
 
sanjuancito profile image
SanJuancito

i got TypeError: 'str' object does not support item assignment

Collapse
 
fedefede profile image
Fede_Drei

Hi there, amazing job, it's possibile to find a walkaround to get pools APY data? if you want to move on twitter this is my handle @fedre5

Thanks!

Some comments have been hidden by the post's author - find out more