Skip to main content
The Notion SDK is written in TypeScript and provides full type definitions for all API requests and responses.

Type-Safe API Calls

All client methods are fully typed with request parameters and response types:

Importing Types

All types are exported from the main package:

Request Parameter Types

Each API method has a corresponding parameter type:

Common Parameter Types

Response Types

Each API method returns a typed response:

Type Guards

Use type guards to narrow union types:

Object Type Guards

Full Page or Data Source

Rich Text Type Guards

Error Type Guards

Block Types

Different block types have distinct structures:

Property Types

Database properties have different value types:

Generic Type Utilities

Extract types from SDK types:

Helper Type Examples

Create Type-Safe Wrappers

Extract Property Values

Type-Safe Configuration

Working with Unknown Types

When dealing with dynamic data, use type assertions carefully:
Use type assertions sparingly. Prefer type guards like isFullPage() to safely narrow types.

Best Practices

  1. Import types separately - Use import type { ... } for type-only imports
  2. Use type guards - Prefer isFullPage() over manual type checks
  3. Leverage discriminated unions - Use type fields to narrow block/property types
  4. Avoid any - The SDK provides complete types; use them
  5. Type function parameters - Explicitly type parameters that accept SDK types