Notion AI API Endpoints for Database Views: A Developer’s Tour
The 60-second version
Until Notion 3.4 part 2, working with database views via the API meant fetching the underlying database and replicating view logic in code. The new endpoints give direct programmatic access to view configurations — query a view, apply its filters server-side, modify its display properties, all via the API. For developers building agents and integrations, this removes a significant friction point.
What the new endpoints enable
1. Query a view directly.
Fetch the rows a specific view shows, with the view’s filters and sorts already applied. Previously, you fetched the database and re-implemented filtering in client code. Now the server does it.
2. Read view configuration.
Inspect what a view’s filters, sorts, and column selections are. Useful for agents that need to understand what a view represents.
3. Modify view properties programmatically.
Update filters, sorts, or display settings via API. Useful for dynamic views that adapt based on agent context.
4. List views per database.
Enumerate all views attached to a database. Helpful for agents that need to discover the right view to query.
Three patterns this enables
1. View-driven agent context.
Instead of giving an agent the entire database and a complex prompt about filtering, point the agent at a pre-configured view. The view defines the context; the agent works with the filtered subset.
2. Dynamic view modification.
An agent that adjusts a view’s filter based on conversation. “Show me last week’s high-priority items” becomes a real query against a view, not a search across the whole database.
3. View-as-API.
Treat each view as a parameterized data endpoint. Builders can expose specific views to specific agents, controlling exactly what data the agent sees through the view definition.
Practical implementation notes
- Fetching views: Use the database fetch tool first to discover view URLs. View URLs include the view ID after
?v=. - Multi-source databases: Views may apply to a specific source.
- Permissions: API access to views inherits the database’s permission model.
Where this goes wrong
1. Treating views as static. Views can be modified by users in the UI. Agents that cache view configurations get stale.
2. Over-fetching. Querying a view is more efficient than fetching the database and filtering client-side. Migrate.
3. Confusion between views and data sources. Multi-source databases have both. Don’t mix the API parameters.
What to read next
Workers + External APIs, Workers in TypeScript, MCP, Designing Database Schemas for Autofill.
Leave a Reply