![]() ![]() With open(f'.json', 'w') as file:įile.write(json.dumps(child)) Step 5: Set up a cron job Response = requests.post('', headers=headers) Here's how the final script looks like: import requests One way of storing your Notion workspace data is to write top-level pages and databases to separate JSON files and write child pages under a directory named after their parent files. To obtain all items, you will have to recursively query the search endpoint until the has_more parameter returns false. ![]() In large workspaces, results are more likely to be paginated. To grab them, you'll have to query for pages using the retrieve block children endpoint. Keep in mind that the search endpoint doesn't return child pages. 'Authorization': 'Bearer YOUR_INTEGRATION_TOKEN', # replace YOUR_INTEGRATION_TOKEN with your own secret token The Notion API exposes a search endpoint that returns the top-level pages and databases your integration has access to. Unless you intend to back up a specific page only, you'd want to grab all pages and databases. Notion's docs cover this topic in more detail. Your integration won't be visible unless you click on the invite field. You have to manually add it to pages and databases you want to back up by using the invite function in the Share menu. Step 2: Share pages you want to back upīy default, your integration doesn't have access to any pages or databases. You will need it later to authenticate your API requests. Once you're done, grab your Internal Integration Token. Keep in mind that you have to be an admin to access the workspace data. If you want to back up your personal workspace, choose the internal integration. Notion's docs give a good overview of the process. Head over to My integrations page to create an internal integration. Now that Notion's API is available, there's a more robust way of backing up your data. Using a GitLab/Github CI with Notion's private API (the private API is subject to change at any time without notice).Up until this point, you had two options when it came to backing up your Notion data: With Notion becoming a second brain and knowledge management for many folks and organizations alike, it's paramount to have consistent backups if things go south. Backing up your data on a consistent schedule is like buying insurance: you think you don't need it until you need it. ![]()
0 Comments
Leave a Reply. |