Monetization Stats API

Read time 9 minutes

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.

ParameterDescriptionRequired?Notes

apikey

The API authentication key retrieved from the Monetization dashboard.No. Use the Authentication header instead.Not applicable.

fields

A comma-separated list that defines the columns of available fields:

  • adrequest_count
  • start_count
  • view_count
  • available_sum
  • revenue_sum
YesNot applicable.

groupBy

A comma-separated list that expands the rows, splitting data by the following fields:

  • placement (splits data by Ad Unit ID)
  • country
  • platform
  • game (game ID)
NoNot applicable.

scale

A value that splits data by time resolution. Each day splits at 00:00 UTC. Supported options include:

  • hour
  • day
  • week
  • month
  • year
  • all
YesNot applicable.

start

The start time of data set, in ISO 8601 format.

YesNot applicable.

end

The end time of data set, in ISO 8601 format.

YesNot applicable.

gameIds

A comma-separated list of source game IDs by which to filter results.

No

To obtain source IDs, you can make a request using groupBy=game.

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:

CodeDescription

200

The request succeeded.

400

The organizationId, or another required parameter was omitted from the query.

401

The API key is missing from the request or invalid.

404

Organization not found.

408

The request timed out.

429

Request rate limit exceeded.

500

The request failed for an unknown reason.

503

The service is unavailable.