Skip to main content

Automate Notion database creation with JSON schemas

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notion_automation-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

notion_automation-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file notion_automation-1.0.0.tar.gz.

File metadata

  • Download URL: notion_automation-1.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for notion_automation-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dfb5bd28c0050814911cf0aee0e4b4d5fc2dd6af10e771ab78f35f908c192f74
MD5 dec8013cc857ee298a8d97d78394c959
BLAKE2b-256 733bb8a5974ebdc17a0cb1ac26bc8280384502648ded09fe493e38b3b99f7d61

See more details on using hashes here.

File details

Details for the file notion_automation-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for notion_automation-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e7068e61a92c2e5ab6dc55d0f4acd561d1d4e7644a4eb29a6935a6957d789b3
MD5 b8446aa05e39e57ba309679470e2bbd7
BLAKE2b-256 6768bc9a972e06d323e7900b5103481b32ec17c482955551fa2e5150e1109e61

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page