21
Gumroad Sales Tracker (feat. Notion API)
Notion is an incredible software that allows creators develop, publish, maintain content with little to no effort. Creator economy is the new deal. If you are a creator who sells ebooks, presets, software bundles like Notion Templates, you must've heard about Gumroad. Creators, like myself and many more use Gumroad on a day to day basis.
Gumroad Provides API that allows the creator to programmatically retrieve their products and user data for analysis/ maintenance purposes.
Notion also provides API support to read and write into the notion workspace with granular scopes w.r.t resources.
So this would naturally mean, one can read gumroad product data and write them into Notion Pages/ Databases using code.
I am here to present just that.
ICYAC: Link to the template at the end of article ππ»
- Open a Notion page,
- Check my Product Sales,
- Close the page
In order to provide edit capabilities on my sales dashboard, I would want to provide 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 "Gumroad-Notion-Integration"
- 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
A user must share specific pages with an integration in order for those pages to be accessed using the API.
The script must update the Database as well as the Parent Page. Therefore, we would want to give access to both.
Bear in mind to give database access before parent page access
Open 'My Products' Database as a Page & 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
Open the Gumroad Sales Page & 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.
To get your gumroad product information, you need to get a gumroad account secret token
that will be used by the python script, to pull your product data and push them to your notion database
- Login to your gumroad account and visit
https://app.gumroad.com/settings/advanced
url in your browser -
Scroll down to
Create Application
Section that looks like this, Give the application a Icon (optional),
Name
andRedirect URI
(Setredirect uri
value tohttp://127.0.0.1
as our notion integration doesn't involve any oauth2 authorisation code flow)
Click on "Create application" to create the application. This will advance you to the next screen, showing the new application
-
Click
Generate access token
button to get your access token Your access token will be displayed. Copy the Access token
π₯ Leveraging Notion and Gumroad API
Now that we have completed creation of Notion API and Gumroad API Integration. You should have 2 Secret tokens pasted in your text editor safely :-
i. Notion API Secret Token
ii. Gumroad API Secret Token
These two will be used by the python script to :-
Read Product list from your Gumroad Store
Update Products to your Notion Page
Let's walk you through to get it done π
-
Clone to this GitHub Repository to your local device
Open
my_variables.yml
file using a code/ text editorPaste the
Notion
andGumroad
secret tokens like this and save file,
- After updating your notion and gumroad secret tokens into the
my_variables.yml
, we can now install the python dependencies to run the code -
Running the following command to install python dependencies ,
pip3 install -r requirements.txt # use `py -m pip install -r requirements.txt` (for Windows System)
-
Run the following command to start python server
python3 gumroad_notion_product.py # Use `py gumroad_notion_product.py` if you are on Windows!
ππ» Watch your gumroad products appear / get updated one by one in 5 to 10 second time intervals!
Note:
If a product sale happens, the sales count will be updated immediately as long as the python script is running!
This was yet another fun experiment of mine and if you liked this, do follow me on Twitter and let me know π
You can find the Notion Template + Demo here :-
21