API Documentation

Introduction

Get started with the Adverfly API

The Adverfly API allows you to programmatically access data from your workspace. You can retrieve events, sessions, conversions, and ads for analytics.

API Capabilities

CapabilityDescription
Read DataRetrieve events, sessions, conversions, and ads via GET endpoints

When to Use the API vs. JavaScript Pixel

Use CaseRecommended Method
Website trackingJavaScript Pixel (client-side)
Data export / BI integrationAPI
Custom dashboardsAPI
Real-time web analyticsJavaScript Pixel

Base URL

All API requests should be made to:

BASEhttps://api.adverfly.com

Authentication

The API uses API keys for authentication. You can generate API credentials in your workspace settings.

ParameterTypeRequiredDescription
x-api-keystringRequiredYour workspace API key
client-secretstringRequiredYour workspace client secret
Request
curl -X GET "https://api.adverfly.com/v3/events" \
  -H "x-api-key: your-api-key" \
  -H "client-secret: your-client-secret"

Response Format

All responses are returned in JSON format with a pagination object for navigating results.

Response200 OK
{
  "data": [...],
  "pagination": {
    "limit": 100,
    "offset": 0,
    "has_more": true,
    "next_offset": 100,
    "start_date": "2024-01-01 00:00:00",
    "end_date": "2024-01-31 23:59:59"
  }
}

Pagination

FieldTypeDescription
limitintegerNumber of records returned
offsetintegerNumber of records skipped
has_morebooleanWhether more records are available
next_offsetinteger or nullOffset value for the next page (null when has_more is false)
start_datestringStart of the queried date range
end_datestringEnd of the queried date range

Use next_offset as the offset parameter in your next request to paginate through results. When has_more is false, you have reached the last page.

Rate Limits

LimitValue
Daily quota4,320 requests per day
Rate limit10 requests per second
Burst limit20 requests
Max records per request500 (limit parameter)

Date Parameters

All endpoints accept start_date and end_date in YYYY-MM-DD format. If omitted, the API defaults to the last 7 days. Aliases from and to are also accepted.

Events

Retrieve event data from your workspace

Retrieve event data from your workspace pixel tracking. Events include pageviews, clicks, and custom events tracked by your pixel.

GET/v3/events

Query Parameters

ParameterTypeRequiredDescription
start_datestringOptionalStart date in YYYY-MM-DD format (default: 7 days ago). Alias: from
end_datestringOptionalEnd date in YYYY-MM-DD format (default: today). Alias: to
namestringOptionalFilter by event name. Supports wildcards with * (e.g. survey_* to match all survey events). Alias: event_name
session_idintegerOptionalFilter by session ID
visitor_idintegerOptionalFilter by visitor ID
sourcestringOptionalFilter by ad source. Comma-separated for multiple (e.g. meta,google). Alias: sources
limitintegerOptionalNumber of records to return (default: 100, max: 500). Alias: page_size
offsetintegerOptionalNumber of records to skip for pagination. Alias: page

Name filter examples

ValueMatches
pageviewExact match — only pageview events
survey_*All events starting with survey_ (e.g. survey_opened, survey_completed)
*_completedAll events ending with _completed
Request
curl -X GET "https://api.adverfly.com/v3/events?start_date=2024-01-01&end_date=2024-01-31&name=survey_*&limit=100" \
  -H "x-api-key: your-api-key" \
  -H "client-secret: your-client-secret"
Response200 OK
{
  "data": [
    {
      "store_id": 12345,
      "dt": "2024-01-15 10:30:00",
      "name": "pageview",
      "session_id": 789012345,
      "visitor_id": 456789012,
      "visitor_timezone": "Europe/Berlin",
      "adv_source": "meta",
      "adv_campaign_id": "120210123456789",
      "adv_adgroup_id": "120210987654321",
      "adv_ad_id": "120210111222333",
      "utm_source": "facebook",
      "utm_medium": "cpc",
      "utm_campaign": "winter_sale",
      "utm_content": "video_ad_1",
      "utm_term": "",
      "device_type": "desktop",
      "country_code": "DE",
      "hostname": "example.com",
      "pathname": "/products",
      "referrer": "https://google.com",
      "entry_meta_keys": ["fbclid", "gclid"],
      "entry_meta_values": ["abc123", ""]
    }
  ],
  "pagination": {
    "limit": 100,
    "offset": 0,
    "has_more": true,
    "next_offset": 100,
    "start_date": "2024-01-01 00:00:00",
    "end_date": "2024-01-31 23:59:59"
  }
}

Response Fields

