Skip to main content

Notion Automation

This repository automates the creation of databases and entries in Notion using predefined JSON schemas and entry definitions. It is optimized for extensibility and ease of use with minimal configuration.

Core Magic ✨

  • Automates Notion data entry: Define your entries and schema in JSON, and let the automation do the heavy lifting.
  • Extensible & Customizable: Plug-and-play JSON files for schema and entry definitions.
  • Seamless API Integration: Built-in Notion API integration for easy database creation.

Quick Setup

1. Clone & Install Dependencies

git clone https://github.com/your-repo/notion-automation.git
cd notion-automation
pip install -r requirements.txt

2. Configure Notion API

Create a .env file with your Notion API key and page ID:

NOTION_API_KEY=your_notion_api_key
NOTION_PAGE_ID=your_notion_page_id

3. Define Your Schema and Entries

Store your schema and entries (optional) in the plugins/ folder. The schema defines the database structure, and the entries define the content.

Example Schema (schema.json):

{
  "title": "Project Entities",
  "properties": {
    "Entity ID": {
      "property_type": "title"
    },
    "Name": {
      "property_type": "rich_text"
    },
    "Type": {
      "property_type": "select",
      "options": [
        { "name": "Entity", "color": "blue" },
        { "name": "Component", "color": "green" },
        { "name": "Module", "color": "purple" }
      ]
    },
    "Created At": {
      "property_type": "date"
    },
    "Tags": {
      "property_type": "multi_select",
      "options": [
        { "name": "Core", "color": "red" },
        { "name": "Active", "color": "green" },
        { "name": "Archived", "color": "gray" },
        { "name": "Reference", "color": "yellow" }
      ]
    }
  }
}

Example Entries (entries.json):

{
  "entries": [
    {
      "Entity ID": "E001",
      "Name": "Alpha",
      "Type": "Entity",
      "Created At": "2023-10-15",
      "Tags": ["Core", "Active"]
    },
    {
      "Entity ID": "E002",
      "Name": "Beta",
      "Type": "Component",
      "Created At": "2023-10-10",
      "Tags": ["Archived", "Reference"]
    },
    {
      "Entity ID": "E003",
      "Name": "Gamma",
      "Type": "Module",
      "Created At": "2023-10-20",
      "Tags": ["Core", "Active"]
    }
  ]
}

4. Run the Magic 🪄

Option 1: Using Environment Variable for Page ID

To create a database with preseeded entries in the default page specified in the .env file, run:

python cli.py --schema plugins/schema.json --entries plugins/entries.json

If you want to create an empty database without adding entries, simply omit the --entries argument:

python cli.py --schema plugins/schema.json

Option 2: Specifying Target Page ID via CLI

To create a database in a specific Notion page by providing the --page-id argument, use:

python cli.py --schema plugins/schema.json --entries plugins/entries.json --page-id your_target_page_id

Note: Providing the --page-id argument will override the NOTION_PAGE_ID specified in the .env file for that execution.

Core Files

  • cli.py: The main entry point for creating databases and entries.
  • notion_client/: Contains API integration logic and models.
  • plugins/: Store your schema and entry JSON files here. This folder is .gitignored for privacy and customization.

Logs & Debugging

Logs are automatically generated in notion_automation.log. Check the logs for detailed information on API calls and errors.

Metadata

Release files for notion-automation 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notion-automation 1.0.3
File Size Uploaded
notion_automation-1.0.3.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for notion-automation 1.0.3
File Interpreter ABI Platform
notion_automation-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / notion_automation-1.0.3.tar.gz

Download URL notion_automation-1.0.3.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7771770116f83adeed57e0ccd0bd7c15b75e7c0f3fb95fd3962bc77edda176c8
BLAKE2b-256 checksum
How to use checksums
01b23406db47e59b9cf3e993645df8c305ef3a10581bef1d3b1e6c4dd7fe9a4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / notion_automation-1.0.3-py3-none-any.whl

Download URL notion_automation-1.0.3-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b47443138082d694de303bd50f12d7804d5d0f9980ab5679d1bcf2f2df5a37c3
BLAKE2b-256 checksum
How to use checksums
ece1c44885efce2f1b9a7acaea9a48498ef99578d807d580c28e92a38ee19f30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page