Introduction
Welcome to the NextMillennium Reporting API. The methods below will allow you to query reporting data.
Authentication
An example of using token for authentication:
curl "https://pp2-api.nextmillennium.io/api/public/..." \
-H "Authorization: Bearer <token>"
const response = await fetch("https://pp2-api.nextmillennium.io/api/public/...", {
headers: {
"Authorization": `Bearer ${<token>}`
}
})
Make sure to replace
<token>
with your personal API key.
Our API uses tokens for managing access to its endpoints. The token should be included as a Bearer
authorization header in each request.
You can obtain token by contacting your account manager.
Reporting
Dimensions and Metrics
Core Dimensions:
Dimension | Description |
---|---|
date |
The date for which data is requested. |
site |
The specific site associated with the data. |
placement |
Refers to the placement associated with the site. |
Additional Dimensions (Choose One):
Dimension | Description |
---|---|
deviceCategory |
Describes the type of device used by users to view the ad (e.g., desktop, mobile, tablet). |
country |
Represents the geographical location of the user who has viewed the ad. |
size |
Specifies the dimensions of the placement displayed, offering insights into the visual presentation of the ad. |
browser |
Indicates the web browser used by users to view the ad. |
referrerCategory |
Identifies the origin of the web traffic leading to ad views. |
Metrics:
Metric | Description |
---|---|
adRequests |
The number of requests made for displaying ads. |
adOpportunities |
The number of chances for an ad to be displayed. |
adImpressions |
The actual number of times an ad is displayed. |
revenue |
The generated revenue from ad impressions. |
eCPM (Estimated Cost Per Mille) |
The estimated earnings per thousand impressions. |
Using Metrics with Dimensions:
- Users can call any combination of the core dimensions (
date
,site
, andplacement
) along with one additional dimension. - Metrics can be applied to the specified dimensions to gain insights into ad performance and revenue generation.
- Example API Request: Retrieve
adImpressions
andrevenue
for a specificsite
on a particulardate
with the additional dimension ofcountry
.
Campaign Type Limitations
For Standard NM Campaigns (isDirectCampaign: false
or not present in request body)
- Users can call any combination of core dimensions along with one additional dimension.
- Metrics like
adRequests
,adOpportunities
,adImpressions
,revenue
, andeCPM
are available.
For Direct Campaigns (isDirectCampaign: true
)
browser
andreferrerCategory
(Traffic Source) dimensions are not accessible due to system limitations.adRequests
andadOpportunities
metrics are not accessible due to system limitations.- On top of the available
adImpressions
,revenue
andeCPM
you can use additional metrics for Direct Campaigns:
Metric | Description |
---|---|
viewabilityDirect |
The percentage of ads that were actually seen by users. |
ctr (Click-Through Rate) |
The ratio of ad clicks to impressions, indicating user engagement. |
For additional info use Fields method
Query Reports
curl --request POST 'https://pp2-api.nextmillennium.io/api/public/reports/query' \
--header 'Content-Type: application/json' \
--data-raw '{
"from": "2024-01-01",
"to": "2024-01-01",
"dimensions": [
"date"
],
"metrics": [
"revenue"
]
}'
const response = await fetch("https://pp2-api.nextmillennium.io/api/public/reports/query", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
from: "2024-01-01",
to: "2024-01-01",
dimensions: [
"date"
],
metrics: [
"revenue"
]
})
})
The above request returns the following JSON response:
{
"data": [
{
"date": "2024-01-01",
"revenue": 100
}
],
"total": 1
}
This endpoint allows you to query reports. That includes grouping, filtering and sorting.
HTTP Request
POST https://pp2-api.nextmillennium.io/api/public/reports/query
Body Parameters
Parameter | Is Required? | Type | Description |
---|---|---|---|
from |
true |
string |
Start of the reporting period. Should be a valid ISO 8601 date. |
to |
true |
string |
End of the reporting period. Should be a valid ISO 8601 date. Should be less or equal than "from" |
dimensions |
true |
string[] |
List of dimensions to be used for grouping. Can be empty. For the list of all available dimensions see Fields method. |
metrics |
true |
string[] |
List of metrics that should be included in the response. At least one metric must be specified. For the list of all available metrics see Fields method. |
filters |
false |
object[] |
List of filters that can be applied to the report. Filter is done by using IN and NOT IN operations on dimensions. For a detailed description see the Filtering section. |
order |
false |
object[] |
List of order clauses. For a detailed description see the Ordering and Pagination section. |
limit |
false |
number |
Specifies how many rows the response will contain. The result is not determined without the "order" field. |
offset |
false |
number |
Specifies how many rows the report skips. Result is not determined without the "order" field. |
isDirectCampaign |
false |
boolean |
A flag that allows you to filter data by its source. When set to true it will only return reports that result in campaigns created on the "Campaigns" tab in the "Ad Management" menu section in the UI. |
Response Format
If everything is okay you will receive the next response:
{
"data": [],
"total": 0
}
In case of error the response will have the following format:
{
"error": {
"message": ""
}
}
The response body contains only two fields:
- data - requested report
- total - the total number of rows in the report. Usually used to calculate the number of pages with the selected limit
Filtering
Example of a filter
curl --request POST 'https://pp2-api.nextmillennium.io/api/public/reports/query' \
--header 'Content-Type: application/json' \
--data-raw '{
"from": "2024-01-01",
"to": "2024-01-01",
"dimensions": [
"placement"
],
"metrics": [
"revenue"
],
"filters": [
{
"dimension": "placement",
"operation": "in",
"value": [
"placement_gunstar"
]
}
]
}'
const response = await fetch("https://pp2-api.nextmillennium.io/api/public/reports/query", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
from: "2024-01-01",
to: "2024-01-01",
dimensions: [
"placement"
],
metrics: [
"revenue"
],
filters: [
{
dimension: "placement",
operation: "in",
value: [
"placement_gunstar"
]
}
]
})
})
Filters field is an array of objects describing logical statements. All elements of the array are concatenated using AND
operator. The fields of a filter object are:
- dimension - identifier of dimension to which we need to apply the filter;
- operation - optional identifier of the filtering operation. Possible values are
"in"
and"not_in"
. All filters are consideredIN
filters by default; - value - an array of string values to filter by.
Filtering is only available for the requested dimensions
Ordering and Pagination
Using the following code you can query the third page with of the report ordered by revenue with a page size equal to 10
curl --request POST 'https://pp2-api.nextmillennium.io/api/public/reports/query' \
--header 'Content-Type: application/json' \
--data-raw '{
"from": "2024-01-01",
"to": "2024-01-01",
"dimensions": [
"placement"
],
"metrics": [
"revenue"
],
"order": [
{
"by": "revenue",
"direction": "desc"
}
],
"limit": 10,
"offset": 20
}'
const response = await fetch("https://pp2-api.nextmillennium.io/api/public/reports/query", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
from: "2024-01-01",
to: "2024-01-01",
dimensions: [
"placement"
],
metrics: [
"revenue"
],
order: [
{
by: "revenue",
direction: "desc"
}
],
limit: 10,
offset: 20
})
})
You can define a list of order statements to format reports. Ordering object contains two fields
- by - identifier of a dimension or a metric
- direction - identifier of the ordering direction. Available values are
"asc"
and"desc"
. This field has no default value
Statements will be applied in the same order they appear in the array.
By using the "limit"
and "offset"
fields you can either establish a pagination logic (use a consistent ordering; "limit"
will be your page size and "offset"
will help you to change the pages) or limit expected output. Note that you cannot use "offset"
without a "limit"
.
List Available Fields
The following API method provides users with a comprehensive list of available dimensions and metrics. It's essential to note that users may have different dimensions and metrics accessible to them based on system limitations.
curl "https://pp2-api.nextmillennium.io/api/public/reports/fields"
const response = await fetch("https://pp2-api.nextmillennium.io/api/public/reports/fields")
HTTP Request
GET https://pp2-api.nextmillennium.io/api/public/reports/fields
Response Format
{
"dimensions": [
{
"id": "date",
"name": "Date",
"description": "Reporting day. Has format of an ISO 8601 date. Timezone is EST/EDT."
}
],
"metrics": [
{
"id": "revenue",
"name": "Revenue",
"description": "Net Publisher revenue in United States Dollars ($)"
}
]
}
Each object in the response body has three fields:
- id - identifier of the metric or dimension
- name - human-readable name of the metric/dimension
- description - human-readable explanation of the metric/dimension meaning
Errors
You might face the following response codes during the interaction with our API:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. A detailed description of the error is available in the "message" field |
401 | Unauthorized -- API key is either incorrect or improperly attached to request |
429 | Too Many Requests -- Request rate limit reached. Please wait a few minutes before making new requests. |
500 | Internal Server Error -- Unregistered error in the server. If this happens more than once feel free to reach out to support. |