Monetization Stats API

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.

Important: Mediation partners need a Unity API key in order to gather accurate reporting for the Unity Ads network. If you already use the deprecated Applifier Statistics API in your mediated integration, consult your mediation partner before migrating to the Monetization Statistics API. Note that you can still use the Monetization Statistics API to ping Unity's network for reporting data directly. All unmediated customers can safely migrate to the new API.

Authentication

Note: The Monetization Stats API requires your Organization ID, and that ID will be changed when transferring a project.

Note: Transferring a project changes the Organization ID, which is required for accessing the Monetization Statistics API.

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.

Note: The Monetization Statistics API generates a unique key for each user. For mediation integration purposes, any individual's key will work for the entire Organization.

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?
apikeyThe API authentication key retrieved from the Monetization dashboard.No. Use the Authentication header instead.
fields

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

  • adrequest_count

  • start_count

  • view_count

  • available_sum

  • revenue_sum

Yes
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)

No
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

Yes
startThe start time of data set, in ISO 8601 format.Yes
endThe end time of data set, in ISO 8601 format.Yes
gameIds

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

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

No

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

Note: Splitting data across multiple dimensions causes the CSV to grow exponentially, which might cause some large data sets to time-out. The request times out if the server takes more than 60 seconds to process the request.

Request status codes

The endpoint returns the following status codes indicating the result of the request:

CodeDescription

200

The request succeeded.
400The organizationId, or another required parameter was omitted from the query.
401The API key is missing from the request or invalid.
404Organization not found.
408The request timed out.
429Request rate limit exceeded.
500The request failed for an unknown reason.
503The service is unavailable.