FieldTypeDescription
store_idintegerWorkspace ID
dtstringEvent timestamp
namestringEvent name (e.g. pageview, add_to_cart, survey_opened)
session_idintegerSession identifier
visitor_idintegerVisitor identifier
visitor_timezonestringVisitor's timezone
adv_sourcestringAd platform source (e.g. meta, google)
adv_campaign_idstringCampaign ID from ad platform
adv_adgroup_idstringAd group ID from ad platform
adv_ad_idstringAd ID from ad platform
utm_sourcestringUTM source parameter
utm_mediumstringUTM medium parameter
utm_campaignstringUTM campaign parameter
utm_contentstringUTM content parameter
utm_termstringUTM term parameter
device_typestringDevice type (desktop, mobile, tablet)
country_codestringISO country code (e.g. DE, US)
hostnamestringWebsite hostname
pathnamestringPage path
referrerstringReferring URL
entry_meta_keysarrayClick ID parameter names (e.g. fbclid, gclid)
entry_meta_valuesarrayClick ID values (parallel array with entry_meta_keys)

Sessions

Access session data and user activity

Access session data and user activity information. A session represents a user's visit to your website, grouping multiple events together.

GET/v3/sessions

Query Parameters

ParameterTypeRequiredDescription
start_datestringOptionalStart date in YYYY-MM-DD format (default: 7 days ago). Alias: from
end_datestringOptionalEnd date in YYYY-MM-DD format (default: today). Alias: to
session_idintegerOptionalFilter by session ID
visitor_idintegerOptionalFilter by visitor ID
sourcestringOptionalFilter by ad source. Comma-separated for multiple. Alias: sources
limitintegerOptionalNumber of records to return (default: 100, max: 500). Alias: page_size
offsetintegerOptionalNumber of records to skip for pagination. Alias: page
Request
curl -X GET "https://api.adverfly.com/v3/sessions?start_date=2024-01-01&end_date=2024-01-31&limit=100" \
  -H "x-api-key: your-api-key" \
  -H "client-secret: your-client-secret"
Response200 OK
{
  "data": [
    {
      "store_id": 12345,
      "visitor_id": 456789012,
      "session_id": 789012345,
      "session_start_dt": "2024-01-15 10:25:00",
      "session_end_dt": "2024-01-15 10:45:00",
      "session_duration_seconds": 1200,
      "is_bounce": 0,
      "session_entry_page": "/",
      "session_exit_page": "/checkout/success",
      "events": 12,
      "pageviews": 8,
      "add_to_carts": 1,
      "initiated_checkouts": 1,
      "view_contents": 3,
      "contacts": 0,
      "newsletter_signups": 0,
      "completed_registrations": 0,
      "app_installs": 0,
      "add_payment_infos": 1,
      "adv_source": "meta",
      "adv_campaign_id": "120210123456789",
      "adv_adgroup_id": "120210987654321",
      "adv_ad_id": "120210111222333",
      "utm_source": "facebook",
      "utm_campaign": "winter_sale",
      "utm_medium": "cpc",
      "utm_content": "video_ad_1",
      "utm_term": "",
      "device_type": "desktop",
      "country_code": "DE",
      "referrer": "https://google.com",
      "pathname": "/products",
      "hostname": "example.com",
      "entry_meta_keys": ["fbclid"],
      "entry_meta_values": ["abc123"]
    }
  ],
  "pagination": {
    "limit": 100,
    "offset": 0,
    "has_more": true,
    "next_offset": 100,
    "start_date": "2024-01-01 00:00:00",
    "end_date": "2024-01-31 23:59:59"
  }
}

Response Fields

FieldTypeDescription
store_idintegerWorkspace ID
visitor_idintegerVisitor identifier
session_idintegerSession identifier
session_start_dtstringSession start timestamp
session_end_dtstringSession end timestamp
session_duration_secondsintegerSession duration in seconds
is_bounceintegerWhether the session was a bounce (1 = bounce, 0 = not)
session_entry_pagestringLanding page path
session_exit_pagestringExit page path
eventsintegerTotal number of events in session
pageviewsintegerNumber of page views
add_to_cartsintegerNumber of add-to-cart events
initiated_checkoutsintegerNumber of checkout starts
view_contentsintegerNumber of content views
contactsintegerNumber of contact events
newsletter_signupsintegerNumber of newsletter signups
completed_registrationsintegerNumber of completed registrations
app_installsintegerNumber of app installs
add_payment_infosintegerNumber of payment info submissions
adv_sourcestringAd platform source
adv_campaign_idstringCampaign ID from ad platform
adv_adgroup_idstringAd group ID from ad platform
adv_ad_idstringAd ID from ad platform
utm_sourcestringUTM source parameter
utm_campaignstringUTM campaign parameter
utm_mediumstringUTM medium parameter
utm_contentstringUTM content parameter
utm_termstringUTM term parameter
device_typestringDevice type (desktop, mobile, tablet)
country_codestringISO country code
referrerstringReferring URL
pathnamestringPage path
hostnamestringWebsite hostname
entry_meta_keysarrayClick ID parameter names
entry_meta_valuesarrayClick ID values

