Skip to main content

Unofficial Python API client for Notion

Project description

easy-notion-api

Use easy-notion-api for handy Notion API!
Unofficial Python 3 client for Notion API

English

Installation

pip install easy-notion-api

Before Start

To use Notion API, you must get api key from notion integrations page.
And then, create new database in your notion workspace.
Click the database's setting and click 'copy link to view'
Get database id from copied link before '?v='

https://www.notion.so/__here_is_database_id__?v=uuid&pvs=4

Usage

Start

from notion import Notion

client = Notion("your_api_key", "database_id")

Create new page in your db

data = {
    "school": "maycan_school", # school column type in notion is title
    "message": "example message" # message column type in notion is rich_text
    "students": ["Hans", "Woody"] # students column type in notion is people
}
client.create_page_in_db(data)

create_page_in_db method returns dictionary like

{
    is_created: bool,
    page_id: str, # if is_created is False, then page_id is not given and 'detail' key returned with error message
}
  • data format

    • title, rich_text, number, selecet, status

      • key: value
      • Be careful! status value must be predefined in notion app.
    • multi_select, people

      • key: [value1, value2 ...] (value must be user's nickname if people)
    • date

      • key: [value1, value2]
      • The second value(value2) means the end date. If None, only the start date is registered.
      • value format -> "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss"

Update page

data = {
    "message": "i want to go home"
}
client.update_page("page_id", data)

update_page method returns True (when success), else raise Error with message from Notion

Retrieve page properties

client.get_page_properties("page_id") # returns dictionary

Features

  • Create page in Database
  • Update page
  • Retrieve page properties
  • Query Database

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

easy_notion_api-0.1.5-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file easy_notion_api-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for easy_notion_api-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dd600f294e88441c73419e96be8a534fcd2e92d7b147196acac373f36d15abd3
MD5 da824ef5aaab901ecae80c0bc4ecf69b
BLAKE2b-256 73ec13ef44048eea6a1e70bbe80ab4bf695642dfa6e31cdf783c781386e4a74e

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