You can get data that's displayed on the dashboard graphs in JSON format with the Dashboard REST API.
This API uses basic authentication, using the API key and secret key for your project. Pass base64-encoded credentials in the request header like {api-key}:{secret-key}
. api-key
replaces username, and secret-key
replaces the password.
Your authorization header should look something like this:
--header 'Authorization: Basic YWhhbWwsdG9uQGFwaWdlZS5jb206bClwYXNzdzByZAo'`
For more information, see Find your API Credentials
Region | Endpoint |
---|---|
Standard server | https://amplitude.com/api/2/ |
EU residency server | https://analytics.eu.amplitude.com/api/2/ |
Play Song
as Play%20Song
. Use the W3Schools encoding reference for help.For each endpoint, there is a concurrent limit and a rate limit. The concurrent limit restricts the number of requests you can run at the same time. The rate limit restricts the total number of queries you can run per hour. Exceeding these limits returns a 429 error. These limits are per project, and the 429 error also includes information on how you are exceeding the limit.
Concurrent Limit: You can run up to 5 concurrent requests across all Amplitude REST API endpoints, including cohort download.
You can run up to 360 queries per hour for user activity and user search endpoints.
The User Activity and User Search endpoints have a different rate limit than all other request types.
Endpoints use cost per query model. Amplitude calculates cost based on this formula:
cost = (# of days) * (# of conditions) * (cost for the query type)
Here is how Amplitude determines each variable in the formula:
Different chart types have different costs. For all endpoints not listed here, the cost is 1.
Here are the limits for these endpoints, measured in the cost per query:
Concurrent Limit: Up to 1000 cost at the same time.
Rate Limit: Up to 108,000 cost per hour.
Event Segmentation: Equal to the number of events you are looking at in the left module. If any event has a group by, add a cost of 4 per group by and event.
Funnel Analysis: The number of events you are looking at in the funnel multiplied by two. If any event has a group by, add a cost of 4 per group by and event.
Retention Analysis: The cost for this chart is 8.
User Sessions: The cost for this chart is 4.
These query parameters are shared across several Dashboard REST API endpoints.
version
, country
, city
, region
, DMA
, language
, platform
, os
, device
, device_type
, start_version
, and paying
.gp:name
.Parameter | Description |
---|---|
e |
A full event with optional property filters or group by. Events are represented as JSON objects as described in event format. |
s |
Segment definitions. Include as many as needed. Segments are represented as JSON arrays, where each element is a JSON object corresponding to a filter condition as described segment definition. |
g |
The property to group by, for example platform . Available only when there is a single segment. Limit: two. |
The event parameter can include these keys:
Name |
Description |
---|---|
event_type |
Required. The event type. For custom events, prefix the name with ce: . For example: "ce:name". For '[Amplitude] Any Active Event', use _active .For '[Amplitude] Any Event', use _all . For '[Amplitude] Revenue', use revenue_amount . For '[Amplitude] Revenue (Verified)', use verified_revenue . For '[Amplitude] Revenue (Unverified)', use unverified_revenue . |
filters |
Optional. A list of property filters. Each filter is a JSON object with the following keys: subprop_type Required. Either "event" or "user", indicating that the property is either an event or user property, respectively. subprop_key Required. The name of the property to filter on. Note: For non-Amplitude, custom user properties, prepend the user property name with gp: . gp: isn't needed for event properties.subprop_op Required. The operator for filtering on specific property values, either is , is not , contains , does not contain , less , less or equal , greater , greater or equal , set is , or set is not .subprop_value : Required. A list of values to filter the event property by. |
group_by |
Optional. A list of properties to group by (at most 2). Each group by is a JSON object with these keys:type Required. - Either "event" or "user", indicating that the property is either an event or user property, respectively. value Required. - The name of the property to group by. |
1{ 2 "event_type": "CompletedProfile", 3 "filters": [ 4 { 5 "subprop_type": "event", 6 "subprop_key": "EmailVerified", 7 "subprop_op": "is", 8 "subprop_value": [ 9 "true"10 ]11 },12 {13 "subprop_type": "user",14 "subprop_key": "gp:SignUpDate",15 "subprop_op": "is",16 "subprop_value": [17 "2021-08-18"18 ]19 }20 ],21 "group_by": [22 {23 "type": "user",24 "value": "platform"25 }26 ]27}
Name | Description |
---|---|
prop |
Required. The name of the property to filter on. For behavioral cohorts, the name of the property is "userdata_cohort". Example ("XYXxxzz" is the identifier from the Behavioral Cohort's URL, https://analytics.amplitude.com/org_name/cohort/XYXxxzz.) s=\[\{"prop":"userdata_cohort","op":"is","values":\["XYXxxzz"\]\}\] |
op |
Required. The operator for filtering on specific property values. Allowed values are is , is not , contains , does not contain , less , less or equal , greater , greater or equal , set is , or set is not . |
values |
Required. A list of strings to filter the segment by. If you are segmenting by a cohort, the value is the cohort ID, found in URL of the cohort in the web app (for example, "5mjbq8w"). |
1[ 2 { 3 "prop": "version", 4 "op": "contains", 5 "values": ["1.0", "2.0"] 6 }, 7 { 8 "prop": "gp:gender", 9 "op": "is",10 "values": ["female"]11 }12]
You can use the Dashboard REST API to export data from data tables. Just query any Data Table chart type, and don't include start or end dates in the query.
Get JSON results from any saved chart via chart ID.
GET https://amplitude.com/api/3/chart/chart_id/query
1curl --location --request GET 'https://amplitude.com/api/3/chart/:chart_id/query' \2-u '{api_key}:{secret_key}'
1GET /api/3/chart/:chart_id/query HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Name | Description |
---|---|
chart_id |
Required. The chart's ID. Get the chart ID from the chart's URL in the web app. For example, 'abc123' in this URL: https://analytics.amplitude.com/demo/chart/abc123. |
Responses vary based on the chart's type.
Get the number of active or new users.
GET https://amplitude.com/api/2/users
1curl --location --request GET 'https://amplitude.com/api/2/users?start=STARTDATE&end=ENDDATE' \2-u '{api_key}:{secret_key}'
1GET /api/2/users?start=20210101&end=20210901&m=active&i=30&g=city HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Example: Get active users for a period, counted in an interval
Example: Get active users for a period, segmented by a property, counted in an interval
Name | Description |
---|---|
start |
Required. First date included in data series, formatted YYYYMMDD. For example, "20221001". |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example, "20221001". |
m |
Optional. Either "new" or "active" to get the desired count. Defaults to "active". |
i |
Optional. Either 1, 7, or 30 for daily, weekly, and monthly counts, respectively. Defaults to 1. |
s |
Optional. Segment definitions. Defaults to none. Defined in Shared query parameters. |
g |
Optional. The property to group by. Defaults to none. Defined in Shared query parameters |
The response is a JSON object with this schema:
Attribute |
Description |
---|---|
series |
An array with one element for each group, in the same order as "seriesMeta", where each element is itself an array that has the value of the metric on each of the days specified in xValues . |
seriesMeta |
An array of labels with one for each segment. |
xValues |
An array of (string) dates in the form "YYYY-MM-DD", one for each date in the specified range. |
1{ 2 "data": { 3 "series": [ 4 [46109, 47542], 5 [42845, 42626] 6 ], 7 "seriesMeta": ["United States", "Canada"], 8 "xValues": ["2017-08-14", "2017-08-15"] 9 }10}
Get the number of sessions for each pre-defined length ("bucket") period during a specified date range.
GET https://amplitude.com/api/2/sessions/length
1curl --location --request GET 'https://amplitude.com/api/2/sessions/length?start=STARTDATE&end=ENDDATE'2-u '{api_key}:{secret_key}'
1GET /api/2/sessions/length?start=20210426&end=20210905 HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} # credentials must be base64 encoded
Example: Get session length distribution with a custom bin for a period
Example: Get session length distribution by hours with a custom bin size for period
Name |
Description |
---|---|
start |
Required. First date included in data series, formatted YYYYMMDD. For example,"20221001". |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example,"20221001". |
timeHistogramConfigBinTimeUnit |
Optional. Time unit for bucket sizes (see below for valid inputs). |
timeHistogramConfigBinMin |
Optional. Minimum value for bucketing, as a number. For example, "0". |
timeHistogramConfigBinMax |
Optional. Maximum value for bucketing, as a number. For example, "600". |
timeHistogramConfigBinSize |
Optional. Size of each bucket, as a number. For example, "60". |
timeHistogramConfigBinTimeUnit
is any of ['hours', 'minutes', 'seconds']
.
To take advantage of custom binning, you must specify timeHistogramConfigBinMin
, timeHistogramConfigBinMax
, and timeHistogramConfigBinTimeUnit
. When timeHistogramConfigBinSize
isn't specified, Amplitude tries to find the best bin sizing. For example, if you have timeHistogramConfigBinMin=0
, timeHistogramConfigBinMax=10
, and timeHistogramConfigBinTimeUnit=minutes
, there is no guarantee for the final number of bins or bin bounds. If timeHistogramConfigBinSize=1
is specified, then there are 10 bins, and each bin size equals a minute.
When combined timeHistogramConfigBin
parameters are invalid or missing, Amplitude defaults to default bins that account for certain behaviors such as bounce rate. These bins are (in milliseconds): [0, 3000), [3000, 10,000), [10,000, 30,000), [30,000, 60,000), [60,000, 180,000), [180,000, 600,000), [600,000, 1,800,000), [1,800,000, 3,600,000), [3,600,000, 86,400,000)
.
Session lengths have a max length of 1 day (86,400,000 ms).
The response is a JSON object with this schema:
Attribute |
Description |
---|---|
series |
An array with one element which is itself an array that includes the counts (number of sessions) for each of the buckets. |
xValues |
An array of the (string) session length intervals (buckets) of the format [bucketStartInSeconds]s-[bucketEndInSeconds]s . |
1{2 "data": {3 "series": [4 [0, 120408, 2261, 6984, 10778, 54529, 210614, 336605, 196235, 54148]5 ],6 "xValues": ["0s-60s", "60s-120s", "120s-180s", "180s-240s", "240s-300s", "300s-360s", "360s-420s", "420s-480s", "480s-540s", "540s-600s"]7 }8}
GET https://amplitude.com/api/2/sessions/average
Get the average session length (in seconds) for each day in the specified date range.
1curl --location --request GET 'https://amplitude.com/api/2/sessions/average?start=20210601&end=20210630' \2-u '{api_key}:{secret_key}'
1GET /api/2/sessions/average?start=20210601&end=20210630 HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Name | Description |
---|---|
start |
Required. First date included in data series, formatted YYYYMMDD (for example "20221001"). |
end |
Required. Last date included in data series, formatted YYYYMMDD (for example "20221004"). |
Returns a JSON object with this schema:
Attribute | Description |
---|---|
series |
An array with one element which is itself an array that includes the average session length for each day. |
seriesMeta |
An array of labels with one for each segment. |
segmentIndex |
This represents the index of the segment, referring to its position in the right module of the chart control panel. |
xValues |
An array of (string) dates formatted like "YYYY-MM-DD" with one for each in the specified date range. |
1{ 2 "data": { 3 "series": [ 4 [1204.0238276716443, 1197.4160169086904], 5 ], 6 "seriesMeta": [ 7 {"segmentIndex": 0} 8 ], 9 "xValues": ["2017-08-14", "2017-08-15"]10 }11}
GET https://amplitude.com/api/2/sessions/peruser
Get the average number of sessions per user on each day in the specified date range.
1curl --location --request GET 'https://amplitude.com/api/2/sessions/peruser?start=&end=' \2-u '{api_key}:{secret_key}'
1GET /api/2/sessions/average?start=20210601&end=202106302Host: amplitude.com3Authorization: Basic {api-key}:{secret-key}
Name | Description |
---|---|
start |
Required. First date included in data series, formatted YYYYMMDD (for example "20221001"). |
end |
Required. Last date included in data series, formatted YYYYMMDD (for example "20221004"). |
Returns a JSON object with this schema:
Attribute |
Description |
---|---|
series |
An array with one element which is itself an array that includes the (float) average number of sessions per user for each day. |
seriesMeta |
An array of labels with one for each segment. |
segmentIndex |
This represents the index of the segment, referring to its position in the right module of the chart control panel |
xValues |
An array of (string) dates formatted like "YYYY-MM-DD" with one for each in the specified date range |
1{ 2 "data": { 3 "series": [ 4 [3.624536794878406, 3.6232302614435854] 5 ], 6 "seriesMeta": [ 7 {"segmentIndex": 0} 8 ], 9 "xValues": ["2017-08-14", "2017-08-15"]10 }11}
Get the distribution of users across values of a user property in the specified date range.
GET https://amplitude.com/api/2/composition
1curl --location --request GET 'https://amplitude.com/api/2/composition?start=STARTDATE&end=ENDDATE&p=PROPERTY' \2-u '{api_key}:{secret_key}'
1GET /api/2/composition?start=STARTDATE&end=ENDDATE&p=property HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} # credentials must be base64 encoded
Example: Get user composition by property for a period of time
Example: Get user composition by custom property event for a period
Name | Description |
---|---|
start |
Required. First date included in data series, formatted YYYYMMDD. For example, "20221001". |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example, "20221001". |
p |
Required. The property to get the composition of. For built-in Amplitude properties, valid values are version , country , city , region , DMA , language , platform , os , device , start_version , and paying . For custom-defined user properties, format the key as gp:name. |
Returns a JSON object with this schema:
Attribute |
Description |
---|---|
series |
A one-element array which is the number of unique users who had the corresponding property value in the specified date range. |
seriesLabels |
The field that displays what user property the chart is looking at. |
xValues |
An array of values the chosen property can take on. |
1{2 "data": {3 "series": [4 [69643, 47419, 38087, 19064]5 ],6 "seriesLabels": ["version"],7 "xValues": ["1.0", "(none)", "1.1", "0.2"]8 }9}
Get the list of events with the current week's totals, uniques, and % DAU (daily active users).
GET https://amplitude.com/api/2/events/list
1curl --location --request GET 'https://amplitude.com/api/2/events/list' \2-u '{api-key}:{secret-key}'
1GET /api/2/events/list HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Returns a JSON object with this schema:
Attribute |
Description |
---|---|
non_active |
If the event is marked inactive or not. |
value |
Name of the event in the raw data. |
totals |
The total number of times the event has happened this week. |
deleted |
If the event is deleted or not. |
flow_hidden |
If the event is hidden from Pathfinder/Pathfinder Users or not. |
hidden |
If the event is hidden or not. |
display |
The display name of the event. |
1{ 2 "data": [ 3 { 4 "non_active": false, 5 "value": "Add Content to Cart", 6 "totals": 1505645, 7 "deleted": false, 8 "flow_hidden": false, 9 "hidden": false,10 "display": "Add Content to Cart"11 },12 {13 "non_active": false,14 "value": "Add Friends",15 "totals": 193167,16 "deleted": false,17 "flow_hidden": false,18 "hidden": false,19 "display": "Add Friends"20 }21 ]22 ...23}
Get metrics for an event with segmentation.
1curl --location --request GET 'https://amplitude.com/api/2/events/segmentation?e={"event_type":"YOUR%20EVENT"}&start=STARTDATE&end=DATE' \2-u '{api-key}:{secret-key}'
1GET /api/2/events/segmentation?e={"event_type":"YOUR%20EVENT"}&start=STARTDATE&end=ENDDATE HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
You may need to URL encode special characters in the names of event types, event properties, and user properties. For example, encode Play Song as Play%20Song
.
Example: Get any active event for a period
Example: Get two events for a period
Example: Get a custom event for a period
Example: Get event totals for a period
Example: Get event Active % for a period
Name |
Description |
---|---|
e |
Required. Include up to two. A full event. Full description. Note: Currently, the Dashboard REST API supports segmentation by up to two events. If you wish to query on a second event, the parameter would be "e2". |
m |
Optional. Non-property metrics: uniques , totals , pct_dau , or average . Defaults to uniques . Property metrics: histogram , sums , or value_avg . To use property metrics, you must include a valid group by value in parameter e . For custom formulas: "formula" (Note: This metric only supports up to two events currently and the second event needs to have the parameter "e2"). |
n |
Optional. User type, either any or active . |
start |
Required. First date included in data series, formatted YYYYMMDD. For example, "20221001". |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example, "20221001". |
i |
Set to -300000, -3600000, 1, 7, or 30 for real-time, hourly, daily, weekly, and monthly counts, respectively. Defaults to 1. Real-time segmentation displays up to 2 days of data, hourly segmentation displays up to 7 days of data, and daily displays up to 365 days of data. |
s |
Optional. Segment definitions (default: none). Full description. |
g |
Optional. Include up to two. The property to group by. Defaults to none. Full description. |
limit |
Optional. The number of Group By values returned (default: 100). The limit is 1000. |
formula |
Optional, but required if m is set to formula . If you are using the custom formula metric, you need to pass in the formula here (for example, UNIQUES(A)/UNIQUES(B) ). |
rollingWindow |
Required to use a rolling window. To include a rolling window, pass in the number of days/weeks/months with which to compute a rolling window over. |
rollingAverage |
Required to use a rolling average. To include a rolling average, pass in the number of days/weeks/months with which to compute a rolling average over. |
Attribute |
Description |
---|---|
series |
An array with one element for each group, in the same order as "seriesLabels", where each element is itself an array that includes the value of the metric on each of the days specified in "xValues". |
seriesLabels |
An array of labels, one for each group. |
seriesCollapsed |
An array with one element for each group, in the same order as "seriesLabels", where each element is the value of the bar chart visualization in Event Segmentation. This value is the total unique users over a certain time interval. |
xValues |
An array of (string) dates in the form "YYYY-MM-DD", one for each date in the specified range. |
1{ 2 "data": { 3 "series": [ 4 [273333], [190351] 5 ], 6 "seriesLabels": ["United States", "Germany"], 7 "seriesCollapsed": [ 8 [ 9 {"value": 273333}10 ],11 [12 {"value": 190351}13 ],14 "xValues": ["2014-10-01", "2014-10-02"]15 }16}
Get funnel drop-off and conversion rates.
GET https://amplitude.com/api/2/funnels
1curl --location -g --request GET 'https://amplitude.com/api/2/funnels?e={"event_type":"EVENT_1"}&e={"event_type":"EVENT_2"}&start=STARTDATE&end=ENDDATE'2-u '{api_key}:{secret_key}'
1GET /api/2/funnels?e={"event_type":"EVENT"}&e={"event_type":"EVENT"}&e={"event_type":"EVENT"}&start=STARTDATE&end=ENDDATE HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Example: Get event funnel for a series of events in a period, in any order with a specific conversion time
Example: Get event funnel for a series of events in a period, in a specific order grouped by a property
Example: Get event funnel for a series of events in a period, in a specific order, filtered by property, grouped by property
Example: Get event funnel for four events in a period
Example: Get event funnel for four events in a period, for new users, unordered
Example: Get event funnel for four events in a period, for new users, ordered
Name | Description |
---|---|
e |
Required. A full event for each step in the funnel. Full description |
start |
Required. First date included in data series, formatted YYYYMMDD. For example, 20221001 . |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example, 20221001 . |
mode |
Optional. What mode to run the funnel in: ordered for events in the given order, unordered for events in any order, and sequential for events in the given order with no other events between. Defaults to ordered . |
n |
Optional. Either "new" or "active" to specify what set of users to consider in the funnel. Defaults to active . |
i |
Set to -300000, -3600000, 1, 7, or 30 for real-time, hourly, daily, weekly, and monthly counts, respectively. Defaults to 1. Real-time segmentation displays up to 2 days of data, hourly segmentation displays up to 7 days of data, and daily displays up to 365 days of data. |
s |
Optional. Segment definitions. Defaults to none. Full description. |
g |
Optional. The property to group by. Defaults to none. Full description. |
cs |
Optional. The conversion window in seconds. Defaults to 2,592,000 (30 days). Conversion windows are automatically rounded down to the nearest day in "unordered" mode. |
limit |
Optional. The number of Group By values returned Defaults to 100. The maximum is 1000. |
The response includes an array with one element per group. Each element has these fields:
Attribute |
Description |
---|---|
meta |
An array of labels with one for each segment. segmentIndex This represents the index of the segment, referring to its position in the right module of the chart control panel. |
stepTransTimeDistribution |
The histogram data of each step for how long it took users to convert through that step |
stepPrevStepCountDistribution |
The histogram data for each step for how many times users performed the previous step. |
bins |
Data for one histogram bucket. start and end are the start/end of the histogram bin, the data in bin_dist is the users/count/propsum for that histogram bin. |
dayMedianTransTimes |
Median transition times by day between steps. |
series |
An array with one element for each group, where each element is itself an array that includes the median transition time between steps in milliseconds on each of the days specified in "xValues". xValues: An array of (string) dates in the form "YYYY-MM-DD", one for each date in the specified range. formattedXValues: An array of (string) dates in the form of "Month DD", one for each date in the specified range. |
dayAvgTransTimes |
Average transition times by day between steps. series An array with one element for each group, where each element is itself an array that includes the average transition time between steps in milliseconds on each of the intervals specified in "xValues". xValues An array of (string) dates in the form "YYYY-MM-DD", one for each date in the specified range. formattedXValues An array of (string) dates in the form of "Month DD", one for each date in the specified range. |
stepByStep |
An array with one element for each step of the funnel, indicating the fraction of users from the previous step who completed that step. |
medianTransTimes |
An array with one element for each step of the funnel, indicating the median transition time between steps in milliseconds. |
cumulative |
An array with one element for each step of the funnel, indicating the fraction of the total users who completed that step. |
cumulativeRaw |
An array with one element for each step of the funnel, indicating the number of users who completed that step. |
avgTransTimes |
An array with one element for each step of the funnel, indicating the average transition time between steps in milliseconds. |
dayFunnels |
Represents the number of users who completed each step of the funnel by day. series An array with one element for each group, where each element is itself an array that includes the number of users who have completed that step in the funnel on each of the intervals specified in "xValues." xValues An array of (string) dates in the form of "YYYY-MM-DD", one for each date in the specified range. formattedXValues An array of (string) dates in the form of "Month DD", one for each date in the specified range |
events |
Labels for each event in the funnel |
1{ 2 "data": [ 3 { 4 "meta": {"segmentIndex": 0}, 5 "dayMedianTransTimes": { 6 "series": [ 7 [0, 165548, 264380], [0, 164767, 269444] 8 ], 9 "xValues": ["2017-08-14", "2017-08-15"],10 "formattedXValues": ["Aug 14", "Aug 15"]11 },12 "dayAvgTransTimes": {13 "series": [14 [0, 2294365, 5730478], [0, 2268879, 5700436]15 ],16 "xValues": ["2017-08-14", "2017-08-15"],17 "formattedXValues": ["Aug 14", "Aug 15"]18 },19 "stepByStep": [1.0, 0.9915120144246691, 0.9741139357951383],20 "medianTransTimes": [0, 166444, 270194],21 "cumulative": [1.0, 0.9915120144246691, 0.9658456707593803],22 "cumulativeRaw": [163054, 161670, 157485],23 "avgTransTimes": [0, 2175406, 5607243],24 "dayFunnels": {25 "series": [26 [125259, 123716, 118636], [126964, 125373, 119986]27 ],28 "xValues": ["2017-08-14", "2017-08-15"],29 "formattedXValues": ["Aug 14", "Aug 15"]30 },31 "events": ["Search Song or Video", "Select Song or Video", "Play Song or Video"]32 }33 ]34}
Get user retention for specific starting and returning actions.
GET https://amplitude.com/api/2/retention
1curl --location --request GET 'https://amplitude.com/api/2/retention?se={"event_type":"STARTEVENT"}&re={"event_type":"RETURNEVENT"}&start=STARTDATE&end=ENDDATE' \2-u '{api_key}:{secret_key}'
1GET /api/2/retention?se={"event_type":"_active"}&re={"event_type":"EVENT"}&start=STARTDATE&end=ENDDATE2HTTP/1.13Host: amplitude.com4Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Example: Get unbounded retention for active event with another event return for a period
Example: Get weekly N-day retention for active event with another event return for a period
Example:
Parameter | Description |
---|---|
se |
Required. Full event for the start action. Supports two event_type values: _new for new users, and _active for all users. |
re |
Required. Full event for the returning action. Supports one event_type value: _all for all events and _active for all active events. |
start |
Required. First date included in data series, formatted YYYYMMDD. For example, "20221001". |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example, "20221001". |
rm |
Optional. The retention type: bracket, rolling, or n-day. Note that rolling implies unbounded retention. Defaults to n-day, no need to call it explicitly. |
rb |
Optional, but required if rm is set to bracket. The days within each bracket, formatted [[0,4]]. For example, if your bracket was Day 0 - Day 4, the parameter value would be [[0,5]]. |
i |
Optional. Either 1, 7, or 30 for daily, weekly, and monthly counts, respectively. Defaults to 1. |
s |
Optional. Segment definitions. Defaults to none. Full description. |
g |
Optional. Limit: one. The property to group by. Defaults to none. Full description. |
Attribute |
Description |
---|---|
series |
A JSON object containing two keys. dates - An array of formatted string dates, one for each date in the specified range (in descending order). values - A JSON object with one key for each date, where each value is an array whose n-th element corresponds to the retention for n intervals (days, weeks, or months depending on i) out. This is by each interval. |
count |
The number of users retained in that interval. |
outof |
The total number of users in the cohort (users who performed the starting action on the date), respectively. |
incomplete |
Whether users in that date have had enough time to be retained. |
combined |
A JSON object where each value is an array whose n-th element corresponds to the retention for n intervals (days, weeks, or months depending on i) out. This object is the deduplicated aggregate of all date cohorts from the values JSON object. |
seriesMeta |
An array of labels with one for each segment. |
segmentIndex |
This represents the index of the segment, referring to its position in the right module of the chart control panel. |
eventIndex |
This represents the index of the event, referring to which event if you have many return events selected in the left module. |
1{ 2 "data": { 3 "series": [ 4 { 5 "dates": ["Aug 15", "Aug 14"], 6 "values": { 7 "Aug 14": [ 8 {"count": 12864, "outof": 12864, "incomplete": false}, {"count": 9061, "outof": 12864, "incomplete": false}, ..., {"count": 1561, "outof": 12864, "incomplete": true} 9 ],10 "Aug 15": [11 {"count": 14720, "outof": 14720, "incomplete": false}, {"count": 10249, "outof": 14720, "incomplete": false}, ..., {"count": 1773, "outof": 14720, "incomplete": true}12 ],13 },14 "combined": [15 {"count": 27584, "outof": 27584, "retainedSetId": null, "incomplete": false},16 {"count": 19310, "outof": 27584, "retainedSetId": null, "incomplete": false},17 ...18 {"count": 1561, "outof": 12864, "retainedSetId": null, "incomplete": true}19 ]20 },21 "seriesMeta": [22 {"segmentIndex": 0, "eventIndex": 0}23 ]24 ]25 }26}
Get a user summary and their most (or least) recent events. Exceeding the request limits results in 429 errors.
GET https://amplitude.com/api/2/useractivity
1curl --location --request GET 'https://amplitude.com/api/2/useractivity?user={amplitude_id}'2-u '{api_key}:{secret_key}'
1GET /api/2/useractivity?user=247246881751 HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Example: Get events for user with ID 123
Example: Get most recent two events for user with ID 123
1
to return the two most recent events.
Name | Description |
---|---|
user |
Required. Amplitude ID of the user. |
offset |
Optional. Zero-indexed (from most recent event) offset to start returning events from. |
limit |
Optional. Number of events to return (up to 1000). Note that more events may be returned so that there are no partial sessions. Defaults to 1000. |
direction |
Optional. "earliest" to include the user's earliest event or "latest" to includes the most recent. Defaults to "latest". |
The response is a JSON object with this schema:
Attribute | Description |
---|---|
events |
An array of JSON objects, one for each event performed by the user. |
userData |
Total statistics about the user and their user properties. |
1{ 2 "userData": { 3 "user_id": "myusername", 4 "canonical_amplitude_id": 12345, 5 "merged_amplitude_ids": [11111, 22222], 6 "num_events": 142, 7 "num_sessions": 23, 8 "usage_time": 2570259, 9 "first_used": "2015-03-14",10 "last_used": "2015-04-22",11 "purchases": 2,12 "revenue": 9.98,13 "platform": "iOS",14 "os": "ios 8.2",15 "version": "3.4.9",16 "device": "Apple iPhone",17 "device_type": "Apple iPhone 6",18 "carrier": "AT&T",19 "country": "United States",20 "region": "California",21 "city": "San Francisco",22 "dma": "San Francisco-Oakland-San Jose, CA",23 "language": "English",24 "start_version": "1.2.3",25 "device_ids": ["some-device", "some-other-device"],26 "last_location": {27 "lat": 37.133,28 "lng": -122.24129 },30 "properties": {31 "gender": "female"32 }33 },34 "events": [...]35}
Search for a user with a specified Amplitude ID, device ID, user ID, or user ID prefix. Exceeding the request limits results in 429 errors.
GET https://amplitude.com/api/2/usersearch
1curl --location --request GET 'https://amplitude.com/api/2/usersearch?user=USER_ID' \2-u '{api-key}:{secret-key}'
1GET /api/2/usersearch?user=user_id HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Example: Search for user by device ID
0786zXEdyOX1rS3M-P_m1d
.
Example: Search for user by Amplitude ID
356893043036
.
Name | Description |
---|---|
user |
Required. Amplitude ID, Device ID, User ID, or User ID prefix. |
Attribute | Description |
---|---|
matches |
An array of JSON objects, one for each matching user containing their Amplitude ID and User ID. |
type |
Which match type (Amplitude ID, Device ID, User ID, User ID prefix) yielded the result. |
1{2 "matches": [3 {4 "user_id": "myusername",5 "amplitude_id": 123456 }7 ],8 "type": "match_user_or_device_id"9}
If there are no matches, the response returns a 200 response with the following body:
1{2 "type": "nomatch",3 "matches": []4}
Get active user numbers with 5-minute granularity for the last two days.
GET https://amplitude.com/api/2/realtime
1curl --location --request GET 'https://amplitude.com/api/2/realtime' \2-u '{api-key}:{secret-key}'
1GET /api/2/realtime?i=5 HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Returns a JSON object with this schema:
Attribute |
Description |
---|---|
xValues |
An array of (string) times in the form "HH:mm", one for each time interval in a day starting from the current time. |
seriesLabels |
An array of two labels: "Today" and "Yesterday". |
series |
An array with one element for each group, in the same order as "seriesLabels", where each element is itself an array that includes the value of the metric on each of the days specified in "xValues". |
1{ 2 "data": { 3 "xValues": ["15:00", "15:05", "15:10", ... ], 4 "seriesLabels": ["Today", "Yesterday"], 5 "series": [ 6 [123, 144, 101, ...], 7 [139, 111, 180, ...] 8 ] 9 }10}
Get the lifetime value of new users.
GET https://amplitude.com/api/2/revenue/ltv
Learn more about the Revenue LTV chart.
1curl --location --request GET 'https://amplitude.com/api/2/revenue/ltv?start=&end=' \2-u '{api-key}:{secret-key}'
1GET /api/2/revenue/ltv?start=STARTDATE&end=ENDDATE HTTP/1.12Host: amplitude.com3Authorization: Basic {api-key}:{secret-key} #credentials must be base64 encoded
Example: LTV aggregated weekly
Example: LTV aggregated monthly for new paying users
Parameter | Description |
---|---|
m |
Optional. One of the following metrics: 0 = average revenue per user (ARPU), 1 = average realized revenue per user (ARPPU), 2 = Total Revenue, 3 = Paying Users. Defaults to 0. |
start |
Required. First date included in data series, formatted YYYYMMDD. For example, "20221001". |
end |
Required. Last date included in data series, formatted YYYYMMDD. For example, "20221001". |
i |
Optional. Either 1, 7, or 30 for daily, weekly, and monthly counts, respectively. Defaults to 1. |
s |
Optional. Segment definitions. Defaults to none. Full description. |
g |
Optional. Limit: one. The property to group by. Defaults to none. Full description. |
Returns a response containing JSON objects with this schema:
Attribute |
Description |
---|---|
seriesLabels |
An array of labels, one for each group. |
series |
A JSON object containing two keys. dates - An array of formatted string dates, one for each date in the specified range (in descending order). values - A JSON object with one key for each date, where each value is a JSON object with keys r1d , r2d , ..., r90d for the n-day metric values, and the keys count , paid , and total_amount , which indicate the total number of users, number of paid users, and amount paid by the users for the group. |
1{ 2 "data": { 3 "seriesLabels": [""], 4 "series": [ 5 { 6 "dates": ["2021-10-04", "2021-10-03", "2021-10-02", "2021-10-01"], 7 "values": { 8 "2014-10-01": { 9 "r1d": 9.99,10 "r2d": 19.98,11 ...12 "r90d": 742.52,13 "count": 110,14 "paid": 37,15 "total_amount": 781.3916 },17 ...18 }19 }20 ]21 }22}
Thanks for your feedback!
May 21st, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.