Skip to main content
The Notion SDK provides type guard functions to help you narrow TypeScript types at runtime and distinguish between full and partial response objects.

Block Type Guards

isFullBlock

Checks if a response is a full BlockObjectResponse (not a partial block).
Example:

Page Type Guards

isFullPage

Checks if a response is a full PageObjectResponse (not a partial page).
Example:

isFullPageOrDataSource

Checks if a response is a full PageObjectResponse or DataSourceObjectResponse. Useful when working with search or queryDataSource results.
Example:

Database Type Guards

isFullDatabase

Checks if a response is a full DatabaseObjectResponse (not a partial database).
Example:

Data Source Type Guards

isFullDataSource

Checks if a response is a full DataSourceObjectResponse.
Example:

User Type Guards

isFullUser

Checks if a response is a full UserObjectResponse (not a partial user).
Example:

Comment Type Guards

isFullComment

Checks if a response is a full CommentObjectResponse (not a partial comment).
Example:

Rich Text Type Guards

isTextRichTextItemResponse

Checks if a rich text item is a text type.
Example:

isEquationRichTextItemResponse

Checks if a rich text item is an equation type.
Example:

isMentionRichTextItemResponse

Checks if a rich text item is a mention type.
Example:

Why Use Type Guards?

The Notion API returns different response shapes depending on the context:
  • Full objects contain all properties and are returned by direct retrieve operations
  • Partial objects contain only id and object properties and are returned in some contexts where full data isn’t available
Type guards help you:
  1. Write type-safe code that TypeScript can verify
  2. Handle partial responses gracefully
  3. Access properties that only exist on full objects
  4. Distinguish between different rich text types