Skip to content

Commit c90b825

Browse files
Add separate readme file for nuget package 📦
1 parent 03f9f46 commit c90b825

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

Src/Notion.Client/Notion.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<Pack>True</Pack>
3434
<PackagePath></PackagePath>
3535
</None>
36-
<None Include="..\..\README.md">
36+
<None Include="..\..\docs\README.md">
3737
<Pack>True</Pack>
3838
<PackagePath></PackagePath>
3939
</None>

docs/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Notion SDK for .Net
2+
3+
A simple and easy to use client for the [Notion API](https://developers.notion.com)
4+
5+
## Installation
6+
7+
.Net CLI
8+
9+
```
10+
dotnet add package Notion.Net
11+
```
12+
13+
## Usage
14+
15+
> Before getting started, you need to [create an integration](https://www.notion.com/my-integrations) and find the token. You can learn more about authorization [here](https://developers.notion.com/docs/authorization).
16+
17+
Import and initialize the client using the integration token created above.
18+
19+
```csharp
20+
var client = new NotionClient(new ClientOptions
21+
{
22+
AuthToken = "<Token>"
23+
});
24+
```
25+
26+
Make A request to any Endpoint. For example you can call below to fetch the paginated list of users.
27+
28+
```csharp
29+
var usersList = await client.Users.ListAsync();
30+
```
31+
32+
### Querying a database
33+
34+
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:
35+
36+
```C#
37+
// Date filter for page property called "When"
38+
var dateFilter = new DateFilter("When", onOrAfter: DateTime.Now);
39+
40+
var queryParams = new DatabasesQueryParameters { Filter = dateFilter };
41+
var pages = await client.Databases.QueryAsync(databaseId, queryParams);
42+
```
43+
44+
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:
45+
46+
```C#
47+
var filter = new TextFilter("Name", startsWith: "Mr", contains: "John"); // WRONG FILTER USAGE
48+
49+
```
50+
51+
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:
52+
53+
```C#
54+
var selectFilter = new SelectFilter("Urgency", equal: "High");
55+
var assigneeFilter = new PeopleFilter("Assignee", contains: "some-uuid");
56+
var dateFilter = new DateFilter("Due", pastMonth: new Dictionary<string, object>());
57+
58+
var orGroup = new List<Filter> { assigneeFilter, selectFilter };
59+
var complexFiler = new CompoundFilter(
60+
and: new List<Filter> { dateFilter, new CompoundFilter(or: orGroup) }
61+
);
62+
```
63+
64+
## Supported Endpoints
65+
66+
- [ ] Databases
67+
- [x] Retrieve a database
68+
- [x] Query a database
69+
- [x] List databases
70+
- [ ] Create a Database
71+
- [x] Pages
72+
- [x] Retrieve a page
73+
- [x] Create a page
74+
- [x] Update page
75+
- [x] Blocks
76+
- [x] Retrieve Block Children
77+
- [x] Append Block Children
78+
- [x] Users
79+
- [x] Retrieve a User
80+
- [x] List all users
81+
- [x] Search
82+
83+
## Contribution Guideline
84+
85+
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](https://github.com/notion-dotnet/notion-sdk-net/blob/main/CONTRIBUTING.md) defined here - we will continue to improve it.

0 commit comments

Comments
 (0)