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 | |
import pandas as pd | |
import json | |
DATABASE_ID_TEST = "a296bd16b7284bc494aa91f50ad64d30" #https://www.notion.so/a296bd16b7284bc494aa91f50ad64d30?v=d37af84a3a6744fb957002073a267c44 | |
PAGE_ID = "e2e8b31737174dbe86b9ae65f9b8eb9c" #click on Page and Get ID : https://www.notion.so/Mary-Meeks-2d822179eb59451e91e83086cdd74e5c | |
INTEGRATION_TOKEN = "secret_gF6bJPSyOgt5oZgb2sgT1yiMxfS4LqNmWmd2M8S5vzl" | |
NOTION_DB_URL = "https://api.notion.com/v1/databases/" | |
NOTION_PAGE_URL = "https://api.notion.com/v1/pages/" | |
NOTION_PAGE_CONTENT = "https://api.notion.com/v1/blocks/" | |
# get database | |
database_url = NOTION_DB_URL + DATABASE_ID_TEST | |
response = requests.get(database_url, headers={"Authorization": f"{INTEGRATION_TOKEN}"}) | |
# query | |
print (response.json()) | |
database_url = NOTION_DB_URL + DATABASE_ID_TEST + "/query" | |
query = {"filter": {"property": "High Priority", "checkbox": {"equals": True}}} | |
query = {"filter": {"property": "Cost of next trip", "number": {"greater_than_or_equal_to": 0.5}}} | |
headers = {"Authorization": f"{INTEGRATION_TOKEN}", "Notion-Version": "2021-05-13"} | |
response = requests.post(database_url, headers=headers, data=query) | |
# Show result response | |
print((response.json()['results'])) | |
df_structure = pd.DataFrame.from_dict(response.json()['results']) | |
print("The size of the df is", df_structure.shape) | |
df_structure.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment