notion
Notion is an all-in-one workspace for notes, tasks, wikis, and databases.
Usage
import { notion } from 'netzo/apis/notion.ts'
const api = notion({
internalIntegrationToken: Deno.env.get('NOTION_INTERNAL_INTEGRATION_TOKEN'),
notionVersion: Deno.env.get('NOTION_VERSION'),
})
Configuration
The notion
factory function expects an object with the following, and returns an object with an API client api
.
Param | Type | Default | Description |
---|---|---|---|
internalIntegrationToken | string | Deno.env.get('NOTION_INTERNAL_INTEGRATION_TOKEN') | the API key to use for authentication |
notionVersion | string | Deno.env.get('NOTION_VERSION') | Notion version |
Refer to the API documentation to get the required information.
Examples
The following examples assume you have created an api client instance.
Find pages
Find all the pages that belong to a specific database and match the query.
const query: QueryDatabase = {}
const result = await api.databases[DATABASE_ID].query.post<Pages>(query)
const resultData = result.results
Get page
Get a page by id.
Property ids can be passed as query parameters to limit the search to specific properties.
const query: QueryProperties = {}
const resultData = await api.pages[PAGE_ID].get<Page>(query)
Get page content
Get the content of a specific page.
const query: NotionPagination = {}
const result = await api.blocks[PAGE_ID].children.get<Block>(query)
const resultData = result.results
Find users
Find all users of the workplace.
const query: NotionPagination = {}
const result = await api.users.get<Users>(query)
const resultData = result.results