| name | notion-api-1-database-operations |
| description | Sub-skill of notion-api: 1. Database Operations. |
| version | 1.0.0 |
| category | business |
| type | reference |
| scripts_exempt | true |
1. Database Operations
1. Database Operations
List and Search Databases:
curl -s -X POST "https://api.notion.com/v1/search" \
-H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{
"filter": {
"property": "object",
"value": "database"
}
}' | jq '.results[] | {id: .id, title: .title[0].plain_text}'
curl -s "https://api.notion.com/v1/databases/DATABASE_ID" \
-H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" | jq '.properties'
Python - Database Operations:
from notion_client import Client
import os
notion = Client(auth=os.environ["NOTION_API_KEY"])
results = notion.search(
filter={"property": "object", "value": "database"}
)
for db in results["results"]:
title = db["title"][0]["plain_text"] if db["title"] else "Untitled"
print(f"Database: {title} (ID: {db['id']})")
database = notion.databases.retrieve(database_id="your-database-id")
print(f"Properties: {list(database['properties'].keys())}")
new_db = notion.databases.create(
parent={"type": "page_id", "page_id": "parent-page-id"},
title=[{"type": "text", "text": {"content": "Tasks Database"}}],
properties={
"Name": {"title": {}},
"Status": {
"select": {
"options": [
{"name": "To Do", : },
{: , : },
{: , : }
]
}
},
: {
: {
: [
{: , : },
{: , : },
{: , : }
]
}
},
: {: {}},
: {: {}},
: {: {: []}},
: {: {}},
: {: {}}
}
)
()
notion.databases.update(
database_id=,
title=[{: , : {: }}],
properties={
: {: {}}
}
)