Skip to main content

Abstraction layer for the Notion API with declarative schema mapping

Project description

notion-api-utils

Abstraction layer for the Notion API. Define schemas declaratively and convert Python dicts to Notion's JSON format without writing boilerplate.

Install

pip install notion-api-utils

Usage

from notion_api_utils import Schema, Field, Title, RichText, Number, Select, Date, to_notion_properties

# Define a schema mapping your data to Notion properties
schema = Schema(fields={
    "name":   Field("Name", Title),
    "email":  Field("Email", Email),
    "age":    Field("Age", Number),
    "status": Field("Status", Select),
    "date":   Field("Created At", Date),
})

# Your data
data = {
    "name": "Lucas",
    "email": "lucas@example.com",
    "age": 25,
    "status": "Active",
    "date": "2026-03-25",
}

# Convert to Notion properties JSON
properties = to_notion_properties(data, schema)
# Use `properties` in your Notion API call body

Output:

{
  "Name": {"title": [{"text": {"content": "Lucas"}}]},
  "Email": {"email": "lucas@example.com"},
  "Age": {"number": 25},
  "Status": {"select": {"name": "Active"}},
  "Created At": {"date": {"start": "2026-03-25"}}
}

Supported Property Types

Type Input
Title str
RichText str
Number int | float
Select str
MultiSelect list[str]
Date str | date | datetime or {"start": ..., "end": ...}
Checkbox bool
Email str
Url str
PhoneNumber str
Status str
Relation list[str] (page IDs)
People list[str] (user IDs)
Files list[str] (URLs)

Custom Source Key

When your dict key differs from the schema key:

schema = Schema(fields={
    "nome": Field("Name", Title, source_key="nome_completo"),
})

data = {"nome_completo": "Lucas"}
properties = to_notion_properties(data, schema)

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

iaxys_notion_utils-0.2.2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iaxys_notion_utils-0.2.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file iaxys_notion_utils-0.2.2.tar.gz.

File metadata

  • Download URL: iaxys_notion_utils-0.2.2.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iaxys_notion_utils-0.2.2.tar.gz
Algorithm Hash digest
SHA256 20e0e15a1a2f17b4854048308554e4dbca8e5e71ee9307dbe890fe691fda7f09
MD5 cd7f7bd95d0bf44de78859f9e5dacb48
BLAKE2b-256 fea051f636eda817195a82f286ffe32dbd24e4d46c858988c913b40dc5d24fb5

See more details on using hashes here.

File details

Details for the file iaxys_notion_utils-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: iaxys_notion_utils-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iaxys_notion_utils-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08730682fd52f66f6c98a6b7e9e7216e22374fc3a18798028734c1e056fde817
MD5 e635f1f0bb0e37e873ab7a6fd8a1bfb9
BLAKE2b-256 0fe0877e584e666614da0e1b3e91b685c7d6dcb475af070c08923f5968636683

See more details on using hashes here.

Supported by

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