You have metrics. Revenue, active users, churn, usage per customer. They live in your data warehouse. Now you need to serve them to multiple consumers: your product's frontend, your customers' integrations, an AI agent, a scheduled report generator.
The first instinct is custom API endpoints. One endpoint for revenue by region. Another for churn by plan. Another for the customer dashboard. Each endpoint has its own SQL query, its own response format, its own maintenance burden. By the twentieth endpoint, you're running a bespoke analytics service.
An analytics API backed by a semantic layer gives you one query interface that serves every consumer. Define metrics once. Query them from anywhere.
What is an analytics API?
An analytics API is a programmatic interface for querying metrics. Instead of connecting to a database and writing SQL, consumers call an API endpoint with the metrics they want and get structured results back.
curl https://analytics.example.com/v1/query \
-H "Authorization: Bearer bon_pk_..." \
-d '{
"measures": ["orders.total_revenue", "orders.order_count"],
"dimensions": ["orders.region"],
"timeDimensions": [{
"dimension": "orders.created_at",
"granularity": "month",
"dateRange": ["2026-01-01", "2026-03-31"]
}],
"orderBy": { "orders.total_revenue": "desc" }
}'
The response is structured JSON:
{
"data": [
{ "orders.region": "EMEA", "orders.total_revenue": 142000, "orders.order_count": 340, "orders.created_at": "2026-01-01" },
{ "orders.region": "APAC", "orders.total_revenue": 98000, "orders.order_count": 220, "orders.created_at": "2026-01-01" }
]
}
Every consumer uses the same interface. The dashboard frontend, the customer's API integration, the scheduled report, and the AI agent all query the same endpoint with the same metric definitions. The analytics API handles query generation, execution, caching, and access control.
Why not just build API endpoints?
Custom endpoints work at small scale. They break at medium scale:
Metric drift. /api/revenue and /api/dashboard/revenue both return "revenue" but use different SQL queries. One gets updated. The other doesn't.
N+1 endpoint problem. Every new metric or dimension combination is a new endpoint. Revenue by region. Revenue by plan. Revenue by region AND plan. Revenue by region AND plan AND month. The combinatorial explosion is real.
No caching strategy. Each endpoint hits the warehouse on every request. Response times grow with data volume. You end up building a caching layer per endpoint.
No access control. Each endpoint implements its own auth. Customer A's key works on all endpoints or none. Per-tenant, per-metric access control is custom code.
A shared query interface handles all of this. But there's a gap that shows up once AI agents become consumers: an agent that fetches rows still has to present them. A wall of JSON tells the user nothing. Agents need to chart query results, not just fetch them.
Charting the results an agent fetches
Fetching rows is half the job. The other half is rendering them so a person can read the answer. An analytics API that serves agents needs a way to return the picture as well as the numbers.
How the flow works
- The agent calls the query interface with measures, dimensions, and filters.
- The API runs the governed query against your warehouse and returns typed rows.
- The server builds the chart from the typed result: line, bar, or area for trends, scatter for distributions, funnel or waterfall for staged data, pie for shares, or a table when a table is the right answer.
- The host renders it inside Claude or ChatGPT over MCP.
Axes, formatting, and gap-fill are decided from the typed schema, so the same query produces the same chart every time. The model never draws the chart, so the picture cannot disagree with the rows.
One query interface for the numbers. One rendering path for the picture.
Analytics API vs alternatives
| Approach | Metric governance | Multi-tenant | Caching | Maintenance |
|---|---|---|---|---|
| Custom REST endpoints | None (per-endpoint SQL) | DIY | DIY | High (per endpoint) |
| GraphQL API | Schema-level | DIY | Per-resolver | Medium-high |
| Direct warehouse access | None | Manual | None | Low (but dangerous) |
| BI tool API (Looker, Metabase) | Tool-specific | Tool-specific | Tool-specific | Medium |
| Bonnard | Your database or semantic layer (dbt, Cube, MetricFlow, custom) | Four isolation models, role-based per app | Inherits your warehouse | Low (connect data, create an app, choose the audience, publish). Charts and tables render in Claude, ChatGPT, Gemini, and Copilot from governed query results |
When you need an analytics API
You need one when:
- Multiple consumers query the same metrics (frontend + backend + AI agents)
- Customers integrate with your data via API
- You're building embedded analytics with a frontend SDK
- AI agents need programmatic access to governed data
- Your data team is tired of building custom endpoints
You don't need one when:
- A single dashboard covers all use cases
- Nobody queries your metrics programmatically
- The data model is so simple that direct SQL is fine
Where Bonnard fits
Bonnard is the managed form of this: governed BI inside the AI clients your consumers already use, rather than an endpoint you host. Connect PostgreSQL, BigQuery, Redshift, ClickHouse, DuckDB or MotherDuck, or MySQL or MariaDB, or sit it on a dbt, Cube, MetricFlow, or custom semantic layer. Create an app, choose the audience, publish. Role-based access per app, four tenancy models, and a per-call audit log come with it. Bonnard is pre-launch. Join the waitlist.
Frequently asked questions
What is an analytics API?
An analytics API is a programmatic interface for querying business metrics. Instead of writing SQL against a database, consumers call an API with the measures, dimensions, and filters they want. The API handles query generation, caching, and access control.
How is an analytics API different from a REST API?
A generic REST API exposes resources (users, orders, invoices). An analytics API exposes metrics (revenue, churn rate, active users) with aggregation, filtering, and time dimensions built in. The query interface is designed for analytical questions, not CRUD operations.
Do I need an analytics API for AI agents?
If AI agents query your data, an analytics API is the governed path. The alternative is giving agents direct database access (dangerous) or text-to-SQL (inconsistent). An analytics API backed by a semantic layer gives agents governed access to metric definitions. See What Is an Agentic Semantic Layer?.
What about GraphQL for analytics?
GraphQL works for analytics APIs but you end up building the aggregation, caching, and access control layer yourself. A semantic layer provides these out of the box with a purpose-built query interface for analytical workloads.
Top comments (0)