Integrate with Notion to read pages, query databases, create new pages, and update existing content. Uses the official Notion API.
Setup
The user needs a Notion integration token:
1. Go to https://www.notion.so/my-integrations
2. Create a new integration (give it read + write access)
3. Copy the token and set: export NOTION_API_KEY=ntn_xxxxx
4. Share specific pages/databases with the integration in Notion
API Base
All requests go to https://api.notion.com/v1/ with headers:
Authorization: Bearer ${NOTION_API_KEY}
Notion-Version: 2022-06-28
Content-Type: application/jsonOperations
Search for pages
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 '{"query":"SEARCH_TERM","page_size":5}'Read a page
curl -s 'https://api.notion.com/v1/pages/PAGE_ID' \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28"
curl -s 'https://api.notion.com/v1/blocks/PAGE_ID/children?page_size=100' \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28"Query a database
curl -s -X POST 'https://api.notion.com/v1/databases/DATABASE_ID/query' \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"page_size":10}'Create a page
curl -s -X POST 'https://api.notion.com/v1/pages' \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{
"parent": {"database_id":"DATABASE_ID"},
"properties": {
"Name": {"title": [{"text": {"content": "PAGE TITLE"}}]}
},
"children": [
{"object":"block","type":"paragraph","paragraph":{"rich_text":[{"text":{"content":"Page content here."}}]}}
]
}'Append content to a page
curl -s -X PATCH 'https://api.notion.com/v1/blocks/PAGE_ID/children' \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{
"children": [
{"object":"block","type":"paragraph","paragraph":{"rich_text":[{"text":{"content":"New content appended."}}]}}
]
}'Common Use Cases
- "What's in my project tracker?" โ Query the database, summarize entries
- "Add a note to my ideas page" โ Append a block to the page
- "Create a new meeting notes page" โ Create page in specified database
- "Find my notes about X" โ Search, then read matching pages
Response Format
When reading pages, present content as clean markdown โ not raw JSON.
When querying databases, present as a table or list.
Rules
- Never modify or delete content without explicit user confirmation.
- For create/update operations, show the user what will be written before executing.
- If NOTION_API_KEY is not set, guide the user through setup.
- Parse Notion's block format into readable text โ the user shouldn't see raw JSON.
- Respect the user's Notion structure โ don't create pages in unexpected locations.
- If a page hasn't been shared with the integration, explain how to fix it.