Created
February 21, 2023 18:21
-
-
Save maintainer64/a4560cdea7819b4e3d7edfd196abd13b to your computer and use it in GitHub Desktop.
Export json from notion by API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
TOKEN_NOTION = "..." | |
uuid = "..." | |
def get_database_by_id( | |
database_id: str, | |
page_size: int = 1000 | |
): | |
url = f"https://api.notion.com/v1/databases/{database_id}/query" | |
response = requests.post( | |
url=url, | |
json={"page_size": page_size}, | |
headers={ | |
"Authorization": f"Bearer {TOKEN_NOTION}", | |
"Content-Type": "application/json", | |
"Notion-Version": "2021-08-16", | |
} | |
) | |
return response.json() | |
print(get_database_by_id( | |
database_id=uuid | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment