From 7e7630e3045aa89132644d0957f2b268239d42f9 Mon Sep 17 00:00:00 2001 From: Banias Baabe Date: Mon, 4 Dec 2023 18:12:53 +0100 Subject: [PATCH] Add notion-client --- book/cooltools/Chapter.ipynb | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/book/cooltools/Chapter.ipynb b/book/cooltools/Chapter.ipynb index f137757..feec4ec 100644 --- a/book/cooltools/Chapter.ipynb +++ b/book/cooltools/Chapter.ipynb @@ -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(\"\")\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": {