然后,你可以使用 Python 的 requests 库来访问 Notion API。下面是一个简单的例子,展示了如何使用 API 获取数据库中的所有记录:
import requests
# Replace"database_id"with the actual database ID and"your_api_key"with your API key
database_id = "database_id"
api_key = "your_api_key"
# Make a GETrequestto the database's entries endpointresponse = requests.get(
f"https://api.notion.com/v3/databases/{database_id}/entries",
headers={
"Authorization": f"Bearer {api_key}"
}
)
# Print the response
print(response.json())