Flexible live insights query (Meta)
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). Meta only.
API key authentication - use your Zernio API key as a Bearer token
In: header
Query Parameters
Zernio SocialAccount id (posting or ads variant) used to resolve the Meta token.
Meta insights node: act_, campaign id, ad set id or ad id.
Row granularity
"ad" | "adset" | "campaign" | "account"Comma-separated Graph insights fields (e.g. spend,impressions,frequency,website_purchase_roas). Omitted = Meta's default set.
Comma-separated Graph breakdowns (e.g. age,gender or publisher_platform).
JSON array of Meta filter objects: [{"field", "operator", "value"}]. Applied server-side by Meta.
Meta date_preset (e.g. last_7d, last_30d, this_month). Mutually exclusive with fromDate/toDate.
Start of range (YYYY-MM-DD); requires toDate.
dateEnd of range (YYYY-MM-DD); requires fromDate.
dateDays per row (1-90), monthly, or all_days.
Rows per page
251 <= value <= 500Cursor from paging.after of the previous page.
Response Body
application/json
application/json
import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.ads.queryAdInsights({ query: { accountId: 'account_abc123', objectId: 'object_abc123', },});console.log(data);{
"objectId": "string",
"data": [
{}
],
"paging": {
"after": "string"
}
}{
"error": "Unauthorized"
}Impressions, clicks and spend forecast (LinkedIn) POST
LinkedIn-only. Forecasted impressions, clicks, spend and ~20 other metrics for a targeting spec over a time range. Wraps LinkedIn's `adSupplyForecasts` finder. Each returned series carries a `metricType` (IMPRESSION, CLICK, SPENDING, MAX_POTENTIAL_BUDGET, COST_PER_MILLION_IMPRESSIONS, ...) and a `granularity` (DAILY, SEVEN_DAY, THIRTY_DAY, CUSTOM). LinkedIn caps the daily spending forecast at 1.2x the daily budget and returns 0 once the total budget is exhausted. Non-LinkedIn accounts return `available: false`.
Update ad account settings PATCH
Sets the default DSA beneficiary and payor on a Meta ad account (EU DSA, Article 26). Set them once and every EU-targeted call to `/v1/ads/create`, `/v1/ads/boost` and `/v1/ads/ctwa` on that ad account can omit `dsaBeneficiary`/`dsaPayor`: Meta applies the defaults automatically. The values are written to the ad account on Meta, the same setting Ads Manager edits. Nothing is stored in Zernio, and defaults already set in Ads Manager work identically. Zernio never guesses these values for you. Beneficiary and payor are legal disclosures shown to EU users, so you must provide the entity names explicitly. Use `GET /v1/ads/dsa-recommendations` to offer suggestions in your UI. If `defaultDsaPayor` is omitted, the beneficiary is also set as the payor, which covers the common case where the same entity benefits from and pays for the ads. Read the current values back with `GET /v1/ads/dsa-defaults`. Currently supported for Meta accounts only; other platforms return 400.