A custom implementation for automating Notion database operations. This package provides direct API integration without relying on the official notion-client
package.
This package is a standalone implementation and is not related to the official notion-client
package. We've built our own client to:
- Have more control over the API interactions
- Implement custom schema handling
- Provide simplified database operations
- Create a
.env
file with your Notion credentials:
NOTION_API_KEY=your-api-key-here
NOTION_PAGE_ID=your-page-id-here
- Install dependencies:
pip install -r requirements.txt
- Create a schema file in
plugins/
(e.g.,football_schema.json
):
{
"title": "College Football Games",
"properties": {
"Game": {
"property_type": "title",
"name": "Game"
},
"Status": {
"property_type": "select",
"name": "Status",
"options": [
{
"name": "Scheduled"
},
{
"name": "In Progress"
},
{
"name": "Final"
}
]
}
}
}
- Create entries file (e.g.,
football_games.json
):
{
"entries": [
{
"Game": "Rose Bowl - Alabama vs Michigan",
"Status": "Scheduled"
}
]
}
- Run the CLI:
python -m notion_automation.cli create --schema plugins/football_schema.json --tasks plugins/football_games.json
Retrieve schema of an existing database:
python -m notion_automation.cli get-schema --id your-database-id
title
: Database title fieldrich_text
: Multi-line text fieldselect
: Single-select with optionsdate
: Date field
notion_automation/
cli.py
: Command-line interfacemodels.py
: Data models for database configurationnotion_client/
: Notion API client implementationlogger.py
: Logging configuration
- Configuration files go in
plugins/
directory (gitignored) - Logs are written to
notion_automation.log
- Debug level logging available for API payloads
Three log levels are used:
- DEBUG: Detailed API payloads and responses
- INFO: General operation success
- ERROR: API errors and exceptions
Logs are written to both console and notion_automation.log
file.
This package includes:
- Custom Notion API client (
notion_automation.notion_client
) - Schema validation and parsing
- Database creation and management
- No dependencies on external Notion client libraries
When contributing, note that this package:
- Uses its own Notion API client implementation
- Does not depend on the official
notion-client
package - Handles all API interactions directly