Skip to content

Commit

Permalink
Add notion-client
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Dec 4, 2023
1 parent dc8d324 commit 7e7630e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions book/cooltools/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,60 @@
"\n",
"print(config[\"DOMAIN\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Work with Notion via Python with"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Did you know you can interact with Notion via Python?\n",
"\n",
"`notion-client` is a Python SDK for working with the Notion API.\n",
"\n",
"You can create databases, search for items, interact with pages, etc.\n",
"\n",
"Check the example below."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install notion-client"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from notion_client import Client\n",
"\n",
"notion = Client(\"<NOTION_TOKEN>\")\n",
"\n",
"print(notion.users.list())\n",
"\n",
"my_page = notion.databases.query(\n",
" **{\n",
" \"database_id\": \"897e5a76-ae52-4b48-9fdf-e71f5945d1af\",\n",
" \"filter\": {\n",
" \"property\": \"Landmark\",\n",
" \"rich_text\": {\n",
" \"contains\": \"Bridge\",\n",
" },\n",
" },\n",
" }\n",
" )"
]
}
],
"metadata": {
Expand Down

0 comments on commit 7e7630e

Please sign in to comment.