我们建议您先阅读《Singular Reporting API 入门》 ,以熟悉 API 背后的概念,并找到适合您使用情况的正确查询。
另请参阅:SKAdNetwork API参考资料、广告货币化API 参考资料。
此 API 适用于 Singular 客户(广告商)。如果您是 Singular 合作伙伴,请参阅合作伙伴 报告 API。
。
一般信息
身份验证
所有 API 请求都需要一个 API 密钥。要获取密钥,请登录您的账户,进入 "开发工具">"API 密钥"。 您可以在请求中的api_key参数中插入密钥,或在授权 HTTP 标头下提供令牌。
速率限制
Singular API 的默认限制是
- 异步报告:最多同时运行 100 个异步报告。
- 同步报告:最多同时运行 3 个同步报告。
- 单个报告行数限制:每次查询最多 20 万行。
- 每日全局行数限制:单日最多 3M 行(所有查询共享)。
Singular 保留调整特定端点速率限制的权利,以便继续为所有客户提供高质量服务。如果有超出默认限制的特殊需求,请联系我们。
报告 API 端点列表
以下是可用的 API 端点:
Create Async Report | POST | https://api.singular.net/api/v2.0/create_async_report | Returns aggregated statistics. |
Data Availability | GET | https://api.singular.net/api/v2.0/data_availability_status | Before querying Create Async Report, use this endpoint to determine whether for a given day, data is available for each of your sources (data connectors). |
Get Report Status | GET | https://api.singular.net/api/v2.0/get_report_status | Returns the status of a given report. |
Filters | GET | https://api.singular.net/api/v2.0/reporting/filters | Returns all filtering options available for your reports. |
Custom Dimensions | GET | https://api.singular.net/api/custom_dimensions | Returns all the custom dimensions available for your reports. |
Cohort Metrics | GET | https://api.singular.net/api/cohort_metrics | Returns all the cohort metrics and cohort periods available for your reports. |
Conversion Metrics | GET | https://api.singular.net/api/conversion_metrics | Returns all the conversion metrics available for your reports. |
创建异步报告端点
POST | https://api.singular.net/api/v2.0/create_async_report |
使用方法
这是从 Singular 获取报告数据的主要端点。该端点根据你指定的报告维度、指标、日期和其他细节生成异步报告查询,并返回报告 ID。下一步是查询 "获取报告状态"(Get Report Status)端点,以查看报告何时完成并获取下载 URL。
要了解更多信息,请参阅《奇异报告 API 指南》中的 "查询过程"部分。
限制
- 单日 API 请求对返回的行数没有限制。
- 单个请求最多可查询 30 天,最多可查询 100,000 条记录。查询超过 100,000 条记录的请求将不会成功,并需要额外过滤。
- 在与我们的应用程序接口集成以获取每日或每周数据时,我们通常建议将多日查询拆分为单日查询,并在整个时间段内进行迭代。
查询示例
import requests
url = "https://api.singular.net/api/v2.0/create_async_report"
query_params = {"api_key": "<API KEY>"}
payload = {
"dimensions":"app,source,os,country_field",
"metrics": "custom_impressions,custom_clicks,custom_installs",
"start_date":"2020-01-01",
"end_date": "2020-01-01",
"time_breakdown": "all",
"format": "csv",
"country_code_format": "iso"
}
response = requests.post(url=url, params=query_params, data=payload)
print(response.text)
查询参数
参数 | 格式 | 说明 | 示例 |
Basic Parameters | |||
api_key | String | API key provided in the Singular console | |
start_date | Date | ||
end_date | Date | ||
time_breakdown | String | Results breakdown by 'day', 'week', 'month' or 'all', which aggregated data over the entire time period | |
Field Selection Parameters | |||
dimensions | String | A comma-separated list of dimensions. See API Report Types for the list of dimensions available based on the type of data you are looking for. See Metrics and Dimensions for more information about each dimension. | |
metrics | String | A comma-separated list of metrics. See API Report Types for the list of metrics available based on the type of data you are looking for. See Metrics and Dimensions for more information about each metric. | |
cohort_metrics | String | A comma-separated list of cohort metrics by name (see What are cohort metrics?). Cohort metrics include any post-conversion events you have defined in the Events page. To retrieve a list of all the available cohort metrics in your account, use the Cohort Metrics endpoint. | 'cohort_metrics': '815782610a1ddf,revenue' |
cohort_periods | String | A comma-separated list of cohort periods (see What are cohort metrics?). To retrieve a list of the available cohort periods, use the Cohort Metrics endpoint. | 'cohort_periods': '7d,14d,ltv' |
Filtering Parameters | |||
app | String | A comma-separated list of app names to filter the query results by. To retrieve a list of app names, use the Filters endpoint. | 'app': 'my_app1,my_app2' |
Source | String | A comma-separated list of ad networks (and other sources) to filter by. To retrieve a list of ad network names, use the Filters endpoint. | 'source': 'facebook,adwords' |
filters | JSON | A JSON list of filter objects where each contains a dimension, operator, and value(s). Use this parameter to apply more advanced filtering. Note that if you specify more than one filter they will be applied with an AND relation. To retrieve a full list of dimensions you can filter by and their potential values, use the Filters endpoint. | 'filters': '[{"dimension": "os", "operator": "in","values": [1, 4]}, {"dimension": "source", "operator": "not in", "values": ["adwords"]}]' |
Formatting Parameters | |||
format | String | The format in which the query results will be delivered. Options: "json" (default) or "csv". | 'format':'csv' |
country_code_format | String | Either "iso3" (default) or "iso" | |
display_alignment | Boolean |
When set to "true", results will include an alignment row to account for any difference between campaign and creative statistics. |
|
display_unenriched |
Boolean |
When set to "true", results will contain the unenriched data. |
"display_unenriched":true |
输出示例
{
"status": 0,
"substatus": 0,
"value": {
"report_id": "5cfdb747dd464cd09a9c463e5be9691f"
}
}
可用维度和度量
有关每个字段的说明,请参阅 "度量标准和维度术语表"。
网络数据
app
source
adn_campaign_id
adn_campaign_name
adn_campaign_url
data_connector_id
data_connector_source_name
data_connector_username
data_connector_timestamp_utc
可选的附加尺寸(支持情况因网络而异):
os
platform
country_field
region_field
city_field
dma_id_field
dma_name_field
adn_sub_adnetwork_name
adn_account_id
adn_account_name
adn_sub_campaign_id
adn_sub_campaign_name
关键词和/或出版商细分(支持因网络而异,不能与创意细分在同一查询中提取):
keyword_id
keyword
publisher_id
publisher_site_id
publisher_site_name
创意明细(支持情况因网络而异,通常不能与关键字/出版商在同一查询中提取):
creative_type
adn_creative_id
adn_creative_name
creative_url
creative_image
creative_text
creative_width
creative_height
creative_is_video
asset_id
asset_name
活动属性(了解更多信息):
bid_type
bid_strategy
bid_amount
campaign_objective
standardized_bid_type
standardized_bid_strategy
original_bid_amount
campaign_status
min_roas
original_metadata_currency
自定义维度:
如果您已根据这些默认网络维度定义了自定义维度,则可以使用其 ID 调用它们。使用自定义维度端点可获取账户中定义的所有自定义维度及其 ID。
adn_cost
adn_original_cost
adn_original_currency
adn_impressions
adn_clicks
adn_installs
自定义指标:
如果贵组织使用特殊的自定义指标(由 Singular Support 为您创建),API 中的指标名称将使用小写字母,空格用下划线代替。例如:网络平台中的自定义指标 1 = API 中的custom_metric_1 。
跟踪器数据
tracker_impressions
tracker_clicks
tracker_installs
tracker_conversions
tracker_reengagements
daily_active_users
队列指标
revenue
original_revenue
有关可使用的队列指标的完整列表,请参阅队列指标端点。 有关更多信息,请参阅什么是队列指标?
请注意,队列度量包括基于比率的计算,如 CPE 和 CPI。我们不建议在 API 报告中使用这些指标(了解更多信息)。
事件:
您可以提取您定义的任何事件的统计数据。请注意,您必须使用事件自动生成的 ID,而不是使用 Singular 应用程序中定义的事件名称,您可以从队列指标端点获取该 ID。
自定义指标:
如果您的组织使用特殊的自定义度量(由 Singular 支持部门为您创建),API 中的度量名称将使用小写,空格用下划线代替。例如:网络平台中的自定义指标 1 = API 中的 custom_metric_1。
组合数据
app
source
unified_campaign_id
unified_campaign_name
可选的附加尺寸(支持情况因网络/跟踪器而异):
os
platform
country_field
adn_sub_adnetwork_ name
adn_account_id
adn_account_name
sub_campaign_id
sub_campaign_name
关键词和/或出版商细分(支持程度因网络/跟踪器而异,不能与创意细分在同一查询中提取):
keyword_id
keyword
publisher_id
publisher_site_id
publisher_site_name
创意细分(支持因网络而异,仅适用于 Singular 归因服务用户):
creative_type
adn_creative_id
adn_creative_name
creative_url
creative_image
creative_text
creative_width
creative_height
creative_is_video
asset_id
asset_name
自定义维度:
如果您在这些默认维度的基础上定义了自定义维度,您可以使用它们的 ID 将其提取出来。 使用自定义维度端点可获取您账户中定义的所有自定义维度及其 ID。
adn_cost
adn_original_cost
adn_original_currency
custom_impressions
custom_clicks
custom_installs
tracker_conversions
tracker_reengagements
daily_active_users
视频创意和视频营销活动的衡量标准:
video_views
video_views_25pct
video_views_50pct
video_views_75pct
completed_video_views
completed_video_view_rate
群组指标:
revenue
original_revenue
有关可使用的队列指标的完整列表,请参阅队列指标端点。 有关更多信息,请参阅什么是队列指标?
请注意,队列度量包括基于比率的计算,如 CPE 和 CPI。我们不建议在 API 报告中使用这些指标(了解更多信息)。
事件:
您可以提取您定义的任何事件的统计数据。请注意,您必须使用事件自动生成的 ID,而不是使用 Singular 应用程序中定义的事件名称,您可以从队列指标端点获取该 ID。
自定义指标:
如果您的组织使用特殊的自定义度量(由 Singular 支持部门为您创建),API 中的度量名称将使用小写,空格用下划线代替。例如:网络平台中的自定义指标 1 = API 中的 custom_metric_1。
备注:
数据可用性端点
GET | https://api.singular.net/api/v2.0/data_availability_status |
使用情况
该端点返回在给定日期内,每个数据源或数据连接器的数据是否可用。
我们建议在运行每日报告前使用该端点检查昨天的数据是否可用。
查询示例(Python)
import requests
url = "https://api.singular.net/api/v2.0/data_availability_status"
queryparams = {
"api_key":"<API_KEY>",
"expanded":"true",
"format": "json",
"data_date":"2021-02-01",
"display_non_active_sources":"true"
}
response = requests.get(url=url, params=queryparams)
查询参数
参数 | 格式 | 说明 |
api_key | String | API key provided in the Singular console. |
expanded |
Boolean | Set to "true" to get the results for each data connector including the data_connector_id field. Then when you run a report in the Create Async Report endpoint, you can filter the results by data_connector_id. Default is "false" for backward compatibility. |
format | String | Output format: "json" or "csv". |
data_date | Date | The day to check data availability for. |
display_non_active_sources | Boolean | [Optional] Set to "true" to include non-active data connectors (data connectors that haven't had data in the last 30 days) in the check. |
输出示例(当展开为 true 时)
{
"status": 0,
"substatus": 0,
"value": {
"is_all_data_available": false,
"data_connectors": [{
"data_connector_id": "dgd7934875",
"data_connector_source_name": "Vungle",
"data_connector_username": "ua@mycompany.com",
"is_active_last_30_days": true,
"is_available": true,
"is_empty_data": false,
"last_updated_utc": "2021-02-08T10:10:07",
"data_connector_timestamp_utc": "2021-02-08T10:10:07",
"status": "data populated"
}, {
"data_connector_id": "youi293478",
"data_connector_source_name": "IronSource",
"data_connector_username": "ua@mycompany.com",
"is_active_last_30_days": true,
"is_available": false,
"is_empty_data": "N/A",
"last_updated_utc": "N/A",
"data_connector_timestamp_utc": "N/A",
"status": "data not populated"
}]
}
}
输出参数
参数 | 格式 | 说明 |
is_all_data_available | Boolean | True if there is data available from all data connectors for the given date. Otherwise false. |
data_connectors |
An array containing a JSON object for each of your data connectors. | |
Parameters per Data Connector |
||
data_connector_id |
String | A unique identifier for the data connector. You can use this identifier to filter your reports in Create Async Report. |
is_available | Boolean | True if there is data from the specific data connector for the given date. |
data_connector_timestamp_utc | Timestamp | The date and time in which data was last pulled from this data connector for the given date. Use this field if you are auditing historical data and want to see if Singular has fresher data than the one you currently have in your BI platform. |
is_empty_data | Boolean | True if data was pulled successfully from the specific data connector, but the data is empty (all zeros or N/A values). False if data was pulled and contains actual values. Note that if data has not been pulled yet, this field contains "N/A". |
status | String |
Additional information about the status of the data. Possible values:
|
is_active_last_30_days | Boolean | True if this data connector had non-empty data at least once in the last 30 days. |
last_updated_utc | Timestamp | The latest time in which data was saved in the Singular database for this data connector. Note: There may be a gap of up to several hours from the moment in which the data is pulled through the data connector to the time it is saved in the database. |
输出示例(当不包含 "expanded "参数或参数设置为假时)
{'is_all_data available': false,
'data_sources': [
{'username': u'facebook@singular.net',
'status': 'data populated',
'is_empty_data': false,
'is_active_last_30_days': true,
'last_updated_utc': '2018-05-03T10:12:18'
'source': u'Facebook',
'is_available': true},
{'username': u'vungle@singular.net',
'status': 'data populated',
'is_empty_data': true,
'is_active_last_30_days': true,
'last_updated_utc': '2018-05-03T10:12:18'
'source': u'Vungle',
'is_available': true},
{'username': u'applovin@singular.net',
'status': 'data not populated',
'is_empty_data': N/A,
'is_active_last_30_days': true,
'last_updated_utc': N/A
'source': u'Applovin',
'is_available': false}
]}
输出参数
参数 | 格式 | 说明 |
is_all_data_available | Boolean | True if there is data from all data connectors for the given date. Otherwise false. |
is_available | Boolean | True if there is data from the specific data connector for the given date. Otherwise false. |
is_empty_data | Boolean | True if data was pulled successfully from the specific source, but the data is empty (all zeros or "N/A" values). |
status | String | Additional information about the status of the data. The possible values are:
|
is_active_last_30_days | Boolean | True if data was non-zeroes for at least one day in the last 30 days. Otherwise false. |
last_updated_utc | Timestamp | The latest time in which data was saved in the Singular database for this data connector. Note: There may be a gap of up to several hours from the moment in which the data is pulled through the data connector to the time it is saved in the database. |
获取报告状态端点
GET | https://api.singular.net/api/v2.0/get_report_status |
使用方法
此端点返回使用创建异步报告端点生成的给定报告的状态。如果报告已完成运行,端点还会返回一个下载 URL。
如果报告失败,端点会返回一条错误信息,您可以利用它来排除故障(请参阅错误代码表和API FAQ 与故障排除指南)。
要了解更多信息,请参阅《奇异报告 API 指南》中的 "查询过程"部分。
重要:
- 报告有时需要几分钟才能完成。
- 每份报告每 10 秒查询报告状态端点的次数不要超过一次。
- 设置超时。 在极少数情况下,报告可能会停留在 "已排队 "或 "已开始 "状态。如果30 分钟后状态不是 "完成 "或 "失败",我们建议再次提交报告(这将为您提供一个新的报告 ID 供查询)。
查询示例
import requests
url = "https://api.singular.net/api/v2.0/get_report_status"
querystring = {
"report_id":"5cfdb747dd45be9691f",
"api_key": "<API KEY>"
}
response = requests.get(url=url, params=querystring)
print(response.text)
查询参数
参数 | 格式 | 说明 |
api_key | String | API key provided in the Singular console |
report_id | String | A Report ID returned by the Create Async Report endpoint. |
样本输出
{
"status": 0,
"substatus": 0,
"value": {
"status": "DONE",
"url_expires_in": 3600,
"generated_url_time_in_utc": "2018-05-13T08:26:18.457690+00:00",
"url_expired_time_in_utc": "2018-05-13T09:26:18.457690+00:00",
"download_url": "https://singular-reports-results.s3.amazonaws.com/singular/xxxxxxxxx",
"report_id": "5cfdb747dd45be9691f"
}
}
输出参数
输出参数 | 格式 | 说明 |
status | String | Possible values:
|
generated_url_time_in_utc | Timestamp | |
url_expires_in | Integer | Seconds until the download URL expires. |
url_expired_time_in_utc | Timestamp | |
download_url | URL | |
report_id | String |
过滤器端点
GET | https://api.singular.net/api/v2.0/reporting/filters |
使用方法
使用此辅助端点可获取可过滤报告的维度的最新列表,以及每个维度的可能值。
查询示例
import requests
url = "https://api.singular.net/api/v2.0/reporting/filters"
params = {'api_key': "<API KEY>"}
result = requests.get(url=url, params=params)
print result.json()
查询参数
参数 | 格式 | 说明 |
api_key | String | API key provided in the Singular console |
样本输出
{
"status": 0,
"substatus": 0,
"value": {
"dimensions": [
{
"name": "os",
"display_name": "OS",
"values": [
{"name": 4, "display_name": "Android"},
{"name": 1, "display_name": "iOS"}
],
},
{
"name": "source",
"display_name": "Source",
"values": [{"name": "adwords", "display_name": "AdWords"}]
}
]
}
}
自定义维度端点
GET | https://api.singular.net/api/custom_dimensions |
使用方法
使用此端点可检索为账户配置的任何自定义维度的 ID。然后,您可以在查询创建异步报告端点时使用自定义维度 ID(代替或补充任何默认维度)。
要了解自定义维度以及如何创建它们,请参阅自定义维度常见问题。
查询示例
import requests
url = "https://api.singular.net/api/custom_dimensions"
params = {'api_key': "<API KEY>"}
result = requests.get(url=url, params=params)
print result.json()
查询参数
参数 | 格式 | 说明 |
api_key | String | API key provided in the Singular console |
样本输出
{
"status": 0,
"substatus": 0,
"value": {
"custom_dimensions": [
{"display_name": "Channel Type", "id": "e471cb6b83684532e5e83cd"},
{"display_name": "Region", "id": "1dcfdb1ad861fba4b098e2"}
]
}
}
队列度量终点
GET | https://api.singular.net/api/cohort_metrics |
使用方法
使用此端点可检索您账户的所有队列指标和队列周期。这包括您配置 Singular 跟踪的任何应用程序内事件(请参阅 "事件常见问题")。 然后,您可以在 "创建异步报告"(Create Async Report)端点中运行查询时指定这些指标和时间段。
请注意,在创建异步报告查询中,您需要使用指标的 "名称",而不是 "显示名称"。
查询示例
import requests
url = "https://api.singular.net/api/cohort_metrics"
params = {'api_key': "<API KEY>"}
result = requests.get(url=url, params=params)
print result.json()
查询参数
参数 | 格式 | 说明 |
api_key | String | API key provided in the Singular console |
样本输出
{
"status": 0,
"substatus": 0,
"value": {
"metrics": [
{"display_name": "ROI","name": "roi"},
{"display_name": "Revenue","name": "revenue"}
],
"periods": ["1d","3d","5d","7d","14d","30d","actual"]
}
}
输出参数
输出参数 | 格式 | 说明 |
display_name | String | The name of the metric as it appears in the Singular platform. |
name | String | The identifier of the metric for use in API queries. |
periods | Array | All the cohort periods supported for your account. For more information, see What are cohort metrics and cohort periods? |
转换指标端点
GET | https://api.singular.net/api/conversion_metrics |
使用方法
使用此端点可检索账户的所有可用转换事件。然后,在创建异步报告端点中运行查询时,可以将这些事件指定为度量。
请注意,在创建异步报告查询中,您需要使用度量的 "名称",而不是 "显示名称"。
查询示例
import requests
url = "https://api.singular.net/api/conversion_metrics"
params = {'api_key': "<API KEY>"}
result = requests.get(url=url, params=params)
print result.json()
查询参数
参数 | 格式 | 说明 |
api_key | String | API key provided in the Singular console |
样本输出
{
"status": 0,
"substatus": 0,
"value": {
"metrics": [
{"display_name": "5-second video view", "name": "87dfg34453hsfg6f"},
{"display_name": "5-second video view CPE", "name": "87dfg34453hsfg6fCPE"},
{"display_name": "Sign up", "name": "iuq353fidr76w846fha"},
{"display_name": "Sign up CPE", "name": "iuq353fidr76w846fhaCPE"},
{"display_name": "Post engagement", "name": "b59cje9fcgw0th"},
{"display_name": "Post engagement CPE", "name": "b59cje9fcgw0thCPE"},
]
}
}
输出参数
输出参数 | 格式 | 说明 |
display_name | String | The name of the conversion event as configured in the Events page. |
name | String | The auto-generated identifier of the event - use this identifier in your report query. |
错误代码
Singular 使用标准 HTTP 响应代码来表示 API 请求的成功或失败。一般来说,200 代码表示成功,4xx 范围内的代码表示根据所提供的信息失败的错误(例如,遗漏了一个必填参数),5xx 代码表示其他问题。
另请参阅:报告 API 常见问题和故障排除
代码 | 错误文本 | 附加信息 |
400 | An invalid timestamp was given. The timestamp must be of the format: YYYY-MM-DD hh:mm:ss. | Specify timestamps as in the following example: 2018-01-01 00:00:01 |
400 | An invalid date was given. The date must be of the format: YYYY-MM-DD. | Specify dates as in the following example: 2018-01-20 |
400 | An invalid date range was given. End date must be later than start date. | |
400 | An invalid time breakdown was given. | The time breakdown parameter is either missing in your query or isn't one of the supported options: "day", "week", "month", or "all". |
400 | An invalid filter was given. | Use the Filters endpoint to get the list of filters you can use in your queries. |
400 | At least one metric must be used. | Include at least one metric in your query. |
400 | The requested data set includes publisher dimensions and extends beyond a single day. Please run single day queries with publisher dimensions. | Reports broken down by publisher include large volumes of data. To run these reports, limit them to one day. |
400 | An invalid result format was given. Please select between JSON and CSV. | |
400 | An invalid country_code_format was given. Please use "iso3" or "iso". | |
400 | The request contains invalid dimensions: | One or more dimensions you requested in the query are either deprecated or invalid. If you used custom dimensions, double-check that they are available (using the custom dimensions endpoint) and make sure you used the dimension IDs (rather than their display names). |
400 | The request contains duplicate fields: [list] | |
400 | The request contains invalid metrics: | One or more metrics you requested in the query are either deprecated or invalid. If you used cohort metrics or conversion events, double-check that they are available (using the cohort metrics and conversion events endpoints) and make sure you used the metric names (rather than their display names). |
400 | The request contains invalid cohort periods: | Use the cohort metrics endpoints to check which cohort periods are available for your account. |
400 | We could not find cohort periods for the following cohort metrics: . | Add cohort periods for your cohort metrics. |
400 | The request contains dimensions from an old API version: . Please use dimensions from the v2 API endpoint only. | The request included dimensions from multiple API versions, which is not supported. |
400 | The request is missing the following parameter: . | |
401 | An invalid API Key was given. | The API key is either missing or invalid. To get your API key, log into your Singular account and go to Developer Tools > API Keys. |
401 | The provided API key has been previously deactivated. Please contact your administrator. | You are using an API key that belonged to a deactivated user. To get your API key, log into your Singular account and go to Developer Tools > API Keys. |
403 | The provided API key does not have permissions to view the field: |
The API key provided does not have permissions to view a dimension or metric you requested. Contact your organization's administrator to make sure you have the permissions you need. |
403 | The request is denied access. Please contact your administrator. | The request is denied. Contact your organization's administrator for further information. |
404 | Report ID is not found. Please correct it or create a new report. | Double-check that you used the Report ID returned from the Create Async Report endpoint. If the error persists, create a new report. |
404 | Report ID was created with a different key. Please use the same key when requesting status. | To query for a report status, you must use the same API key you used to generate the report. |
405 | METHOD NOT ALLOWED | You are probably using GET instead of POST or vice versa in your http request. |
429 | Query quota is exceeded: only <> reports are currently allowed. The following report IDs are active: . | You have exceeded the amount of async reports you are permitted to run at the same time. Wait for your previous requests to complete. |
429 | Too many requests. Only <> requests per second is currently allowed. | You have exceeded the rate limit. Wait for your previous requests to complete. |
500 | The request has failed due to an internal error. | Typically, this just means you should retry your API call. See What should I do if I get a 500 error? |