Block Type Guards
isFullBlock
Checks if a response is a fullBlockObjectResponse (not a partial block).
Page Type Guards
isFullPage
Checks if a response is a fullPageObjectResponse (not a partial page).
isFullPageOrDataSource
Checks if a response is a fullPageObjectResponse or DataSourceObjectResponse. Useful when working with search or queryDataSource results.
Database Type Guards
isFullDatabase
Checks if a response is a fullDatabaseObjectResponse (not a partial database).
Data Source Type Guards
isFullDataSource
Checks if a response is a fullDataSourceObjectResponse.
User Type Guards
isFullUser
Checks if a response is a fullUserObjectResponse (not a partial user).
Comment Type Guards
isFullComment
Checks if a response is a fullCommentObjectResponse (not a partial comment).
Rich Text Type Guards
isTextRichTextItemResponse
Checks if a rich text item is a text type.isEquationRichTextItemResponse
Checks if a rich text item is an equation type.isMentionRichTextItemResponse
Checks if a rich text item is a mention type.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
idandobjectproperties and are returned in some contexts where full data isn’t available
- Write type-safe code that TypeScript can verify
- Handle partial responses gracefully
- Access properties that only exist on full objects
- Distinguish between different rich text types