패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

notion_api

Dart용 Notion SDK 패키지처럼 관리할 수 있는 공개 베타 Notion API용 래퍼입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
50
좋아요
27
Pub 점수
140

패키지 설치

flutter pub add notion_api

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

공개 베타 Notion API를 위한 래퍼를 제공하는 Dart 패키지로, 개발자가 네이티브 SDK를 사용하는 것처럼 Notion 데이터베이스, 페이지 및 콘텐츠와 상호 작용할 수 있게 해줍니다. Flutter 애플리케이션을 위한 직관적인 메서드를 통해 인증, 데이터 검색 및 조작을 간소화합니다. 저수준 HTTP 요청을 추상화하여 Notion의 구조화된 데이터 작업에 깔끔하고 타입 안전한 인터페이스를 제공합니다. Notion 워크스페이스와 실시간 동기화 또는 동적 콘텐츠 관리가 필요한 앱에 적합합니다.

사용 사례

  • Flutter 앱에 Notion 데이터베이스 통합
  • 앱 데이터를 Notion 페이지와 동기화
  • Notion 백엔드를 사용하여 콘텐츠 관리 도구 구축
  • Flutter 앱에서 Notion 페이지 업데이트 자동화
  • Notion을 데이터 소스로 사용하여 작업 추적기 만들기

주요 기능

  • 형 안전한 API 호출
  • 크로스 플랫폼 지원 (Android, iOS, Web, macOS, Windows, Linux)
  • Notion API 토큰을 통한 인증 처리
  • 데이터베이스 쿼리 및 페이지 작업 지원
  • 간단하고 읽기 쉬운 메서드 구문

적합한 대상

  • 생산성 앱을 구축하는 플러터 개발자
  • 주요 작업 공간으로 Notion을 사용하는 팀
  • Notion과 양방향 동기화가 필요한 앱
  • 가벼운 Notion 통합을 찾는 개발자

고려 사항

  • 유효한 Notion API 토큰이 필요합니다
  • 공개 베타 API 기능에만 제한됨
  • 개인 또는 기업 전용 Notion 엔드포인트에는 적합하지 않습니다
  • Notion API가 진화함에 따라 업데이트가 필요할 수 있습니다
  • 내장 캐싱 또는 오프라인 지원 없음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Notion API client for dart.

CI codecov

See the ROADMAP file to see what is coming next.

API implemented

Endpoint Avaliable Notes
Retrieve a database ✅
Query a database 🏗 Working on it
List databases ✅
Create a database ✅ Workin on more properties
Retrieve a page ✅
Create a page ✅ Workin on more properties
Update a page ✅ Workin on more properties
Retrieve block children ✅
Append block children ✅
Retrieve a user
List all users
Search

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

A few examples

A page created and filled using only this package:
https://jonathangomz.notion.site/notion_api-example-0893dd2cb38a413d90165cb810b3c019

To see code to create the page above or see more examples go here.

Append blocks children
// Create children instance:
Children children = Children.withBlocks([
  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);

Errors

Some errors that I have encounter and still don't know how to solve because are errors that also occur on Postman are:

Create page with chidren

When the parent is a page the error is:

"body failed validation: body.properties.title.type should be an array, instead was `\"array\"`."

But when the parent is a database then the error is:

"body failed validation: body.parent.page_id should be defined, instead was `undefined`."

You can create the page first and then add the children as shown in the examples.

Contributions

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

Rules

Some rules to follow:

  1. Please follow the dart convention format:
    1. Effective dart
    2. dart format
  2. If you are adding a new function, please also add the documentation.
  3. If you are adding a new parameters, please also add it to the current documentation.
  4. (Optional) Run the tests to know that everything is working just fine (See how run the tests).
    • This is optional because sometimes the tests fail on GitHub actions so anyway I will check this on my computer.

Tests

To be able to run the tests you will have to have a .env file on the root directory with the next variables:

  • TOKEN: The secret token.
  • TEST_DATABASE_ID: The database id where you will be working on.
  • TEST_PAGE_ID: Some page id inside the database specified above.
  • TEST_BLOCK_ID: Some block id inside the page specified above.
  • TEST_BLOCK_HEADING_ID: Some heading block id inside the page specified above.
Example:

The values are not valid of course.

TOKEN=secret_Oa24V8FbJ49JluJankVOQihyLiMXwqSQeeHuSFobQDW
TEST_DATABASE_ID=366da3d646bb458128071fdb2fbbf427
TEST_PAGE_ID=c3b53019-4470-443b-a141-95a3a1a44g60
TEST_BLOCK_ID=c8hac4bb32af48889228bf483d938e34
TEST_BLOCK_HEADING_ID=c8hac4bb32af48889228bf483d938e34

Next release

v1.2.1:

Release date: 02/Aug/2021

  • Add constructors with only single text content with default style for:
    • Paragraph.text('some text here...')
    • ToDo.text('some text here...', checked: true)
    • Heading.text('some text here...', type: 2)
    • BulletedListItem.text('some text here...')
    • NumberedListItem.text('some text here...')
    • Toggle.text('some text here...', children: [])
  • Add more constructors for Heading class:
    • one: Heading with type 1 by default.
    • two: Heading with type 2 by default.
    • three: Heading with type 3 by default.
  • Add more constructors for Text class:
    • code: Text with code style by default.
    • italic: Text with italic style by default.
    • bold: Text with bold style by default.
    • [Opt] list: List of words separated by comma (by default).
      • Example: Text.list() will receive a list of Text and will be concatenated separated with comma by default. It may be unnecessary. Can help to make the code more readable.
    • [Opt] sep: Text separator.
      • Example: Text.sep(), by default, will insert " " in a list of Text instances, but it will be able to do more things that I don't know yet, hehe. It may be unnecessary. Can help to make the code more readable.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.