Overview
Endpoints enable you to create predefined queries from PostHog insights or SQL queries and expose them as API endpoints. You could use endpoints to:
- Build embedded analytics. Show analytics to your customers in your own application
- Pull aggregated PostHog data into your app. Use PostHog data to create feeds with top content, recommended items or more.
Endpoints offers a number of advantages over our query API, such as materialization (giving you better performance) and through the use of isolated resources.


How endpoints work
Endpoints follow a simple workflow:
- Create an insight or SQL query in PostHog that defines the data you want to expose
- Create an endpoint from that insight or query, giving it a custom name
- Access the data via a simple API endpoint with improved performance and rate limits
Endpoint URL pattern
Endpoints follow this URL pattern:
/api/environments/:project_id/endpoints/:endpoint_name/runFor example:
/api/environments/2/endpoints/example-sql-2/run/api/environments/2/endpoints/account_users_activity/run
Endpoints vs API queries
Endpoints vs API queries
You should use endpoints when you need:
- Better performance: Optimized for predefined queries
- Higher rate limits: More requests per minute/hour than standard API queries
- Stable URLs: Consistent endpoint names that don't change
If you need to run ad-hoc queries or don't have predefined queries, API queries may be a better fit, but it will come at a cost.