Conversions

Get conversion event data

Get conversion event data for your workspace. Conversions are tracked when users complete desired actions like purchases, signups, or form submissions.

GET/v3/conversions

Query Parameters

ParameterTypeRequiredDescription
start_datestringOptionalStart date in YYYY-MM-DD format (default: 7 days ago). Alias: from
end_datestringOptionalEnd date in YYYY-MM-DD format (default: today). Alias: to
namestringOptionalFilter by conversion name. Supports wildcards with * (e.g. purchase_*)
transaction_idstringOptionalFilter by transaction/order ID
customer_idstringOptionalFilter by customer ID
is_new_customerstringOptionalFilter by new/returning customer (accepts 0, 1, true, false)
limitintegerOptionalNumber of records to return (default: 100, max: 500). Alias: page_size
offsetintegerOptionalNumber of records to skip for pagination. Alias: page
Request
curl -X GET "https://api.adverfly.com/v3/conversions?start_date=2024-01-01&end_date=2024-01-31&limit=100" \
  -H "x-api-key: your-api-key" \
  -H "client-secret: your-client-secret"
Response200 OK
{
  "data": [
    {
      "store_id": 12345,
      "dt": "2024-01-15 10:42:00",
      "name": "purchase",
      "session_id": 789012345,
      "customer_id": "customer@email.com",
      "visitor_id": 456789012,
      "transaction_id": "ORD-2024-001",
      "transaction_gross_revenue": 12999,
      "transaction_currency": "EUR",
      "transaction_country_code": "DE",
      "transaction_city": "Berlin",
      "hostname": "example.com"
    }
  ],
  "pagination": {
    "limit": 100,
    "offset": 0,
    "has_more": true,
    "next_offset": 100,
    "start_date": "2024-01-01 00:00:00",
    "end_date": "2024-01-31 23:59:59"
  }
}

Response Fields

FieldTypeDescription
store_idintegerWorkspace ID
dtstringConversion timestamp
namestringConversion type (e.g. purchase, lead)
session_idintegerSession identifier
customer_idstringCustomer identifier (e.g. email)
visitor_idintegerVisitor identifier
transaction_idstringOrder/transaction ID
transaction_gross_revenueintegerRevenue in cents (e.g. 12999 = 129.99)
transaction_currencystringCurrency code (EUR, USD, etc.)
transaction_country_codestringISO country code
transaction_citystringCustomer's city
hostnamestringWebsite hostname

Notes

  • Revenue is returned in the smallest currency unit (cents). Divide by 100 for the main currency value.
  • Use transaction_id or customer_id filters to look up specific orders or customers.

Ads

Get advertising performance data

Get advertising performance data for your workspace. Returns spend, impressions, clicks, and reach from connected ad platforms (Meta, Google, TikTok, etc.).

GET/v3/ads

Query Parameters

ParameterTypeRequiredDescription
start_datestringOptionalStart date in YYYY-MM-DD format. Defaults to 7 days ago if omitted.
end_datestringOptionalEnd date in YYYY-MM-DD format. Defaults to today if omitted.
sourcestringOptionalFilter by ad platform. Comma-separated for multiple (e.g. meta,google)
adaccount_idstringOptionalFilter by ad account ID
campaign_idstringOptionalFilter by campaign ID
adgroup_idstringOptionalFilter by ad group ID
ad_idstringOptionalFilter by ad ID
limitintegerOptionalNumber of records to return (default: 100)
offsetintegerOptionalNumber of records to skip for pagination

Supported sources

ValuePlatform
metaMeta (includes facebook, instagram, messenger, audience_network, threads)
facebookFacebook (subset of Meta)
instagramInstagram (subset of Meta)
googleGoogle Ads
tiktokTikTok Ads
pinterestPinterest Ads
snapchatSnapchat Ads
outbrainOutbrain
taboolaTaboola
organicOrganic traffic
audience_networkMeta Audience Network (subset of Meta)
messengerMeta Messenger (subset of Meta)
threadsMeta Threads (subset of Meta)
whatsappWhatsApp
emailEmail channels
Request
curl -X GET "https://api.adverfly.com/v3/ads?start_date=2024-01-01&end_date=2024-01-31&source=meta,google&limit=100" \
  -H "x-api-key: your-api-key" \
  -H "client-secret: your-client-secret"
