zernio-sdk 0.0.550 → 0.0.552
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +73 -75
- data/docs/AdAccountsApi.md +915 -0
- data/docs/AdCampaignsApi.md +615 -15
- data/docs/AdCreativesApi.md +815 -0
- data/docs/AdInsightsApi.md +415 -0
- data/docs/AdTargetingApi.md +371 -0
- data/docs/AnalyticsApi.md +7 -7
- data/docs/BoostPostRequestTracking.md +1 -1
- data/docs/{CreateLeadFormRequestQuestionsInnerOptionsInner.md → BoostPostRequestTrackingUrlTagsInner.md} +2 -2
- data/docs/ConversionsApi.md +890 -0
- data/docs/CreateLeadFormRequestQuestionsInner.md +1 -1
- data/docs/LeadGenApi.md +527 -0
- data/docs/MessagingAdsApi.md +215 -0
- data/docs/ReachAndFrequencyApi.md +294 -0
- data/docs/TrackingTagsApi.md +141 -0
- data/docs/YouTubeDailyViewsResponse.md +2 -0
- data/docs/YouTubeDemographicsResponse.md +2 -0
- data/docs/YouTubeVideoRetentionResponse.md +2 -0
- data/lib/zernio-sdk/api/ad_accounts_api.rb +958 -0
- data/lib/zernio-sdk/api/ad_campaigns_api.rb +618 -12
- data/lib/zernio-sdk/api/ad_creatives_api.rb +826 -0
- data/lib/zernio-sdk/api/ad_insights_api.rb +446 -0
- data/lib/zernio-sdk/api/ad_targeting_api.rb +404 -0
- data/lib/zernio-sdk/api/analytics_api.rb +8 -8
- data/lib/zernio-sdk/api/conversions_api.rb +936 -0
- data/lib/zernio-sdk/api/lead_gen_api.rb +547 -0
- data/lib/zernio-sdk/api/messaging_ads_api.rb +226 -0
- data/lib/zernio-sdk/api/reach_and_frequency_api.rb +316 -0
- data/lib/zernio-sdk/api/tracking_tags_api.rb +137 -0
- data/lib/zernio-sdk/models/boost_post_request_tracking.rb +5 -2
- data/lib/zernio-sdk/models/{create_lead_form_request_questions_inner_options_inner.rb → boost_post_request_tracking_url_tags_inner.rb} +3 -3
- data/lib/zernio-sdk/models/create_lead_form_request_questions_inner.rb +1 -1
- data/lib/zernio-sdk/models/you_tube_daily_views_response.rb +11 -1
- data/lib/zernio-sdk/models/you_tube_demographics_response.rb +11 -1
- data/lib/zernio-sdk/models/you_tube_video_retention_response.rb +11 -1
- data/lib/zernio-sdk/version.rb +1 -1
- data/lib/zernio-sdk.rb +9 -2
- data/openapi.yaml +329 -163
- data/spec/api/ad_accounts_api_spec.rb +206 -0
- data/spec/api/ad_campaigns_api_spec.rb +119 -6
- data/spec/api/ad_creatives_api_spec.rb +182 -0
- data/spec/api/ad_insights_api_spec.rb +120 -0
- data/spec/api/ad_targeting_api_spec.rb +101 -0
- data/spec/api/analytics_api_spec.rb +4 -4
- data/spec/api/conversions_api_spec.rb +199 -0
- data/spec/api/lead_gen_api_spec.rb +131 -0
- data/spec/api/messaging_ads_api_spec.rb +71 -0
- data/spec/api/reach_and_frequency_api_spec.rb +87 -0
- data/spec/api/tracking_tags_api_spec.rb +25 -0
- data/spec/models/{create_lead_form_request_questions_inner_options_inner_spec.rb → boost_post_request_tracking_url_tags_inner_spec.rb} +6 -6
- data/spec/models/you_tube_daily_views_response_spec.rb +6 -0
- data/spec/models/you_tube_demographics_response_spec.rb +6 -0
- data/spec/models/you_tube_video_retention_response_spec.rb +6 -0
- metadata +38 -10
- data/docs/AdsApi.md +0 -5278
- data/lib/zernio-sdk/api/ads_api.rb +0 -5391
- data/spec/api/ads_api_spec.rb +0 -1015
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
# Zernio::AdInsightsApi
|
|
2
|
+
|
|
3
|
+
All URIs are relative to *https://zernio.com/api*
|
|
4
|
+
|
|
5
|
+
| Method | HTTP request | Description |
|
|
6
|
+
| ------ | ------------ | ----------- |
|
|
7
|
+
| [**create_ad_insights_report**](AdInsightsApi.md#create_ad_insights_report) | **POST** /v1/ads/insights/reports | Submit an async insights report run |
|
|
8
|
+
| [**get_ad_analytics**](AdInsightsApi.md#get_ad_analytics) | **GET** /v1/ads/{adId}/analytics | Get ad analytics |
|
|
9
|
+
| [**get_ad_insights_report**](AdInsightsApi.md#get_ad_insights_report) | **GET** /v1/ads/insights/reports/{reportRunId} | Poll an async insights report run |
|
|
10
|
+
| [**get_campaign_analytics**](AdInsightsApi.md#get_campaign_analytics) | **GET** /v1/ads/campaigns/{campaignId}/analytics | Get campaign analytics |
|
|
11
|
+
| [**query_ad_insights**](AdInsightsApi.md#query_ad_insights) | **GET** /v1/ads/insights | Flexible live insights query |
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## create_ad_insights_report
|
|
15
|
+
|
|
16
|
+
> <CreateAdInsightsReport202Response> create_ad_insights_report(create_ad_insights_report_request)
|
|
17
|
+
|
|
18
|
+
Submit an async insights report run
|
|
19
|
+
|
|
20
|
+
Submits an asynchronous Meta insights report. Same query surface as GET /v1/ads/insights, but in the JSON body; Meta processes the report server-side, which is the right choice for long ranges or large accounts where the sync query is slow or rate-limited. Returns a `reportRunId` to poll via GET /v1/ads/insights/reports/{reportRunId}.
|
|
21
|
+
|
|
22
|
+
### Examples
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
require 'time'
|
|
26
|
+
require 'zernio-sdk'
|
|
27
|
+
# setup authorization
|
|
28
|
+
Zernio.configure do |config|
|
|
29
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
|
30
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
api_instance = Zernio::AdInsightsApi.new
|
|
34
|
+
create_ad_insights_report_request = Zernio::CreateAdInsightsReportRequest.new({account_id: 'account_id_example', object_id: 'object_id_example'}) # CreateAdInsightsReportRequest |
|
|
35
|
+
|
|
36
|
+
begin
|
|
37
|
+
# Submit an async insights report run
|
|
38
|
+
result = api_instance.create_ad_insights_report(create_ad_insights_report_request)
|
|
39
|
+
p result
|
|
40
|
+
rescue Zernio::ApiError => e
|
|
41
|
+
puts "Error when calling AdInsightsApi->create_ad_insights_report: #{e}"
|
|
42
|
+
end
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Using the create_ad_insights_report_with_http_info variant
|
|
46
|
+
|
|
47
|
+
This returns an Array which contains the response data, status code and headers.
|
|
48
|
+
|
|
49
|
+
> <Array(<CreateAdInsightsReport202Response>, Integer, Hash)> create_ad_insights_report_with_http_info(create_ad_insights_report_request)
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
begin
|
|
53
|
+
# Submit an async insights report run
|
|
54
|
+
data, status_code, headers = api_instance.create_ad_insights_report_with_http_info(create_ad_insights_report_request)
|
|
55
|
+
p status_code # => 2xx
|
|
56
|
+
p headers # => { ... }
|
|
57
|
+
p data # => <CreateAdInsightsReport202Response>
|
|
58
|
+
rescue Zernio::ApiError => e
|
|
59
|
+
puts "Error when calling AdInsightsApi->create_ad_insights_report_with_http_info: #{e}"
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Parameters
|
|
64
|
+
|
|
65
|
+
| Name | Type | Description | Notes |
|
|
66
|
+
| ---- | ---- | ----------- | ----- |
|
|
67
|
+
| **create_ad_insights_report_request** | [**CreateAdInsightsReportRequest**](CreateAdInsightsReportRequest.md) | | |
|
|
68
|
+
|
|
69
|
+
### Return type
|
|
70
|
+
|
|
71
|
+
[**CreateAdInsightsReport202Response**](CreateAdInsightsReport202Response.md)
|
|
72
|
+
|
|
73
|
+
### Authorization
|
|
74
|
+
|
|
75
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
76
|
+
|
|
77
|
+
### HTTP request headers
|
|
78
|
+
|
|
79
|
+
- **Content-Type**: application/json
|
|
80
|
+
- **Accept**: application/json
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## get_ad_analytics
|
|
84
|
+
|
|
85
|
+
> <GetAdAnalytics200Response> get_ad_analytics(ad_id, opts)
|
|
86
|
+
|
|
87
|
+
Get ad analytics
|
|
88
|
+
|
|
89
|
+
Returns detailed performance analytics for an ad. Includes summary metrics, a daily timeline over the requested date range, and optional demographic breakdowns (Meta and TikTok only). If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max.
|
|
90
|
+
|
|
91
|
+
### Examples
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
require 'time'
|
|
95
|
+
require 'zernio-sdk'
|
|
96
|
+
# setup authorization
|
|
97
|
+
Zernio.configure do |config|
|
|
98
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
|
99
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
api_instance = Zernio::AdInsightsApi.new
|
|
103
|
+
ad_id = 'ad_id_example' # String |
|
|
104
|
+
opts = {
|
|
105
|
+
from_date: Date.parse('2013-10-20'), # Date | Start of date range (YYYY-MM-DD). Defaults to 90 days ago.
|
|
106
|
+
to_date: Date.parse('2013-10-20'), # Date | End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range.
|
|
107
|
+
breakdowns: 'breakdowns_example' # String | Comma-separated breakdown dimensions. **Meta**: age, gender, country, publisher_platform, device_platform, region. **TikTok**: gender, age, country_code, platform, ac, language. **LinkedIn** (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events.
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
begin
|
|
111
|
+
# Get ad analytics
|
|
112
|
+
result = api_instance.get_ad_analytics(ad_id, opts)
|
|
113
|
+
p result
|
|
114
|
+
rescue Zernio::ApiError => e
|
|
115
|
+
puts "Error when calling AdInsightsApi->get_ad_analytics: #{e}"
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Using the get_ad_analytics_with_http_info variant
|
|
120
|
+
|
|
121
|
+
This returns an Array which contains the response data, status code and headers.
|
|
122
|
+
|
|
123
|
+
> <Array(<GetAdAnalytics200Response>, Integer, Hash)> get_ad_analytics_with_http_info(ad_id, opts)
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
begin
|
|
127
|
+
# Get ad analytics
|
|
128
|
+
data, status_code, headers = api_instance.get_ad_analytics_with_http_info(ad_id, opts)
|
|
129
|
+
p status_code # => 2xx
|
|
130
|
+
p headers # => { ... }
|
|
131
|
+
p data # => <GetAdAnalytics200Response>
|
|
132
|
+
rescue Zernio::ApiError => e
|
|
133
|
+
puts "Error when calling AdInsightsApi->get_ad_analytics_with_http_info: #{e}"
|
|
134
|
+
end
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Parameters
|
|
138
|
+
|
|
139
|
+
| Name | Type | Description | Notes |
|
|
140
|
+
| ---- | ---- | ----------- | ----- |
|
|
141
|
+
| **ad_id** | **String** | | |
|
|
142
|
+
| **from_date** | **Date** | Start of date range (YYYY-MM-DD). Defaults to 90 days ago. | [optional] |
|
|
143
|
+
| **to_date** | **Date** | End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range. | [optional] |
|
|
144
|
+
| **breakdowns** | **String** | Comma-separated breakdown dimensions. **Meta**: age, gender, country, publisher_platform, device_platform, region. **TikTok**: gender, age, country_code, platform, ac, language. **LinkedIn** (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events. | [optional] |
|
|
145
|
+
|
|
146
|
+
### Return type
|
|
147
|
+
|
|
148
|
+
[**GetAdAnalytics200Response**](GetAdAnalytics200Response.md)
|
|
149
|
+
|
|
150
|
+
### Authorization
|
|
151
|
+
|
|
152
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
153
|
+
|
|
154
|
+
### HTTP request headers
|
|
155
|
+
|
|
156
|
+
- **Content-Type**: Not defined
|
|
157
|
+
- **Accept**: application/json
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
## get_ad_insights_report
|
|
161
|
+
|
|
162
|
+
> <GetAdInsightsReport200Response> get_ad_insights_report(report_run_id, account_id, opts)
|
|
163
|
+
|
|
164
|
+
Poll an async insights report run
|
|
165
|
+
|
|
166
|
+
Status and results for a report run created via POST /v1/ads/insights/reports. While the job runs, returns `status` and `percentCompletion`. Once `status` is \"Job Completed\" the response also carries a `data` page, cursor-paginated via `limit` / `after`.
|
|
167
|
+
|
|
168
|
+
### Examples
|
|
169
|
+
|
|
170
|
+
```ruby
|
|
171
|
+
require 'time'
|
|
172
|
+
require 'zernio-sdk'
|
|
173
|
+
# setup authorization
|
|
174
|
+
Zernio.configure do |config|
|
|
175
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
|
176
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
api_instance = Zernio::AdInsightsApi.new
|
|
180
|
+
report_run_id = 'report_run_id_example' # String |
|
|
181
|
+
account_id = 'account_id_example' # String | Zernio SocialAccount id used to resolve the Meta token (must be the same connection that created the run).
|
|
182
|
+
opts = {
|
|
183
|
+
limit: 56, # Integer |
|
|
184
|
+
after: 'after_example' # String |
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
begin
|
|
188
|
+
# Poll an async insights report run
|
|
189
|
+
result = api_instance.get_ad_insights_report(report_run_id, account_id, opts)
|
|
190
|
+
p result
|
|
191
|
+
rescue Zernio::ApiError => e
|
|
192
|
+
puts "Error when calling AdInsightsApi->get_ad_insights_report: #{e}"
|
|
193
|
+
end
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Using the get_ad_insights_report_with_http_info variant
|
|
197
|
+
|
|
198
|
+
This returns an Array which contains the response data, status code and headers.
|
|
199
|
+
|
|
200
|
+
> <Array(<GetAdInsightsReport200Response>, Integer, Hash)> get_ad_insights_report_with_http_info(report_run_id, account_id, opts)
|
|
201
|
+
|
|
202
|
+
```ruby
|
|
203
|
+
begin
|
|
204
|
+
# Poll an async insights report run
|
|
205
|
+
data, status_code, headers = api_instance.get_ad_insights_report_with_http_info(report_run_id, account_id, opts)
|
|
206
|
+
p status_code # => 2xx
|
|
207
|
+
p headers # => { ... }
|
|
208
|
+
p data # => <GetAdInsightsReport200Response>
|
|
209
|
+
rescue Zernio::ApiError => e
|
|
210
|
+
puts "Error when calling AdInsightsApi->get_ad_insights_report_with_http_info: #{e}"
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Parameters
|
|
215
|
+
|
|
216
|
+
| Name | Type | Description | Notes |
|
|
217
|
+
| ---- | ---- | ----------- | ----- |
|
|
218
|
+
| **report_run_id** | **String** | | |
|
|
219
|
+
| **account_id** | **String** | Zernio SocialAccount id used to resolve the Meta token (must be the same connection that created the run). | |
|
|
220
|
+
| **limit** | **Integer** | | [optional][default to 25] |
|
|
221
|
+
| **after** | **String** | | [optional] |
|
|
222
|
+
|
|
223
|
+
### Return type
|
|
224
|
+
|
|
225
|
+
[**GetAdInsightsReport200Response**](GetAdInsightsReport200Response.md)
|
|
226
|
+
|
|
227
|
+
### Authorization
|
|
228
|
+
|
|
229
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
230
|
+
|
|
231
|
+
### HTTP request headers
|
|
232
|
+
|
|
233
|
+
- **Content-Type**: Not defined
|
|
234
|
+
- **Accept**: application/json
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
## get_campaign_analytics
|
|
238
|
+
|
|
239
|
+
> <GetCampaignAnalytics200Response> get_campaign_analytics(campaign_id, opts)
|
|
240
|
+
|
|
241
|
+
Get campaign analytics
|
|
242
|
+
|
|
243
|
+
Returns performance analytics for a whole campaign in one call: summary metrics, a daily timeline over the requested date range (summed across the campaign's ads), and optional demographic breakdowns. Breakdowns are fetched live from Meta at the campaign level (one call per dimension, no per-ad fan-out), so an agency dashboard gets campaign-level age/gender/etc. without summing thousands of per-ad reads. `campaignId` is the platform campaign id; pass `platform` when a campaign id could be ambiguous across platforms. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max.
|
|
244
|
+
|
|
245
|
+
### Examples
|
|
246
|
+
|
|
247
|
+
```ruby
|
|
248
|
+
require 'time'
|
|
249
|
+
require 'zernio-sdk'
|
|
250
|
+
# setup authorization
|
|
251
|
+
Zernio.configure do |config|
|
|
252
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
|
253
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
api_instance = Zernio::AdInsightsApi.new
|
|
257
|
+
campaign_id = 'campaign_id_example' # String | Platform campaign id (platformCampaignId).
|
|
258
|
+
opts = {
|
|
259
|
+
platform: 'platform_example', # String | Disambiguate when the campaign id exists across platforms (e.g. facebook, instagram).
|
|
260
|
+
from_date: Date.parse('2013-10-20'), # Date | Start of date range (YYYY-MM-DD). Defaults to 90 days ago.
|
|
261
|
+
to_date: Date.parse('2013-10-20'), # Date | End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range.
|
|
262
|
+
breakdowns: 'breakdowns_example' # String | Comma-separated breakdown dimensions. **Meta**: age, gender, country, publisher_platform, device_platform, region, platform_position, impression_device, video_asset, image_asset, body_asset, title_asset. **LinkedIn** (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events.
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
begin
|
|
266
|
+
# Get campaign analytics
|
|
267
|
+
result = api_instance.get_campaign_analytics(campaign_id, opts)
|
|
268
|
+
p result
|
|
269
|
+
rescue Zernio::ApiError => e
|
|
270
|
+
puts "Error when calling AdInsightsApi->get_campaign_analytics: #{e}"
|
|
271
|
+
end
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### Using the get_campaign_analytics_with_http_info variant
|
|
275
|
+
|
|
276
|
+
This returns an Array which contains the response data, status code and headers.
|
|
277
|
+
|
|
278
|
+
> <Array(<GetCampaignAnalytics200Response>, Integer, Hash)> get_campaign_analytics_with_http_info(campaign_id, opts)
|
|
279
|
+
|
|
280
|
+
```ruby
|
|
281
|
+
begin
|
|
282
|
+
# Get campaign analytics
|
|
283
|
+
data, status_code, headers = api_instance.get_campaign_analytics_with_http_info(campaign_id, opts)
|
|
284
|
+
p status_code # => 2xx
|
|
285
|
+
p headers # => { ... }
|
|
286
|
+
p data # => <GetCampaignAnalytics200Response>
|
|
287
|
+
rescue Zernio::ApiError => e
|
|
288
|
+
puts "Error when calling AdInsightsApi->get_campaign_analytics_with_http_info: #{e}"
|
|
289
|
+
end
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Parameters
|
|
293
|
+
|
|
294
|
+
| Name | Type | Description | Notes |
|
|
295
|
+
| ---- | ---- | ----------- | ----- |
|
|
296
|
+
| **campaign_id** | **String** | Platform campaign id (platformCampaignId). | |
|
|
297
|
+
| **platform** | **String** | Disambiguate when the campaign id exists across platforms (e.g. facebook, instagram). | [optional] |
|
|
298
|
+
| **from_date** | **Date** | Start of date range (YYYY-MM-DD). Defaults to 90 days ago. | [optional] |
|
|
299
|
+
| **to_date** | **Date** | End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range. | [optional] |
|
|
300
|
+
| **breakdowns** | **String** | Comma-separated breakdown dimensions. **Meta**: age, gender, country, publisher_platform, device_platform, region, platform_position, impression_device, video_asset, image_asset, body_asset, title_asset. **LinkedIn** (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events. | [optional] |
|
|
301
|
+
|
|
302
|
+
### Return type
|
|
303
|
+
|
|
304
|
+
[**GetCampaignAnalytics200Response**](GetCampaignAnalytics200Response.md)
|
|
305
|
+
|
|
306
|
+
### Authorization
|
|
307
|
+
|
|
308
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
309
|
+
|
|
310
|
+
### HTTP request headers
|
|
311
|
+
|
|
312
|
+
- **Content-Type**: Not defined
|
|
313
|
+
- **Accept**: application/json
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
## query_ad_insights
|
|
317
|
+
|
|
318
|
+
> <QueryAdInsights200Response> query_ad_insights(account_id, object_id, opts)
|
|
319
|
+
|
|
320
|
+
Flexible live insights query
|
|
321
|
+
|
|
322
|
+
Live, flexible insights query against Meta's Graph API. Unlike GET /v1/ads/{adId}/analytics (fixed metric set, cached), this forwards caller-chosen `fields`, `breakdowns` and `filtering` to any Meta insights node and returns Meta's rows verbatim. `objectId` selects the node: an ad account, campaign, ad set or ad platform id. `level` sets row granularity independently of the node. Semantic validation is Meta's: an unknown field or invalid breakdown combination returns a 400 carrying Meta's message. For long ranges or agency-scale accounts prefer the async variant (POST /v1/ads/insights/reports).
|
|
323
|
+
|
|
324
|
+
### Examples
|
|
325
|
+
|
|
326
|
+
```ruby
|
|
327
|
+
require 'time'
|
|
328
|
+
require 'zernio-sdk'
|
|
329
|
+
# setup authorization
|
|
330
|
+
Zernio.configure do |config|
|
|
331
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
|
332
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
api_instance = Zernio::AdInsightsApi.new
|
|
336
|
+
account_id = 'account_id_example' # String | Zernio SocialAccount id (posting or ads variant) used to resolve the Meta token.
|
|
337
|
+
object_id = 'object_id_example' # String | Meta insights node: act_<n>, campaign id, ad set id or ad id.
|
|
338
|
+
opts = {
|
|
339
|
+
level: 'ad', # String | Row granularity
|
|
340
|
+
fields: 'fields_example', # String | Comma-separated Graph insights fields (e.g. spend,impressions,frequency,website_purchase_roas). Omitted = Meta's default set.
|
|
341
|
+
breakdowns: 'breakdowns_example', # String | Comma-separated Graph breakdowns (e.g. age,gender or publisher_platform).
|
|
342
|
+
action_breakdowns: 'action_breakdowns_example', # String | Comma-separated Graph action breakdowns. Segments the actions[] arrays in each row.
|
|
343
|
+
action_attribution_windows: 'action_attribution_windows_example', # String | Comma-separated Meta attribution windows. Action values are returned keyed per window.
|
|
344
|
+
action_report_time: 'action_report_time_example', # String | When actions are counted: impression, conversion or mixed.
|
|
345
|
+
use_unified_attribution_setting: true, # Boolean | Use the ad sets' own attribution settings for action counting.
|
|
346
|
+
filtering: 'filtering_example', # String | JSON array of Meta filter objects: [{\"field\", \"operator\", \"value\"}]. Applied server-side by Meta.
|
|
347
|
+
date_preset: 'date_preset_example', # String | Meta date_preset (e.g. last_7d, last_30d, this_month). Mutually exclusive with fromDate/toDate.
|
|
348
|
+
from_date: Date.parse('2013-10-20'), # Date | Start of range (YYYY-MM-DD); requires toDate.
|
|
349
|
+
to_date: Date.parse('2013-10-20'), # Date | End of range (YYYY-MM-DD); requires fromDate.
|
|
350
|
+
time_increment: 'time_increment_example', # String | Days per row (1-90), monthly, or all_days.
|
|
351
|
+
limit: 56, # Integer | Rows per page
|
|
352
|
+
after: 'after_example' # String | Cursor from paging.after of the previous page.
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
begin
|
|
356
|
+
# Flexible live insights query
|
|
357
|
+
result = api_instance.query_ad_insights(account_id, object_id, opts)
|
|
358
|
+
p result
|
|
359
|
+
rescue Zernio::ApiError => e
|
|
360
|
+
puts "Error when calling AdInsightsApi->query_ad_insights: #{e}"
|
|
361
|
+
end
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### Using the query_ad_insights_with_http_info variant
|
|
365
|
+
|
|
366
|
+
This returns an Array which contains the response data, status code and headers.
|
|
367
|
+
|
|
368
|
+
> <Array(<QueryAdInsights200Response>, Integer, Hash)> query_ad_insights_with_http_info(account_id, object_id, opts)
|
|
369
|
+
|
|
370
|
+
```ruby
|
|
371
|
+
begin
|
|
372
|
+
# Flexible live insights query
|
|
373
|
+
data, status_code, headers = api_instance.query_ad_insights_with_http_info(account_id, object_id, opts)
|
|
374
|
+
p status_code # => 2xx
|
|
375
|
+
p headers # => { ... }
|
|
376
|
+
p data # => <QueryAdInsights200Response>
|
|
377
|
+
rescue Zernio::ApiError => e
|
|
378
|
+
puts "Error when calling AdInsightsApi->query_ad_insights_with_http_info: #{e}"
|
|
379
|
+
end
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Parameters
|
|
383
|
+
|
|
384
|
+
| Name | Type | Description | Notes |
|
|
385
|
+
| ---- | ---- | ----------- | ----- |
|
|
386
|
+
| **account_id** | **String** | Zernio SocialAccount id (posting or ads variant) used to resolve the Meta token. | |
|
|
387
|
+
| **object_id** | **String** | Meta insights node: act_<n>, campaign id, ad set id or ad id. | |
|
|
388
|
+
| **level** | **String** | Row granularity | [optional] |
|
|
389
|
+
| **fields** | **String** | Comma-separated Graph insights fields (e.g. spend,impressions,frequency,website_purchase_roas). Omitted = Meta's default set. | [optional] |
|
|
390
|
+
| **breakdowns** | **String** | Comma-separated Graph breakdowns (e.g. age,gender or publisher_platform). | [optional] |
|
|
391
|
+
| **action_breakdowns** | **String** | Comma-separated Graph action breakdowns. Segments the actions[] arrays in each row. | [optional] |
|
|
392
|
+
| **action_attribution_windows** | **String** | Comma-separated Meta attribution windows. Action values are returned keyed per window. | [optional] |
|
|
393
|
+
| **action_report_time** | **String** | When actions are counted: impression, conversion or mixed. | [optional] |
|
|
394
|
+
| **use_unified_attribution_setting** | **Boolean** | Use the ad sets' own attribution settings for action counting. | [optional] |
|
|
395
|
+
| **filtering** | **String** | JSON array of Meta filter objects: [{\"field\", \"operator\", \"value\"}]. Applied server-side by Meta. | [optional] |
|
|
396
|
+
| **date_preset** | **String** | Meta date_preset (e.g. last_7d, last_30d, this_month). Mutually exclusive with fromDate/toDate. | [optional] |
|
|
397
|
+
| **from_date** | **Date** | Start of range (YYYY-MM-DD); requires toDate. | [optional] |
|
|
398
|
+
| **to_date** | **Date** | End of range (YYYY-MM-DD); requires fromDate. | [optional] |
|
|
399
|
+
| **time_increment** | **String** | Days per row (1-90), monthly, or all_days. | [optional] |
|
|
400
|
+
| **limit** | **Integer** | Rows per page | [optional][default to 25] |
|
|
401
|
+
| **after** | **String** | Cursor from paging.after of the previous page. | [optional] |
|
|
402
|
+
|
|
403
|
+
### Return type
|
|
404
|
+
|
|
405
|
+
[**QueryAdInsights200Response**](QueryAdInsights200Response.md)
|
|
406
|
+
|
|
407
|
+
### Authorization
|
|
408
|
+
|
|
409
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
410
|
+
|
|
411
|
+
### HTTP request headers
|
|
412
|
+
|
|
413
|
+
- **Content-Type**: Not defined
|
|
414
|
+
- **Accept**: application/json
|
|
415
|
+
|