makenotion/notion-sdk-js
makenotion/notion-sdk-js is a TypeScript project with 5.7k stars in the Frontend space. Official Notion JavaScript Client
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Snapshot
Top contributors
Show top contributors
Notion SDK for JavaScript
A JavaScript and TypeScript client for the Notion API. This reference covers the SDK's methods, options, and helpers.
Installation
npm install @notionhq/client
Usage
[!NOTE] For setup steps, see Notion's getting started guide.
Client accepts an integration token or an OAuth access token.
const { Client } = require("@notionhq/client")
const notion = new Client({
auth: process.env.NOTION_TOKEN,
})
Make a request to any Notion API endpoint.
;(async () => {
const listUsersResponse = await notion.users.list({})
console.log(listUsersResponse)
})()
[!NOTE] See the complete list of endpoints in the API reference.
Request methods return a Promise with the response. For example:
{
results: [
{
object: "user",
id: "d40e767c-d7af-4b18-a86d-55c61f1e39a4",
type: "person",
person: {
email: "[email protected]",
},
name: "Avocado Lovelace",
avatar_url:
"https://secure.notion-static.com/e6a352a8-8381-44d0-a1dc-9ed80e62b53d.jpg",
},
// ...
]
}
Endpoint parameters are grouped into a single object. You don't need to remember which parameters go in the path, query, or body.
const myPage = await notion.dataSources.query({
data_source_id: "897e5a76-ae52-4b48-9fdf-e71f5945d1af",
filter: {
property: "Landmark",
rich_text: {
contains: "Bridge",
},
},
})
Markdown versions
Enhanced Markdown (v1) is deprecated. API versions through 2026-03-11 still default to v1. The next API version will default to v2 and reject requests that specify v1. Notion plans to retire v1 on older API versions about three months after that release.
Set markdown_version: "v2" on Markdown reads and writes now to test your integration before you upgrade. Migrate to Notion-flavored Markdown
const { markdown } = await notion.pages.retrieveMarkdown({
page_id: pageId,
markdown_version: "v2",
})
Per-request beta flags
Pass betas to a typed endpoint to opt that call into one or more API betas. The SDK sends the flags in one comma-separated Notion-Beta header. Omitting betas or passing an empty array sends no beta header.
await notion.dataSources.query({
data_source_id: dataSourceId,
betas: ["status-group-filters-2026-10-06"],
filter: { property: "Status", status: { group_equals: "In progress" } },
})
This query matches every status option in the “In progress” group. Status group filters beta
TypeScript suggests the current flags known to this SDK. You can also pass a newer flag by its full name and revision date. The API checks whether each flag is valid. Beta versions
Handling errors
Notion API errors reject the request with an APIResponseError. The code property identifies the error. APIErrorCode contains the known server error codes.
const {
Client,
APIErrorCode,
isNotionClientError,
} = require("@notionhq/client")
try {
const notion = new Client({ auth: process.env.NOTION_TOKEN })
const myPage = await notion.dataSources.query({
data_source_id: dataSourceId,
filter: {
property: "Landmark",
rich_text: {
contains: "Bridge",
},
},
})
} catch (error) {
if (
isNotionClientError(error) &&
error.code === APIErrorCode.ObjectNotFound
) {
// Ask the user to select a different data source.
} else {
// Other error handling code
console.error(error)
}
}
Logging
The default logger writes warnings and errors to the console. LogLevel.DEBUG also logs response bodies.
const { Client, LogLevel } = require("@notionhq/client")
const notion = new Client({
auth: process.env.NOTION_TOKEN,
logLevel: LogLevel.DEBUG,
})
A custom logger receives logLevel, message, and extraInfo. It should return no value.
Client options
The Client constructor accepts one options object.
| Option | Default value | Type | Description |
|---|---|---|---|
auth | undefined | string | Bearer token for authentication. If left undefined, the auth parameter should be set on each request. |
logLevel | LogLevel.WARN | LogLevel | Verbosity of logs the instance will produce. By default, logs are written to stdout. |
timeoutMs | DEFAULT_TIMEOUT_MS | number | Number of milliseconds to wait before emitting a RequestTimeoutError |
baseUrl | DEFAULT_BASE_URL | string | The root URL for sending API requests. This can be changed to test with a mock server. |
logger | Log to console | Logger | A custom logging function. This function is only called when the client emits a log that is equal or greater severity than logLevel. |
agent | Default node agent | http.Agent | Used to control creation of TCP sockets. A common use is to proxy requests with https-proxy-agent |
retry | See constants | RetryOptions | Configuration for automatic retries on rate limits (429), service overloads (529), and server errors (500, 503). See Automatic retries below. |
dangerouslyAllowBrowser | false | boolean | Allows a token inside a browser page or worker. Without it, the client throws BrowserTokenNotAllowedError there. See Browser usage below. |
Browser usage
The Notion API sends CORS headers, so browser code can call api.notion.com directly. The client works in modern browsers with the built-in fetch.
A token in a web page isn't a secret. Anyone who can load the page can read it and act as your connection.
- For an app other people use, keep the token on a server. Create a public connection, which uses OAuth. Exchange the authorization code on your server, and send the page only the data it needs.
- For a personal tool or a local page that only you can open, using a token directly is your own risk to accept.
The client blocks tokens in a browser by default. Constructing it with auth inside a browser page throws BrowserTokenNotAllowedError. Pass dangerouslyAllowBrowser: true to confirm you understand the risk.
const notion = new Client({
auth: tokenTypedIntoYourOwnPage,
dangerouslyAllowBrowser: true,
})
A token passed per request through auth is blocked the same way: the request rejects with BrowserTokenNotAllowedError before anything is sent. A client without a token still works in a browser, for example with a baseUrl that points at your own server, which adds the token. Web workers and service workers in a browser count as a browser too, because every visitor downloads their script. Server runtimes that borrow worker APIs, such as Cloudflare Workers and Deno worker threads, don't count. Test runners that emulate a browser, such as jsdom, count as well, so pass dangerouslyAllowBrowser: true in those tests. The agent option is ignored in browsers, and the client doesn't send its user-agent header there, so a proxy's CORS rules don't need to allow it. OAuth token endpoints under /v1/oauth/ don't send CORS headers, so exchange authorization codes on a server.
Automatic retries
The client retries failed requests up to 2 times by default. Delays increase with each retry and include a random offset.
Retried errors:
rate_limited(HTTP 429) - Too many requests; retried for all HTTP methodsservice_overload(HTTP 529) - Service overloaded; retried for all HTTP methodsinternal_server_error(HTTP 500) - Server error; retried only for GET and DELETEservice_unavailable(HTTP 503) - Service temporarily unavailable; retried only for GET and DELETE
For server errors, only GET and DELETE are retried to avoid repeating writes. The client uses the Retry-After header when present. It accepts a delay in seconds or an HTTP date.
Retry options:
const notion = new Client({
auth: process.env.NOTION_TOKEN,
retry: {
maxRetries: 5, // Maximum retry attempts (default: 2)
initialRetryDelayMs: 500, // Initial delay between retries (default: 1000ms)
maxRetryDelayMs: 60000, // Maximum delay between retries (default: 60000ms)
},
})
To disable automatic retries:
const notion = new Client({
auth: process.env.NOTION_TOKEN,
retry: false,
})
Constants
The SDK exports these defaults and Notion-specific values:
const {
DEFAULT_BASE_URL, // "https://api.notion.com"
DEFAULT_TIMEOUT_MS, // 60_000
DEFAULT_MAX_RETRIES, // 2
DEFAULT_INITIAL_RETRY_DELAY_MS, // 1_000
DEFAULT_MAX_RETRY_DELAY_MS, // 60_000
MIN_VIEW_COLUMN_WIDTH, // 32
} = require("@notionhq/client")
MIN_VIEW_COLUMN_WIDTH is the minimum table column width in pixels. A column at this width appears collapsed. For example:
await notion.views.create({
database_id: databaseId,
name: "My view",
type: "table",
configuration: {
table: {
properties: [
{
property_id: checkboxPropId,
visible: true,
width: MIN_VIEW_COLUMN_WIDTH,
},
],
},
},
})
TypeScript
The package includes types for request parameters, responses, and their fields.
With strict TypeScript, caught errors have type unknown. isNotionClientError
narrows the error to a known SDK error type. APIErrorCode identifies server
errors; ClientErrorCode identifies errors raised by the client.
import {
APIErrorCode,
ClientErrorCode,
isNotionClientError,
} from "@notionhq/client"
try {
const response = await notion.dataSources.query({
data_source_id: dataSourceId,
})
} catch (error: unknown) {
if (isNotionClientError(error)) {
// error is now strongly typed to NotionClientError
switch (error.code) {
case ClientErrorCode.RequestTimeout:
// ...
break
case APIErrorCode.ObjectNotFound:
// ...
break
case APIErrorCode.Unauthorized:
// ...
break
default:
console.error(error)
}
}
}
Type guards
These type guards distinguish full API responses from partial responses.
| Type guard function | Purpose |
|---|---|
isFullPage | Determine whether an object is a full PageObjectResponse |
isFullBlock | Determine whether an object is a full BlockObjectResponse |
isFullDataSource | Determine whether an object is a full DataSourceObjectResponse |
isFullPageOrDataSource | Determine whether an object is a full PageObjectResponse or DataSourceObjectResponse |
isFullUser | Determine whether an object is a full UserObjectResponse |
isFullComment | Determine whether an object is a full CommentObjectResponse |
Example:
const fullOrPartialPages = await notion.dataSources.query({
data_source_id: "897e5a76-ae52-4b48-9fdf-e71f5945d1af",
})
for (const page of fullOrPartialPages.results) {
if (!isFullPageOrDataSource(page)) {
continue
}
// The page variable has been narrowed from
// PageObjectResponse | PartialPageObjectResponse | DataSourceObjectResponse | PartialDataSourceObjectResponse
// to
// PageObjectResponse | DataSourceObjectResponse.
console.log("Created at:", page.created_time)
}
Utility functions
These helpers read results across multiple pages.
iteratePaginatedAPI(listFn, firstPageArgs)
Returns an async iterator that reads each page of results as needed.
Parameters:
listFn: Any function on the Notion client that represents a paginated API (i.e. acceptsstart_cursor.) Example:notion.blocks.children.list.firstPageArgs: Arguments that should be passed to the API on the first and subsequent calls to the API, for example ablock_id.
Returns:
An async iterator over results from the API.
Example:
for await (const block of iteratePaginatedAPI(notion.blocks.children.list, {
block_id: parentBlockId,
})) {
// Do something with block.
}
collectPaginatedAPI(listFn, firstPageArgs)
Accepts the same arguments as iteratePaginatedAPI and returns all results in
one array. The results must fit in memory.
Parameters:
listFn: Any function on the Notion client that represents a paginated API (i.e. acceptsstart_cursor.) Example:notion.blocks.children.list.firstPageArgs: Arguments that should be passed to the API on the first and subsequent calls to the API, for example ablock_id.
Returns:
An array with results from the API.
Example:
const blocks = await collectPaginatedAPI(notion.blocks.children.list, {
block_id: parentBlockId,
})
// Do something with blocks.
iterateAllDataSourceRows(client, args)
Reads rows beyond the limit for a single data source query, which is 10,000 by
default. At that limit, has_more is false and request_status.type is
"incomplete"; ordinary pagination stops.
This helper sorts by created_time and starts a new query from the last row's
timestamp each time it reaches the limit. It removes duplicate rows by ID.
Parameters:
client: A Notion client instance.args: The same arguments asdataSources.query, minus the fields the helper controls:start_cursor(pagination is automatic) andsorts(set tocreated_timeascending to partition).data_source_idis required. Anyfilteryou pass is combined with the window bound usingand.
Returns:
An async iterator over every row in the data source.
Throws:
If a single created_time value holds more rows than the limit, the window
cannot be narrowed by time alone. Pass a filter in that case so each window
stays under the limit.
Example:
for await (const row of iterateAllDataSourceRows(notion, {
data_source_id: dataSourceId,
})) {
// Do something with row.
}
collectAllDataSourceRows(client, args)
Accepts the same arguments as iterateAllDataSourceRows and returns all results
in one array. The full data source must fit in memory. For larger data sources,
iterateAllDataSourceRows reads rows as a stream.
Parameters:
client: A Notion client instance.args: The same arguments asiterateAllDataSourceRows.
Returns:
An array with every row in the data source.
Example:
const rows = await collectAllDataSourceRows(notion, {
data_source_id: dataSourceId,
})
// Do something with rows.
Custom requests
request() calls a Notion API endpoint directly. For example:
// POST /v1/comments
const response = await notion.request({
path: "comments",
method: "post",
body: {
parent: { page_id: "5c6a28216bb14a7eb6e1c50111515c3d" },
rich_text: [{ text: { content: "Hello, world!" } }],
},
// No `query` params in this example, only `body`.
})
console.log(JSON.stringify(response, null, 2))
notion.request<ResponseBody>({...}) uses ResponseBody as the expected response type. It does not validate that type at runtime.
Use formDataParams for endpoints that take a file. For example, to upload a skill archive to a page in a Skills database:
import { readFile } from "fs/promises"
import type { UploadSkillResponse } from "@notionhq/client"
// POST /v1/ai/skills/:id/upload
const response = await notion.request<UploadSkillResponse>({
path: `ai/skills/${skillPageId}/upload`,
method: "post",
formDataParams: {
file: {
filename: "skill.tar.gz",
data: new Blob([await readFile("./skill.tar.gz")], {
type: "application/gzip",
}),
},
},
})
[!TIP] Prefer a named SDK method when one exists, such as
notion.comments.create()for this example.request()can call endpoints that the SDK does not yet cover.
The Client constructor also accepts a custom fetch function.
Verifying webhook signatures
verifyWebhookSignature checks the signature on a Notion webhook event. It uses the raw request body, the subscription's verification token, and the X-Notion-Signature header. The header contains an HMAC-SHA256 signature in the form sha256=<hex>.
import { verifyWebhookSignature } from "@notionhq/client"
const verificationToken = process.env.NOTION_WEBHOOK_VERIFICATION_TOKEN
if (!verificationToken) {
throw new Error("Missing webhook verification token")
}
// Express example. Use the raw body: parsing and re-serializing JSON
// can change its bytes and invalidate the signature.
app.post(
"/notion-webhook",
express.text({ type: "application/json" }),
async (req, res) => {
const body: unknown = req.body
if (typeof body !== "string") {
return res.status(400).send("expected a raw text body")
}
const ok = await verifyWebhookSignature({
body,
signature: req.header("x-notion-signature"),
verificationToken,
})
if (!ok) {
return res.status(401).send("invalid signature")
}
const event: unknown = JSON.parse(body)
// Validate the event's shape before using its fields.
res.status(200).send("ok")
}
)
Subscription setup is separate from event validation. The webhook setup guide covers receiving and saving the initial verification token.
signWebhookPayload({ body, verificationToken }) creates a signature for tests without a live subscription.
[!NOTE] Both helpers are async and use
globalThis.crypto.subtle.
Examples
For sample code and example projects, see notion-cookbook.
Requirements and compatibility
This package supports the following minimum versions:
- Runtime:
node >= 22 - Type definitions (optional):
typescript >= 5.9
Older versions are not supported. SDK releases also have minimum recommended Notion API versions:
| Version of JS/TS SDK | Minimum recommended API version |
|---|---|
| v4.0.0 and above | 2022-06-28 |
| v5.0.0 and above | 2025-09-03 |
This SDK supports both 2025-09-03 and 2026-03-11 API versions. The default is 2025-09-03. To use the newer version, pass it when constructing the client:
const notion = new Client({
auth: process.env.NOTION_TOKEN,
notionVersion: "2026-03-11",
})
Key changes in 2026-03-11:
- The
positionparameter replacesafteronappendBlockChildren. It supportsafter_block,start, andend. - The
in_trashfield replacesarchivedon pages, blocks, databases, and data sources. - The
meeting_notesblock type replacestranscription.
The SDK's TypeScript types include both sets of field names. Older names are marked @deprecated.
The notionVersion constructor option sets the API version header for requests.
Contributing
Follow the contribution guide to build, test, and check SDK compatibility before opening a pull request.
Endpoint code is generated from a schema in Notion's internal repo. Outside contributors cannot run that generator. Ask a maintainer for generated-code changes; direct edits will be overwritten. Open an issue to discuss changes to the SDK's core behavior first.
Docs, examples, and bug reports are welcome.
Getting help
For API support, SDK problems, or feature requests, email [email protected].
You can also open an SDK issue, but we do not monitor issues as closely as email.
Related repositories
Strapi is a self-hosted headless CMS that auto-generates REST and GraphQL APIs from content model definitions you build visually with the Content-Type Builder — no code required on the API side. It ships with authentication, granular roles and permissions, a media library, i18n, and draft/publish workflows out of the box, and the request pipeline (Routes → Middlewares → Controllers → Services) is fully overridable at each layer. TypeScript is first-class and you can pair it with SQLite for local dev or PostgreSQL/MySQL/MariaDB in production. The plugin system and customizable admin panel are real extensibility points, not marketing. The tradeoff: there's no official Docker image (you roll your own from your project), and major version upgrades have been historically painful — the migration docs are thorough but the process still demands attention. Worth it if you need full control over your content infrastructure and don't mind owning the deployment; less ideal if you want something you can set and forget.
Four public comments on TypeScript from Hacker News and GitHub, 2015 to 2022: praise for the compiler API and complaints about imports and exceptions.
Deno has 108,941 GitHub stars, but firsthand opinions on Hacker News and GitHub are thin: URL imports, npm friction, binary size and a regression claim.
Storybook is a frontend workshop maintained at storybookjs/storybook. It renders UI components and pages in isolation from your main application. Core renderers include React, Angular, Vue 3, Web Components, HTML, Ember, Svelte, and Preact, plus React Native and community support for Qwik and SolidJS. It's released under the MIT license.
Quick answers
How active is development on makenotion/notion-sdk-js?
The most recent commit recorded on makenotion/notion-sdk-js was 3 months ago, based on the GitHub push timestamp. The repository has 715 forks — one of the better signals of community interest.
How does makenotion/notion-sdk-js compare to other Frontend projects?
makenotion/notion-sdk-js is tracked by TopGit in the Frontend category, with 5.7k GitHub stars and written in TypeScript. Browse the Frontend topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does makenotion/notion-sdk-js have?
makenotion/notion-sdk-js has 5.7k GitHub stars — refresh the page for the live number, or check github.com/makenotion/notion-sdk-js. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is makenotion/notion-sdk-js open source?
Yes — makenotion/notion-sdk-js ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/makenotion/notion-sdk-js.
What is makenotion/notion-sdk-js?
makenotion/notion-sdk-js (makenotion/notion-sdk-js) is a TypeScript project on GitHub. From the project's own README: Official Notion JavaScript Client
Where do I read more about makenotion/notion-sdk-js?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/makenotion/notion-sdk-js is the definitive source.
Read full README in the tab above.
Curious whether notion-sdk-js is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about notion-sdk-js.