Response200 OK
{
  "data": [
    {
      "store_id": 12345,
      "dt": "2024-01-15",
      "adaccount_id": "act_123456789",
      "source": "meta",
      "campaign_id": "120210123456789",
      "campaign_name": "Winter Sale 2024",
      "adgroup_id": "120210987654321",
      "adgroup_name": "Lookalike - Purchases",
      "ad_id": "120210111222333",
      "ad_name": "Video - Snow Jacket",
      "spend": 4500,
      "impressions": 12340,
      "clicks": 287,
      "reach": 9800
    }
  ],
  "pagination": {
    "limit": 100,
    "offset": 0,
    "has_more": true,
    "next_offset": 100,
    "start_date": "2024-01-01 00:00:00",
    "end_date": "2024-01-31 23:59:59",
    "sources": ["meta", "google"]
  }
}

Response Fields

FieldTypeDescription
store_idintegerYour workspace ID
dtstringDate of the ad data (YYYY-MM-DD)
adaccount_idstringAd account identifier
sourcestringAd platform (meta, google, tiktok, etc.)
campaign_idstringCampaign identifier
campaign_namestringCampaign name
adgroup_idstringAd group identifier
adgroup_namestringAd group name
ad_idstringAd identifier
ad_namestringAd name
spendintegerSpend in smallest currency unit (cents)
impressionsintegerNumber of impressions
clicksintegerNumber of clicks
reachintegerNumber of unique users reached (0 if not reported by platform)

Totals

The ads endpoint also returns a totals object at the top level with aggregated values:

{
  "totals": {
    "total_ads": 500,
    "total_spend": 123456,
    "total_impressions": 9876543,
    "total_clicks": 54321,
    "total_reach": 7654321
  },
  "data": [...],
  "pagination": { ... }
}

Notes

  • Spend is returned in the smallest currency unit (e.g. cents). Divide by 100 to get the value in the main currency unit.
  • Reach may be 0 for platforms that do not report it (e.g. Google Ads).
  • Data is deduplicated per ad per day. If the same ad data is imported multiple times, only the latest version is returned.
  • Requires read:<source> or admin:admin permission on your API key.

Errors

API error codes and handling

The Adverfly API uses standard HTTP status codes to indicate the success or failure of requests.

HTTP Status Codes

Status CodeStatusDescription
200OKRequest succeeded
400Bad RequestMissing required headers or invalid parameters
401UnauthorizedInvalid API key or client secret
403ForbiddenValid credentials but insufficient permissions for the requested source
404Not FoundRequested endpoint does not exist
405Method Not AllowedHTTP method not supported
429Too Many RequestsRate limit exceeded (enforced at API Gateway level)
500Internal Server ErrorUnexpected server error

Error Response Format

When an error occurs, the API returns a JSON object with a message field:

Response401 Unauthorized
{
  "message": "Invalid API key"
}

Common Error Messages

CodeDescription
Missing x-api-key headerThe x-api-key header was not included in the request (HTTP 400)
Missing client-secret headerThe client-secret header was not included in the request (HTTP 400)
Invalid API keyThe provided API key does not exist or has been revoked (HTTP 401)
Invalid client secretThe client secret does not match the API key (HTTP 401)
You do not have access to pixel dataYour API key does not have pixel read permissions (HTTP 403)
You do not have access to ads dataYour API key does not have ads read permissions (HTTP 403)
You do not have access to the requested sourcesYour API key lacks permission for one or more of the requested source platforms (HTTP 403)
Invalid start_date or end_date parameterDate must be in YYYY-MM-DD format (HTTP 400)
start_date must be before end_dateThe start date is after the end date (HTTP 400)
limit must be a positive integerThe limit parameter must be a positive number (HTTP 400)
offset must be a non-negative integerThe offset parameter cannot be negative (HTTP 400)
session_id must be numericThe session_id filter must be a number (HTTP 400)
visitor_id must be numericThe visitor_id filter must be a number (HTTP 400)
is_new_customer must be one of 0,1,true,falseInvalid value for is_new_customer filter (HTTP 400)
Method not allowedThe HTTP method used is not supported — use GET (HTTP 405)

Permissions

API keys use a source-based permission system. Each key can have permissions like read:meta, read:google, etc. Use admin:admin for full access to all sources.

If you request ads from a source your key does not have permission for, you will receive a 403 Forbidden response.