A simple application to track problems and submissions across different competitive programming platforms by syncing the data into a single Notion database.
As a competitive programmer, I tend to use a combination of different resources when training. Though I mainly use Codeforces and occasionally practice Leetcode, I sometimes find myself wandering into other websites, including VJudge and AtCoder.
With the plethora of resources available, it has become somewhat of a tedious task to track my progress across all these different sites, especially when I want to refer back to a problem and can't remember exactly where I've come across it.
That is why I've decided to implement a CP Problem Tracker inside of my Notion workspace. It centralizes all the problems, successful submissions, and attempted languages.
This simple node.js
application makes use of the available APIs for each entity.
The application first attempts to fetch and format all the user submissions, and their respective problems, from each platform's API. The application will only fetch new submissions (i.e. submissions with a timestamp greater than the platform's LAST_SUBMISSION_TIMESTAMP
of the .env
file). The LAST_SUBMISSION_TIMESTAMP
of each platform is initially set to zero and automatically updated after each successful run.
Once the data is properly structured, the application uses Notion's API to update the respective database accordingly.
Obviously, a Notion workspace is needed to sync to the corresponding database. If you do not already have a Notion account, check their official website at https://www.notion.so/.
Once you've secured a workspace, you'll need a Notion database to sync to. The application expects certain properties with specific names and types, so feel free to duplicate this database template.
NOTE: You CAN add properties to the duplicated database as you wish, but make sure not to alter any of the existing properties. Of course, feel free to edit the title, icon, and cover image as you please!
As this is a Node.js
application, you'd need a node.js installation to run it. If you don't already have node.js installed, navigate to their website at https://nodejs.org/.
All your identifiers are stored in a local .env
file next to app.js
in the project's directory. These are your unique IDs which the application will use to properly identify you across the different paltforms.
NOTE: Make sure your .env
file is stored safely and up-to-date before running the application.
NOTE: The .env
file contains LAST_SUBMISSION_TIMESTAMP
for each platform, which should be initialized to zero if the platform had not been synced before. It will update automatically after a successful run.
These are identifiers that you generate once and wouldn't typically need to change later on.
Refer to https://developers.notion.com/reference/retrieve-a-database for the official documetation.
If you prefer to use the desktop app, you can navigate to your database and copy link (shortcut: CTRL+L) then follow the same described steps.
Follow the steps described in the official documentation at https://developers.notion.com/docs/create-a-notion-integration to generate your Notion key.
- Navigate to https://www.notion.so/my-integrations and select "New Integration".
- Make sure the integration is "Internal" and fill out the basic information (Name and, optionally, Logo).
- For the integrations, make sure to check "Read Content", "Update Content", and "Insert Content". No other capabilities are needed for the application to work. If interested, refer to the capabilities documentation at https://developers.notion.com/reference/capabilities.
Important: Once you generate your key, you need to connect to your database. To do so:
- Navigate to your database in Notion
- Select the three dots on the top right and navigate to "Connections"
- Select the integration you've just created
CODEFORCES_KEY
& CODEFORCES_SECRET
generated when you add a new API key from https://codeforces.com/settings/api
Leetcode does not provide a way to generate API keys (like codeforces, for example) nor does it provide a seemless method of authenticating requests, which is why your LEETCODE_SESSION cookie is needed to authorize communication with Leetcode.
To generate this cookie:
- Navigate to https://leetcode.com/ and make sure you're signed in.
- Open developer tools (e.g. CTRL+SHIFT+I on Google Chrome) and navigate to the Application tab where you'll search for LEETCODE_SESSION.
- Copy the value of this cookie and paste it into the
.env
file.
Important: As this is a cookie, it is important to ensure that it is updated before each run.
Remember to navigate to the project's directory in your terminal before executing any of these commands.
If you're using the application for the first time, run npm install
to install or update all the required dependencies.
After you've updated the .env
file with your identifiers as described in the previous section, run the command node --env-file=.env app.js
in your terminal to start the sync process.
- Syncing your problems & submissions into Notion
- Downloading your submissions locally
- Error handling is rather basic. This is a simple application, after all.
- If one of the websites is down, the application will crash. A workaround for this would be to avoid syncing to that platform while its servers are down.
For the time being, a simple fix would be to clear the Notion database and reset the .env
timestamps back to 0
. This ensures a clean sync into an empty database.
-
All languages supported by a platform are supported when syncing, but the formatting is still undergoing some testing.
-
Error 403: Multiple http requests to the same website (or API endpoint) is causing the application to be detected as a webscraper and a 403 "Forbidden Access" error is returned in the terminal, causing the application to crash. Fixes are currently being developed to resolve this issue. As such, any code retrievals will be blank, as they are not fetched from the endpoint to limit the number of http requests needed by the application to function (as a temporary fix), but the URL to the submission remains intact and valid inside the Notion page.
- Fetches private gym submissions' URL but does not sync their codes.
- Private submissions have an "undefined" difficulty
- Fetches the submissions' URL but does not sync their codes (Needs authentication).
Following is a list of official documentation (if applicable) and any resources relevant to the project.
Notion API documentation
- Request Limits: The rate limit for incoming requests per integration is an average of three requests per second. Some bursts beyond the average rate are allowed.
Codeforces API documentation
- Request Limits: API may be requested at most 1 time per two seconds. If you send more requests, you will receive a response with "FAILED" status and "Call limit exceeded" comment.
Leetcode does not provide any official documentation, so following is a list of references that are directly relevant to the this project.
-
The Submissions REST API Endpoint
-
Leetcode's GraphQL API Endpoint
Vjudge does not provide any official documentation, so following is a list of references that are directly relevant to the this project.
- Submissions Endpoint
https://vjudge.net/status/data?
params - Problem Endpoint
https://vjudge.net/problem/data?
params - Solution Endpoint
https://vjudge.net/solution/
run-id
I'm not affiliated with any of the involved platforms. At the time of working on this project, I'm still just an undergraduate Computer Science major. If you would like to reach out, feel free to send an email titled "CP Notion Problems Tracker" to mahmoud.j.eschool@gmail.com.