Crypto Boom of early '21
A crackle involving cryptocurrencies took off late 2020, and early 2021 saw a portion of it go mainstream. Cryptocurrency adoption was at all time high, with mighty bursts of bulk investing and selling.
The prices went from all time highs to dwindling states all in the matter of minutes. This was a result of non stop bidirectional flow of coins all over the globe. This forced the investors to keep up to date with extremely mutable prices toggling the state of the market.
Some wanted quick profits, some wanted to be a part of history and others went for the overhaul. Regardless of the intentions, almost all of the players had the trade sites running non-stop on all screens to catch the next dip.
Hours and hours of precious time were lost while keeping up to date with the graphs based profits (or losses) and the inconsistent nature of the the market didn't make the situation any better.
For people like me who waste a lot of time overthinking and make decisions on impulse, I wanted to try sorting this out.
🤔
The idea was to keep me updated without all the glitter and jam. I hated keeping all of the trade firms open multiple tabs and wanted to get this sorted out.
So I planned to use APIs to pull data to my console to check the prices without any other hassle.
ICYAC: Link to the template at the end of article 👇🏻
...
😲 Advent of Notion API
Then Notion launched API Integrations Beta. This immediately lit a spark in my head. Now I didn't have to leave my notion app (workspace).
👓 My Expectations
- Open a Notion page,
- Check my profits (or losses),
- Close the page
👉🏻 "This should take only 1 minute of my time."
Design
I want my net profit but I don't want to leave my Notion Workspace.
I had to get my net profit,
where
n
is number of coins I am currently 'hodling',
m
is number of coins of type j
that I currently have in my wallet
I just want check 'NetProfit' and peace out.
Dashboard Setup
"Notion is incredible with its DIY databases." - We can build wonders without worrying about the code that goes into maintaining it.
I quickly set up a dashboard with the crypto coin entries as a entities. The selected attributes were used to calculate the profit.
Considering that my API Integration is setup and my updation server is running, If I had to ever invest in a new currency, I would just add an entry to this database consisting of Name
, Amount Invested
and Number of Coins in wallet
, I should automatically see my profits taking form in the Notion Database.
Notion Integration
In order to provide edit capabilities on my crypto dashboard, I would want to provide a access token with edit scope to my updation script (here python).
To get the access token (secret key), I would want to create an internal integration. The steps to create an integration for a database can be found here
Steps to setup an Integration: [Referenced from Official Notion Doc]
- Go to https://www.notion.com/my-integrations.
- Click the "+ New integration" button.
- Give your integration a name, say "My-Crypto-Updates"
- Select the workspace where you want to install this integration.
- Click "Submit" to create the integration.
- Copy the "Internal Integration Token" on the next page and keep it aside
Share a database with your integration
A user must share specific pages with an integration in order for those pages to be accessed using the API.
Go back to the 'Crypto Dashboard' & click on the Share
button and use the selector to find your integration by its name, then click Invite
. Your integration now has permission to read, write, and edit the new database.
Ensure that this created integration is not used by any other database
🔥 Leveraging notion-api
Once you have a database setup in your notion workspace, you would want to have a system where the dashboard is constantly updated with latest crypto currency prices.
😄 Let's walk you through to get it done, using the 💪🏻 power of Notion API,
I am using python as it is more readable and is familiar for most. The script essentially performs 3 actions:
Getting list of CryptoCoins that the user has added to the Notion database (GET~ POST)
Getting prices for the CryptoCoins in List (GET)
Updating the Prices to the Notion Database (PATCH)
The above functionality is implemented using python class methods.
How to use Notion API 💻
- Clone the GitHub Repository
- (After unzipping) You will find 3 files inside
-
cd
into the directory where the 3 files are present usingbash shell
orterminal
(command prompt
for windows) -
Install the required software dependencies by running the following command,
pip3 install -r requirements.txt # use `py -m pip install -r requirements.txt` (for Windows System)
-
Update and save the
my_variables.yml
file with your notion related information, (don't include the <> characters)
MY_NOTION_SECRET_TOKEN: <insert-your-notion-integration- secret-token> # (use the secret from prior step
-
Run the following command to execute python script,
python3 read.py # Use `py read.py` if you are on Windows!
🙌🏻 Watch your crypto dashboard update automatically! 🎉
Conclusion
This was another experiment of mine but it really helped me save a lot of time scrolling and clicking around Crypto Trading Firms.
If you liked this, do follow me on Twitter and let me know 😁
👉🏻 The Notion Template can be found here :~
👉🏻 If you want to offload running and maintaining code to me, you can subscribe to this service as a monthly subscription:
Top comments (32)
I got an error
Hello Ben,
I can help you out!
Can we connect on twitter DMs? That way we can resolve things without bloating public threads
Please do @benjiblaine
Thanks for the help @tnvmadhav ! It's working now.
I simply forgot to remove the "<" and ">" in the my_variables.yml file 🤦♂️
😄 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.
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!
Apologies for the delayed response.
Sure. I would love to help. Can we take this to twitter DMs if you don't mind?
Got the same error, any suggestion?
Thank you!!
Got the same error
IndexError: list index out of range
Any ideas?
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!
Sure, but there's no option to DM you on Twitter though.
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!
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?
Can't get this to work for the life of me. Could use a video tutorial
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?
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.
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:
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
Do you see any errors when you run python script?
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 methodgetDatabaseId()
?Can we take this in twitter dms?
Edit:
Issue is fixed ✅
Sure! I'm not sure what your last question means but i followed you on twittter
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.
Sorry, for being late.
Did it work out?
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
I got the same error as @benjiblaine
Any ideas?
I did not forget to remove <>
i got an error
Hello,
I would love to help you out.
Can we connect using Twitter DMs so that this thread isn't bloated with minute details?
Sure @anesgroup on Twitter.
Thank you.
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 ?
Hey there,
Apologies for the delayed response!
You just have to paste your notion integration secret token into the
my_variables.yml
file and run your python script!Yes, as long as the script is running, the crypto data will be fetched and the notion database will be updated automatically!
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 may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more