Insights

Last updated:

For instructions on how to authenticate to use this endpoint, see API overview.

The /api/insight/ endpoints allow you to run queries on your data in PostHog.

Want to contribute? This page currently only documents the Trend endpoint. Documentation for Funnels, Paths, Correlation Analysis, Lifecycle and Stickiness is missing. Edit this page in GitHub with a PR to contribute.

Endpoints

Trend

GET
/api/insight/trend

Get a list of trends from PostHog.

Query parameters

ParameterType / Valid ValuesDescriptionRequired
eventsArray of EventsBasic usage is [{"id": "$pageview"}].

For each event, you can specify:
- id Name of the event
- properties A Properties object (see below)
- order (int) order of the event. This is mostly used for funnels
propertiesArray of PropertiesThe key/values that you want to filter on. Basic usage is: [{"key": "$browser", "value": "Chrome"}]

For each property, you can specify:
- key Key of the property
- value Value you want to filter on
- type Either person or event
- operator, any of:
-- exact/empty
--is_not
--icontains
--not_icontains
--gt
--lt
--is_set
intervalstringInterval of the data. minute, hour, day, week, month
breakdown_valuestringSplit out all entities by any property value or cohort id.
breakdown_typestringDefault: property. Can be set to cohort, in which case you can pass through a cohort_id to breakdown_value
displaystringDefault: ActionsLineGraph. Determines how the data is aggregated at the end.

- ActionsLineGraph default, one result per day
- ActionsBarValue all values over the time range aggregated to one result. Useful if you're breaking things down.

Example

Request
GET /api/insight/trend/?events=[{"id":"$pageview"}]&interval=week
Response
HTTP 200 OK
Content-Type: application/json
{
"result": [
{
"action": {
"id": "$pageview",
"type": "events",
"order": null,
"name": "$pageview",
"math": null,
"math_property": null,
"properties": []
},
"label": "$pageview",
"count": 84.0,
"data": [
0.0,
69.0,
15.0
],
"labels": [
"Sun. 18 April",
"Sun. 25 April",
"Sun. 2 May"
],
"days": [
"2021-04-18",
"2021-04-25",
"2021-05-02"
]
}
],
"next": null
}

Ask a question