All Projects → notion-dotnet → notion-sdk-net

notion-dotnet / notion-sdk-net

Licence: MIT license
A Notion SDK for .Net

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to notion-sdk-net

notion-sdk-py
Official Notion SDK rewritten in Python (sync + async)
Stars: ✭ 753 (+960.56%)
Mutual labels:  api-client, notion, notion-api
cards
Turn your Notion database into a deck of cards
Stars: ✭ 37 (-47.89%)
Mutual labels:  notion, notion-api
notion-scholar
Reference management solution using Python and Notion.
Stars: ✭ 77 (+8.45%)
Mutual labels:  notion, notion-api
open-source-notionapi-apps
Collection of Apps, Integrations und Libraries that utilize the Notion API
Stars: ✭ 82 (+15.49%)
Mutual labels:  notion, notion-api
memegentino
Meme generator for Notion
Stars: ✭ 18 (-74.65%)
Mutual labels:  notion, notion-api
notion-nextjs-blog
A starter blog template powered by Next.js, Notion and Tailwind CSS.
Stars: ✭ 25 (-64.79%)
Mutual labels:  notion, notion-api
jahir.dev
My personal website 💎 – Built using Next.js, TypeScript, MDX, contentlayer, Notion and Stitches styled components
Stars: ✭ 119 (+67.61%)
Mutual labels:  notion, notion-api
notionapi
A Notion API SDK, written in Golang
Stars: ✭ 351 (+394.37%)
Mutual labels:  notion, notion-api
NotionSwift
Unofficial Notion API SDK for iOS & macOS
Stars: ✭ 49 (-30.99%)
Mutual labels:  notion, notion-api
shellbear.me
Source code of my personal website and blog ✨
Stars: ✭ 177 (+149.3%)
Mutual labels:  notion, notion-api
Notion-and-Google-Calendar-2-Way-Sync
2 Way Sync Between Notion Database and Google Calendar
Stars: ✭ 205 (+188.73%)
Mutual labels:  notion, notion-api
go-notion
Notion Official API Go Client.
Stars: ✭ 14 (-80.28%)
Mutual labels:  notion, notion-api
go-notion
Go client for the Notion API.
Stars: ✭ 261 (+267.61%)
Mutual labels:  notion, notion-api
Notion-GCal-Sync
A Python script to automate the syncing of tasks between Google Calendar and the all-in-one productivity workspace, Notion. It utilizes API and is customizable for your own needs. Free to use.
Stars: ✭ 120 (+69.01%)
Mutual labels:  notion, notion-api
notion-sdk-php
A complete Notion SDK for PHP developers.
Stars: ✭ 60 (-15.49%)
Mutual labels:  notion, notion-api
notionapi-agent
Unofficial Node.js API client for Notion.so
Stars: ✭ 89 (+25.35%)
Mutual labels:  api-client, notion
notionproxy
Notion as a web site, inspired by react-notion-x.
Stars: ✭ 24 (-66.2%)
Mutual labels:  notion, notion-api
chess.com
Python wrapper for Chess.com Published-Data API
Stars: ✭ 34 (-52.11%)
Mutual labels:  api-client
deepl-api-connector
Connector library for deepl.com rest translation api
Stars: ✭ 12 (-83.1%)
Mutual labels:  api-client
sbankenclient-ios
A small but enjoyable iOS framework to connect to the Sbanken API
Stars: ✭ 21 (-70.42%)
Mutual labels:  api-client

Notion SDK for .Net

A simple and easy to use client for the Notion API


GitHub release (latest SemVer) GitHub

Build Status Build artifacts Publish Code CodeQL

LGTM Alerts LGTM Grade

GitHub last commit GitHub commit activity GitHub commit activity GitHub commit activity

GitHub repo size Lines of code

Provides the following packages:

Package Downloads Nuget
Notion.Net Nuget Nuget Nuget (with prereleases)

Installation

.Net CLI

dotnet add package Notion.Net

Note: From Nuget 2.0.0 notion client sdk default sets the Notion-Version header to 2021-08-16.

Usage

Before getting started, you need to create an integration and find the token. You can learn more about authorization here.

Import and initialize the client using the integration token created above.

var client = NotionClientFactory.Create(new ClientOptions
{
    AuthToken = "<Token>"
});

Make A request to any Endpoint. For example you can call below to fetch the paginated list of users.

var usersList = await client.Users.ListAsync();

Dependency Injection

Library also provides extension method to register NotionClient with Microsoft dependency injection.

services.AddNotionClient(options => {
  options.AuthToken = "<Token>";
});

Querying a database

After you initialized your client and got an id of a database, you can query it for any contained pages. You can add filters and sorts to your request. Here is a simple example:

// Date filter for page property called "When"
var dateFilter = new DateFilter("When", onOrAfter: DateTime.Now);

var queryParams = new DatabasesQueryParameters { Filter = dateFilter };
var pages = await client.Databases.QueryAsync(databaseId, queryParams);

Filters constructors contain all possible filter conditions, but you need to choose only condition per filter, all other should be null. So, for example this code would not filter by 2 conditions as one might expect:

var filter = new TextFilter("Name", startsWith: "Mr", contains: "John"); // WRONG FILTER USAGE

To use complex filters, use class CompoundFilter. It allows adding many filters and even nesting compound filters into each other (it works as filter group in Notion interface). Here is an example of filter that would return pages that were due in past month AND either had a certain assignee OR had high urgency:

var selectFilter = new SelectFilter("Urgency", equal: "High");
var assigneeFilter = new PeopleFilter("Assignee", contains: "some-uuid");
var dateFilter = new DateFilter("Due", pastMonth: new Dictionary<string, object>());

var orGroup = new List<Filter> { assigneeFilter, selectFilter };
var complexFiler = new CompoundFilter(
    and: new List<Filter> { dateFilter, new CompoundFilter(or: orGroup) }
);

Supported Endpoints

  • Databases
    • Query a database
    • Create a database
    • Update database
    • Retrieve a database
    • List databases (Deprecated: use Search API instead)
  • Pages
    • Retrieve a page
    • Create a page
    • Update page
    • Retrieve page property item
  • Blocks
    • Retrieve a block
    • Update a block
    • Retrieve block children
    • Append block children
    • Delete a block
  • Users
    • Retrieve a User
    • List all users
    • Retrieve your token's bot user
  • Search

Enable internal logs

The library make use of ILoggerFactory interface exposed by Microsoft.Extensions.Logging. Which allow you to have ability to enable the internal logs when developing application to get additional information.

To enable logging you need to add the below code at startup of the application.

// pass the ILoggerFactory instance
NotionClientLogging.ConfigureLogger(logger);

You can set the LogLevel in config file.

{
  "Logging": {
    "LogLevel": {
      "Notion.Client": "Trace"
    }
  }
}

You can also refer examples/list-users example.

Contributors

This project exists thanks to all the people who contribute.

contributor image

Contribution Guideline

Hello! Thank you for choosing to help contribute to this open source library. There are many ways you can contribute and help is always welcome. You can read the detailed Contribution Guideline defined here - we will continue to improve it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].