notion_api 0.0.1-dev.2 notion_api: ^0.0.1-dev.2 copied to clipboard
Notion API client for dart.
Notion API client for dart.
Using #
Important: The methods return a http.Response
. You can find how to use it in its documentation.
NotionClient
class #
You only have to create a new instance of the NotionClient
class and all the API requests will be available as class methods.
NotionClient notion = NotionClient(token: 'YOUR SECRET TOKEN FROM INTEGRATIONS PAGE');
Creating pages #
Page page = Page(
databaseId: 'YOUR DATABASE ID',
title: Text(content: 'The title of the new page'),
);
notion.pages.create(page);
Retrieving pages #
notion.pages.fetch('YOUR_PAGE_ID');
Retrieving a database #
notion.databases.fetch('YOUR_DATABASE_ID');
Retrieving all databases #
Warning: This endpoint is not recommended by the Notion team.
Parameters:
- startCursor: If supplied, this endpoint will return a page of results starting after the cursor provided. If not supplied, this endpoint will return the first page of results.
- pageSize: The number of items from the full list desired in the response. Maximum: 100, otherwise will be ignored.
notion.databases.fetchAll();
Individual classes #
You can also use individual request group class like NotionPagesClient
or NotionDatabasesClient
. They are used like the main client but the methods are class methods instead of class properties methods.
Example
// With main class
NotionClient notion = NotionClient(token: 'YOUR_TOKEN');
notion.databases.fetchAll();
// With individual class
NotionDatabasesClient databases = NotionDatabasesClient(token: 'YOUR_TOKEN');
databases.fetchAll();