State 2024/01/11: all APIs are working except:
- block/append
- page/create and update
- database/get, query and list
Those are not priority and up for grabs.
This is an unofficial Notion public API beta library and website template. You can, for example, get notion pages as a RSS feed. You can also use it as a simple CMS (Content Management System).
Create a session:
var sessionInfo = new NotionSessionInfo
{
Token = "secret_9BXXXxxxxxxxxxXXXXXXXXXXXxxxxxxxxxxxxxxx"
};
var session = new NotionSession(sessionInfo);
Example: get the HTML content of a page
var page = await session.Search(filterOptions: FilterOptions.ObjectPage)
.WhereAwait(async p => p.Title().Title[0].PlainText == "Procrastination")
.FirstAsync();
var html = await session.GetHtml(page);
Create a page at the root of Notion.so (the root page), then add subpages to this page with a title and an icon.
When you encounter CmsPageTitle
below in this setup, replace it with the exact title of your root page.
Connect to your notion.so account first then navigate here and create a new integration.
Copy the Internal Integration Token
, this is your credential (named Token
below).
Go back to your content, and share your root page with the integration you just created (tap in the invite input zone to bring the integration selector).
Option 1: Spawn the website with kubernetes
Run these commands after having setup kubernetes:
helm upgrade demonotionblog helm\notionsharpblog --install -f your-own-values.yaml
start http://localhost:5080/
Example of a simple your-own-values.yaml
file suitable for minikube.
Check helm\notionsharpblog\values.yaml
for all available configurable values.
appSettingsSecrets:
appsettings-secrets.Production.json: |-
{
"Notion": {
"CmsPageTitle": "My Blog",
"Token": "secret_9BXXXxxxxxxxxxXXXXXXXXXXXxxxxxxxxxxxxxxx"
}
}
#For minikube only
service:
type: LoadBalancer
port: 5080
Issue these commands to create your customized notion website. Replace the fake credentials with yours.
This requires the dotnet sdk v5+.
md DemoNotionBlog
cd DemoNotionBlog
dotnet new -i Softlion.NotionSharp.TemplateProjects
dotnet new blazorblog -p "MySite CMS"
dotnet user-secrets init
dotnet user-secrets set "Notion:Token" "secret_9BXXXxxxxxxxxxXXXXXXXXXXXxxxxxxxxxxxxxxx"
or
dotnet new blazorblog -p "MySite CMS" --token secret_9BXXXxxxxxxxxxXXXXXXXXXXXxxxxxxxxxxxxxxx
dotnet run
To uninstall the template:
dotnet new -u Softlion.NotionSharp.TemplateProject.Blog
Use Visual Studio, VS Code, or Rider to open the solution .sln
file and customize the website.
Clone the git repo then install the template:
dotnet new -i Demos\DemoNotionBlog
Then spawn a new website from this template:
dotnet new blazorblog -p "MySite CMS" --key secret_9BXXXxxxxxxxxxXXXXXXXXXXXxxxxxxxxxxxxxxx
dotnet run
To uninstall the template:
dotnet new -u Softlion.NotionSharp.TemplateProject.Blog
A dockerfile is included with the demo/template project. In Visual Studio, right click the demo project and choose "publish" to publish it using the UI. Or use these commands:
docker build -t yourdockerhub.com/demonotionblog:1.0.0 .
docker run -p8080:5000 yourdockerhub.com/demonotionblog:1.0.0
start http://localhost:8080/
Note: the prebuilt docker image vapolia/demonotionblog:latest is made only for helm
(ie: kubernetes) and is missing the appsettings-secrets.Production.json file.