Skip to content

Instantly share code, notes, and snippets.

@maintainer64
Created February 21, 2023 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maintainer64/a4560cdea7819b4e3d7edfd196abd13b to your computer and use it in GitHub Desktop.
Save maintainer64/a4560cdea7819b4e3d7edfd196abd13b to your computer and use it in GitHub Desktop.
Export json from notion by API
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