Expand description
notion2prompt library — converts Notion pages and databases into structured prompts.
§Public API
The library exposes types organized by concern:
- Error handling —
AppError,ValidationError - Configuration —
PipelineConfig - Domain model —
NotionObject,Page,Database,Block, etc. - Domain types —
NotionId,ApiKey,BlockId,PageId, etc. - API client —
NotionFetcher,NotionHttpClient, parsers - Formatting —
render_blocks,RenderContext,TableBuilder
Structs§
- Annotations
- ApiKey
- API key for Notion API authentication
- ApiResponse
- Result of an HTTP operation with response metadata.
- Block
Common - Common fields for all blocks
- Bookmark
Block - Bookmark block
- Breadcrumb
Block - Breadcrumb block
- Bulleted
List Item Block - Bulleted list item block
- Cached
Notion Client - A
NotionRepositoryimplementation that caches raw API JSON responses to disk. Cache hits re-parse through the standard parsers so the domain model is never serialized/deserialized directly. - Callout
Block - Callout block
- Child
Database Block - Child database block
- Child
Page Block - Child page block
- Code
Block - Code block
- Column
Block - Column block
- Column
List Block - Column list block
- Database
- A Notion database
- Database
Property - Database property definition
- Database
Title - Database title
- Date
Value - Date value with optional time and end date
- Divider
Block - Divider block
- Embed
Block - Embed block
- Equation
Block - Equation block
- Equation
Data - External
File - File
Block - File block
- Heading1
Block - Heading 1 block
- Heading2
Block - Heading 2 block
- Heading3
Block - Heading 3 block
- Image
Block - Image block
- Link
- Link
Preview Block - Link preview block
- Link
ToPage Block - Link to page block
- Mention
Data - Mention data with type information
- Notion
Fetcher - Enhanced queue-based fetcher with parallel work-stealing and error recovery.
- Notion
File - Notion
Http Client - A thin wrapper around reqwest Client for Notion API requests.
- Notion
Id - NotionId - A general-purpose Notion ID that can represent any type of object
- Numbered
List Item Block - Numbered list item block
- Object
Graph - Immutable graph representing parent-child relationships between Notion objects.
- Page
- A Notion page
- Page
Title - Page title
- Paragraph
Block - Paragraph block
- Partial
User - Partial user representation (used in mentions)
- PdfBlock
- PDF block
- Pipeline
Config - Resolved pipeline configuration — validated and ready to drive all three stages.
- Property
Name - The name of a property on a Notion page or database.
- Property
Value - Property value — wraps a typed value with its property ID.
- Quote
Block - Quote block
- Render
Context - Context passed through the rendering pipeline.
- Rendered
Prompt - The final output of the render stage — a complete prompt ready for delivery.
- Rich
Text Item - Rich text item with formatting annotations.
- Select
Option - Select option
- Synced
Block - Synced block
- Synced
From - Table
Block - Table block
- Table
Builder - Builder for constructing tables from databases.
- Table
OfContents Block - Table of contents block
- Table
RowBlock - Table row block
- Template
Block - Template block
- Template
Name - Template name with validation
- Text
Block Content - Text content block
- Text
Content - Legacy text content — kept for API deserialization compatibility.
- ToDo
Block - To-do block
- Toggle
Block - Toggle block
- Unsupported
Block - Unsupported block
- User
- User representation
- Validated
Url - Validated URL type
- Video
Block - Video block
- Warning
- Warning message with structured information
Enums§
- AppError
- Main application error type.
- Block
- Block represents all possible Notion block types
- Child
Database Content - The resolution state of a child database’s content.
- Color
- Type-safe color enum instead of strings
- Database
Fetch Failure - Domain vocabulary for why a database fetch failed.
- Database
Property Type - Database property types
- Fetch
Error - Error that can occur during content retrieval operations.
- File
Object - File object types
- Formula
Result - Formula result types
- Icon
- Icon types
- Mention
Type - Different types of mentions in rich text
- Notion
Object - The root object that can be fetched from Notion
- Number
Format - Number format options
- Parent
- Parent reference with typed IDs
- Property
Type Value - The specific value types for properties - compatibility layer
- Rich
Text Type - The kind of rich text content — a typed vocabulary replacing stringly-typed dispatch.
- Rollup
Result - Rollup result types - used by legacy PropertyValue system
- Track
Error - Error that can occur during visit tracking operations.
- Validation
Error - Warning
Level
Traits§
- Block
Visitor - Visitor trait for traversing block structures.
- Content
Source - Retrieves Notion content by ID.
- Depth
Limiter - Depth limiting capability for controlling recursion depth.
- Notion
Content - Content retrieval capability for Notion API.
- Notion
Content Ext - Extension trait with typed convenience methods for
NotionContent. - Notion
Repository - The ability to retrieve content from a Notion workspace.
- Prompt
Composer - Transforms a NotionObject into a RenderedPrompt.
- Prompt
Delivery - Delivers a rendered prompt to its destinations.
- Visit
Tracker - Visit tracking capability for preventing cycles during recursive traversal.
Functions§
- compose_
block_ markdown - Composes a single block into markdown with a heading.
- compose_
database_ summary - Composes a database summary as markdown: title, schema, data count, metadata.
- compose_
notion_ markdown - Composes any NotionObject into markdown — dispatches by variant.
- compose_
page_ markdown - Composes a Notion page into markdown: title, properties, content, metadata.
- parse_
block_ response - Parse block response using notion-client
- parse_
blocks_ pagination - Pagination function for blocks (using notion-client) - returns PaginatedResponse
- parse_
database_ response - Parse database response using notion-client
- parse_
page_ response - Parse page response using notion-client
- parse_
pages_ pagination - Pagination function for pages (using notion-client) - returns PaginatedResponse
- render_
blocks - Renders a slice of blocks into markdown.
- render_
prompt - Renders a NotionObject into a prompt string using Handlebars templates.
Type Aliases§
- BlockId
- Database
Id - PageId
- Type aliases for specific ID types
- UserId