The RevenueMetrics API allows you to retrieve performance data for websites and ad units over a specific date range. This data includes key metrics such as revenue, impressions, clicks, and other performance indicators, providing actionable insights for optimizing ad performance.
Access to the API requires an API key. This key can be obtained in the Universal Developer Portal. Once obtained, the key must be included in the HTTP request header under the field x-api-key.
Auth Type: API Key
Header Name: x-api-key
Usage Example:
x-api-key: YOUR_API_KEY
Replace the string YOUR_API_KEY in the code with your actual API key
Request Parameters
Parameter
Type
Required
Description
dateFrom
string
✅ Yes
Start date (format: YYYY-MM-DD HH:MM:SS)
dateTo
string
✅ Yes
End date (format: YYYY-MM-DD HH:MM:SS)
GraphQL Query Example
The following GraphQL query retrieves performance metrics for websites and ad units within a specified date range.
Below are practical examples of how to send requests to the Revenue Metrics API using various popular programming languages, such as Node.js, Python, and C#. These examples demonstrate how to structure your requests, authenticate using an API key, and handle responses effectively.
Below is a table summarizing key fields returned in the API responses. This will help you interpret and use the data effectively in your application.
Field
Type
Description
total
number
Total item returned
siteId
integer
Unique identifier for the site
siteName
string
Name of the site
adunitId
integer
Unique identifier for the ad unit
adunitName
string
Name of the ad unit
impressions
integer
Total ad impressions
clicks
integer
Total ad clicks
revenue
number
Total revenue generated
ecpm
number
Effective cost per mille
arpdau
number
Average revenue per daily active user
dau
integer
Daily active users
Error Response Examples
When interacting with the API, you may encounter errors if the request is not properly formatted or authorized. This section highlights common issues, their causes, and how to resolve them. Below are examples of typical error responses and what they indicate.
1. Invalid Date Range:
{"errors": [ {"message": "Property DateFrom must be earlier than or equal to DateTo. Please correct the date range.","locations": [ {"line": 2,"column": 5 } ],"path": ["revenueMetrics" ] } ],"data": {"revenueMetrics": null }}
2. Syntax or Time Range Error:
{"errors": [ {"message": "Property DateTo should be in the format yyyy-MM-dd HH:mm:ss. Please correct it.","locations": [ {"line": 2,"column": 5 } ],"path": ["revenueMetrics" ] } ],"data": {"revenueMetrics": null }}
3. Invalid API Key:
{"errors": [ {"message": "The current user is not authorized to access this resource.","locations": [ {"line": 2,"column": 5 } ],"path": ["revenueMetrics" ],"extensions": {"code": "AUTH_NOT_AUTHORIZED" } } ],"data": {"revenueMetrics": null }}