Skip to content

jonathangomz/notion_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2d4067c · Jun 22, 2021
Jun 22, 2021
Jun 22, 2021
Jun 22, 2021
Jun 22, 2021
Jun 22, 2021
May 20, 2021
Jun 22, 2021
May 20, 2021
Jun 22, 2021
Jun 22, 2021
Jun 9, 2021
Jun 17, 2021

Repository files navigation

Notion API client for dart.

CI

See the ROADMAP file to see what is coming next.

Usage

Important: The methods return a NotionResponse. 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');

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();

Some examples

To see more examples go here.

Append blocks children

// Create children instance:
Children children = Children().addAll([
  Heading(text: Text('Test')),
  Paragraph(texts: [
    Text('Lorem ipsum (A)'),
    Text('Lorem ipsum (B)',
        annotations: TextAnnotations(
          bold: true,
          underline: true,
          color: ColorsTypes.Orange,
        ))
  ])
]);

// Send the instance to Notion
notion.blocks.append(
  to: 'YOUR_BLOCK_ID',
  children: children,
);

Create a page

// Create a page instance
Page page = Page(
  parent: Parent.database(id: 'YOUR_DATABASE_ID'),
  title: Text('NotionClient (v1): Page test'),
);

// Send the instance to Notion.
notion.pages.create(page);

Next release

v1.0.0:

Release date: 25/Jun/2021

Changes

  • Fix any error

Contributions

Please help, I don't even know if what I'm doing is right.