Use the Monetization Stats API to retrieve monetization data directly in CSV format. The API fetches the same statistics that are available on the developer dashboard, however you can use it to programmatically pull data for your own uses.
Authentication
The endpoint uses an API key from the Unity Ads Monetization dashboard. Select Setup > API Access from the secondary navigation menu, then copy the API key from the Monetization Stats API Access section, or select Create API Key if none exists.
You must include the API key as the "apikey=<token>"
query parameter, or using the authentication header "Authorization: Token <token>"
. The redirect URL fetches the data. This is standard HTTP behavior that is supported by all HTTP clients.
If the authentication fails, the authentication server responds with an HTTP/2 error code, and a message in the body. For example:
400 {"errors":[{"msg":"access token required"}]}
Request Format
To retrieve statistics data from the Unity Ads service, use the following GET request, where <organizationId>
is the Organization core ID of your Unity Organization:
GET https://monetization.api.unity.com/stats/v1/operate/organizations/<organizationId>
Query parameters
The API supports various ways to split your data. Some are required for a successful request.
Parameter | Description | Required? | Notes |
---|---|---|---|
| The API authentication key retrieved from the Monetization dashboard. | No. Use the Authentication header instead. | Not applicable. |
| A comma-separated list that defines the columns of available fields:
| Yes | Not applicable. |
| A comma-separated list that expands the rows, splitting data by the following fields:
| No | Not applicable. |
| A value that splits data by time resolution. Each day splits at 00:00 UTC. Supported options include:
| Yes | Not applicable. |
| The start time of data set, in ISO 8601 format. | Yes | Not applicable. |
| The end time of data set, in ISO 8601 format. | Yes | Not applicable. |
| A comma-separated list of source game IDs by which to filter results. | No | To obtain source IDs, you can make a request using |
This API supports returning CSV or JSON files. Specify the output format in the "Accept"
header as follows:
- For CSV, use
"Accept: text/csv"
. - For JSON, use
"Accept: application/json"
.
Following is an example request, using real parameters (with the exception of placeholder Organization core ID and API key):
curl https://monetization.api.unity.com/stats/v1/operate/organizations/:organizationId?groupBy=country,placement,platform,game&fields=adrequest_count,available_sum,revenue_sum,start_count,view_count&scale=hour&start=2020-05-01T00:00:00Z&end=2020-06-01T23:59:00Z&apikey=:apiKeyValue -H "Accept: text/csv" --output stats.csv
Request status codes
The endpoint returns the following status codes indicating the result of the request:
Code | Description |
---|---|
| The request succeeded. |
| The |
| The API key is missing from the request or invalid. |
| Organization not found. |
| The request timed out. |
| Request rate limit exceeded. |
| The request failed for an unknown reason. |
| The service is unavailable. |