Skip to content

Instantly share code, notes, and snippets.

@lgaud
lgaud / Load a Notion Database in Pandas.ipynb
Last active November 20, 2023 09:29
This is an example of importing a Notion database into Pandas, created for a blog post at https://www.pynotion.com/load-in-pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgaud
lgaud / create-notion-database-with-relation.py
Created October 11, 2022 13:38
Creates 2 Notion Databases, where the second has a Relation and Roll Ups to the first.
import json
import os
from dotenv import load_dotenv
import requests
class NotionClient():
def __init__(self, notion_key):
self.notion_key = notion_key
@lgaud
lgaud / translate-notion-page.py
Created October 3, 2022 15:13
This example uses Azure Cognitive Services Translator to translate Notion pages into a new Notion page. Code example for www.pynotion.com.
import os
from dotenv import load_dotenv
import requests
"""
This example uses Azure Cognitive Services Translator to translate Notion pages into a new Notion page.
See full explanation at: https://www.pynotion.com/translate-with-azure-translator-part-2
Create a Translator resource in Azure, and set the key and region in your environment or a .env file as
@lgaud
lgaud / translate-notion-title.py
Last active September 29, 2022 18:03
This gist uses the Microsoft Azure Cognitive Services Translator API to translate the title of a Notion page and print out the translation. Accompanies a post on PyNotion.com
import os
from dotenv import load_dotenv
import requests
"""
This example uses Azure Cognitive Services Translator and the Notion API to translate the title of a page.
For more details, see [Translate a Notion page using Azure Cognitive Services Translator (Part 1)](https://www.pynotion.com/translate-with-azure-translator)
Create a Translator resource in Azure, and set the key and region in your environment or a .env file as
@lgaud
lgaud / notion_hello.py
Last active September 27, 2023 18:47
Notion Hello World in Python
"""
1. Create an integration at https://www.notion.so/my-integrations
2. Set an environment variable NOTION_KEY with the value of the "Internal Integration Token"
3. Create a page and connect it to your integration.
Ensure you have requests installed in your environment `pip install requests`
"""
import os
import json