Call endpoints from your app
Contents
Open beta
Endpoints is in beta and free to use while it is. Send us feedback in app.
The API is where endpoints earn their keep. Your app makes one authenticated request to a named route, and PostHog runs the saved query and returns the rows – no query construction in client code, and no analytics logic spread across your services.
Terminal
What you can do here
- Parameterize the query – pass variables so one endpoint serves many customers, date ranges, or breakdowns.
- Page through results – use
limitandoffsetfor large result sets. - Pin to a version – target a specific version so a query change doesn't break a deployed client.
- Generate a typed client – each endpoint publishes an OpenAPI 3.0 spec you can feed to
openapi-generatoror@hey-api/openapi-ts. See OpenAPI SDK generation.
Authentication
Requests use either a project secret API key or a personal API key, both scoped to endpoint:read. Project secret keys are the right choice for backend services since they aren't tied to a user account.
Never ship either key in client-side code. For customer-facing analytics, proxy the request through your own backend and pass the customer identifier as a variable.
Related
- Worked examples in cURL, Python, Node.js, TypeScript, and Go: retrieve your data.
- What happens between your request and the response: how execution works.
- How many requests you can make: rate limits.
- When to use an endpoint instead of a raw query: endpoints vs the query API.