You need to ship traffic analytics this week: country coverage for reporting, high-level engagement per domain, and a breakdown of where visitors come from. By the end of this guide you’ll pull supported country codes and query traffic sources, top markets, and engagement metrics for any domain using Site Traffic API on Zyla API Hub.
What you can build with this API
The Site Traffic API returns two critical data sets:
- A complete list of supported countries and their ISO codes (for mapping, reporting, and filters).
- Traffic overview for a domain (top five countries by share, traffic sources, and engagement metrics like visits, pages per visit, and time on site).
Developers use it to power dashboards, market sizing tools, competitive research backends, and automated alerts around audience changes. If you need a fast integration with clear HTTP GET endpoints and a single account/API key model from Zyla API Hub, this guide shows the exact requests and fields you’ll work with.
Getting started on Zyla API Hub
To call the API:
- Open the Site Traffic API page on Zyla API Hub: Start 7-day trial on Site Traffic API.
- Click Subscribe or Start Free Trial when available. Billing is subscription + quota, not pay-per-call. For first-time users, you’ll typically see a 7-day trial or a 50-request option. Check the API page for current access and pricing.
- Copy your API key.
- Send requests with the header Authorization: Bearer YOUR_API_KEY to the endpoints documented below.
One Zyla account and API key works across more than 10,000 public APIs on the marketplace, so you can scale your integrations without creating separate auth flows for each provider.
Endpoints you will use
The Site Traffic API exposes two GET endpoints on Zyla API Hub. All calls require an Authorization header. Do not include a body.
1) Countries List
Receive a list of all supported countries and their codes. These codes are used in the traffic analysis results.
- Method: GET
- URL: https://zylalabs.com/api/29/site-traffic-api/1372/countries-list
- Parameters: none documented
- Auth: Authorization: Bearer YOUR_API_KEY
Official curl example (copy and run):
curl -s -X GET "https://zylalabs.com/api/29/site-traffic-api/1372/countries-list" \
-H "Authorization: Bearer YOUR_API_KEY"
Official example response:
[{"name":"Afghanistan","alpha-2":"AF","alpha-3":"AFG","country-code":"004","iso_3166-2":"ISO 3166-2:AF","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""},{"name":"Åland Islands","alpha-2":"AX","alpha-3":"ALA","country-code":"248","iso_3166-2":"ISO 3166-2:AX","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""},{"name":"Albania","alpha-2":"AL","alpha-3":"ALB","country-code":"008","iso_3166-2":"ISO 3166-2:AL","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""},{"name":"Algeria","alpha-2":"DZ","alpha-3":"DZA","country-code":"012","iso_3166-2":"ISO 3166-2:DZ","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""},{"name":"American Samoa","alpha-2":"AS","alpha-3":"ASM","country-code":"016","iso_3166-2":"ISO 3166-2:AS","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""},{"name":"Andorra","alpha-2":"AD","alpha-3":"AND","country-code":"020","iso_3166-2":"ISO 3166-2:AD","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""},{"name":"Angola","alpha-2":"AO","alpha-3":"AGO","country-code":"024","iso_3166-2":"ISO 3166-2:AO","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"},{"name":"Anguilla","alpha-2":"AI","alpha-3":"AIA","country-code":"660","iso_3166-2":"ISO 3166-2:AI","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"},{"name":"Antarctica","alpha-2":"AQ","alpha-3":"ATA","country-code":"010","iso_3166-2":"ISO 3166-2:AQ","region":"","sub-region":"","intermediate-region":"","region-code":"","sub-region-code":"","intermediate-region-code":""},{"name":"Antigua and Barbuda","alpha-2":"AG","alpha-3":"ATG","country-code":"028","iso_3166-2":"ISO 3166-2:AG","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","s…
What you’ll use from this response:
- name: Country name for display in UIs.
- alpha-2 and alpha-3: ISO codes to map against traffic breakdowns and for localization.
- country-code: Numeric ISO 3166 code. Useful for joins if your data uses numeric identifiers.
- region, sub-region: Grouping for rollups (e.g., regional dashboards).
Tip: Cache this response. Country lists change infrequently, so memoize for 24 hours (or longer) to avoid redundant calls.
2) Traffic Source and Overview
Get the top-5 countries by share, traffic source information, and engagement stats for a domain. Pass the domain without protocol or www.
- Method: GET
- URL: https://zylalabs.com/api/29/site-traffic-api/93/traffic-source-and-overview
- Parameters:
- domain (required): Example value shown below.
- Auth: Authorization: Bearer YOUR_API_KEY
Official curl pattern (as provided by the Hub listing example):
Official example response (excerpt as provided by the Hub):
{
"Version": 1,
"SiteName": "google.com",
"Description": "Learn about the Certified Publisher Program. Our publishing software experts will help you maximize revenue and grow your business.",
"TopCountryShares": [
{
"Country": 840,
"CountryCode": "US",
"Value": 0.23679350972974017
},
{
"Country": 392,
"CountryCode": "JP",
"Value": 0.059428140900848324
},
{
"Country": 356,
"CountryCode": "IN",
"Value": 0.05710248670449797
},
{
"Country": 76,
"CountryCode": "BR",
"Value": 0.049777326688909565
},
{
"Country": 826,
"CountryCode": "GB",
"Value": 0.03518837304351638
}
],
"Title": "Google Advanced Search",
"Engagments": {
"BounceRate": "0.28352824215831807",
"Month": "6",
"Year": "2026",
"PagePerVisit": "8.695346223748027",
"Visits": "84940150026",
"TimeOnSite": "605.4395199614316"
},
"EstimatedMonthlyVisits": {
"2026-04-01": 84751050692,…
What to read from this response:
- TopCountryShares: List of up to 5 items. Use CountryCode (e.g., US, JP) and Value (share as a fraction).
- Engagments: Metrics are strings in the sample. Use them as numeric values in your code after parsing. Visits is a count; PagePerVisit and TimeOnSite are typical engagement signals; BounceRate is a ratio.
- EstimatedMonthlyVisits: A date-keyed object with monthly visit estimates. Keys follow YYYY-MM-01 format.
Tip: Pair CountryCode with alpha-2 from the Countries List endpoint for consistent labeling and regional groupings.
End-to-end example: get supported countries in Python
The snippet below calls Countries List once, builds a lookup of alpha-2 to display name, and demonstrates how to prepare a fast in-memory cache you can share across requests in your service.
import os
import time
import requests
API_KEY = os.getenv("ZYLALABS_API_KEY", "YOUR_API_KEY")
COUNTRIES_URL = "https://zylalabs.com/api/29/site-traffic-api/1372/countries-list"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# naive in-process cache
_cache = {"countries": None, "ts": 0}
CACHE_TTL_SECONDS = 24 * 60 * 60 # 24 hours
def get_countries():
now = time.time()
if _cache["countries"] and (now - _cache["ts"] < CACHE_TTL_SECONDS):
return _cache["countries"]
resp = requests.get(COUNTRIES_URL, headers=HEADERS, timeout=30)
resp.raise_for_status()
data = resp.json() # expected to be a list of country objects (see official sample)
# Build alpha-2 lookup for quick joins later.
alpha2_to_name = {item.get("alpha-2"): item.get("name") for item in data if "alpha-2" in item}
_cache["countries"] = {"raw": data, "alpha2_to_name": alpha2_to_name}
_cache["ts"] = now
return _cache["countries"]
if __name__ == "__main__":
info = get_countries()
# Example usage: print the display name for JP and US if present.
for code in ["JP", "US"]:
print(code, "->", info["alpha2_to_name"].get(code))
Handling response fields:
- Use item["alpha-2"] for joining with TopCountryShares[i].CountryCode in the traffic overview.
- Use item["region"] or item["sub-region"] to roll results up by geography.
- Persist the list to your datastore if you want deterministic snapshots for historical reports.
Reading traffic overview results in your service
When consuming Traffic Source and Overview, keep the following in mind:
- Parameter domain must be provided without protocol or www (for example, example.com).
- TopCountryShares.Value is a share (fraction). Multiply by 100 for percentages when displaying.
- The Engagments object fields appear as strings in the official sample. Convert them to float or int as needed.
- EstimatedMonthlyVisits keys are ISO-like dates (YYYY-MM-01). They’re easy to sort lexicographically.
For a service implementation:
- Validate domain inputs strictly to avoid malformed requests and to keep logs clean.
- Cache results per domain with an expiry appropriate to your application (e.g., hourly) to control traffic and optimize latency.
- If you show comparisons by country, preload the Countries List once per day and map CountryCode to localized country names.
Practical use cases you can ship this week
- Competitor summary cards: Fetch TopCountryShares and Engagments for each competitor domain and render side-by-side in your app. Use the alpha-2 mapping to show flags or full country names.
- Market focus detection: Sort TopCountryShares by Value to identify the top market. Trigger playbook actions (e.g., localize landing page, prioritize SEO in JP/BR/IN).
- Traffic trend sparklines: From EstimatedMonthlyVisits, plot the last 6 months. Cache by domain to keep UI responsive.
- Regional aggregation: Combine CountryCode with region or sub-region from Countries List for regional rollups in your BI dashboard.
- Automated alerts: Watch for a 20% week-over-week swing in Visits or a sudden change in BounceRate to notify a Slack channel.
Implementation details that save time
- Authentication: Every call must include Authorization: Bearer YOUR_API_KEY. Do not put the key in query params.
- Timeouts: Use a client timeout (e.g., 30s) to avoid hanging processes in batch jobs or serverless functions.
- Parsing numeric strings: Convert BounceRate, PagePerVisit, TimeOnSite, and Visits to float/int before calculations.
- Batch scheduling: If you have many domains, schedule traffic overview fetches with jitter to avoid thundering herds and to smooth usage within your subscription quota.
- Resilience: Implement basic retries for transient 5xx responses with exponential backoff. Log response status and endpoint for triaging.
- Caching strategy:
- Countries List: Cache for 24 hours or more.
- Traffic overview: Cache per domain for tens of minutes to hours depending on your freshness needs.
- Data normalization: Keep a small schema in your store:
- domain (string)
- top_countries: [{code: string, share: float}]
- engagement: {visits: int, pages_per_visit: float, time_on_site: float, bounce_rate: float, period: {year, month}}
- estimated_monthly_visits: [{date: "YYYY-MM-01", visits: int}]
Calling the API from AI agents via MCP
If you’re using MCP-compatible tools (e.g., Claude Code, Cursor, Windsurf), you can route calls through Zyla’s MCP endpoint. The MCP endpoint is available at https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY. For details on integrating MCP tools, see: MCP.
Typical flow:
- Provide your Zyla API key to the MCP client.
- Invoke tools for HTTP GET with Authorization header to the exact endpoints documented in this article.
- Parse the JSON in your agent prompt or tool-side code to surface TopCountryShares and Engagments to the user.
Because MCP abstracts transport, keep the same URLs and parameters. Do not add any undocumented fields.
Minimal test plan
- Sanity test Countries List: Assert that alpha-2 codes contain “US”, “JP”, etc., and that the payload is a non-empty array.
- Traffic overview happy path: For a known domain (e.g., google.com per sample), assert presence of TopCountryShares and Engagments keys.
- Type conversions: Confirm numeric parsing of Visits, BounceRate, TimeOnSite, PagePerVisit.
- Mapping join: Cross-check that each TopCountryShares[i].CountryCode maps to a known alpha-2 in the countries list.
- Cache behavior: Validate TTL expiration and refresh paths for both endpoints.
Security and deployment notes
- Environment variables: Store YOUR_API_KEY in secrets managers or environment variables; do not hardcode.
- Server-side calls: Make requests from your backend to avoid exposing keys in front-end code.
- Monitoring: Track per-endpoint latency, error rates, and quota consumption to avoid surprises.
- Data retention: If you persist results, note the fetch timestamp and the Engagments period (Month, Year) to maintain auditability in reports.
Reference: Endpoint summary
- GET https://zylalabs.com/api/29/site-traffic-api/1372/countries-list
- Returns: Array of countries with fields like name, alpha-2, alpha-3, country-code, region, sub-region.
- Params: none documented.
- Auth: Authorization: Bearer YOUR_API_KEY.
- GET https://zylalabs.com/api/29/site-traffic-api/93/traffic-source-and-overview
- Returns: Traffic overview for a domain, including TopCountryShares, Engagments, and EstimatedMonthlyVisits.
- Params: domain (required), e.g., domain=google.com.
- Auth: Authorization: Bearer YOUR_API_KEY.
FAQ
How do I authenticate requests?
Include the header Authorization: Bearer YOUR_API_KEY in every request.
What parameter is required for Traffic Source and Overview?
Pass domain without protocol or www. Example: domain=google.com.
Can I get the list of supported countries?
Yes. Call GET https://zylalabs.com/api/29/site-traffic-api/1372/countries-list (no parameters). Cache it to reduce calls.
How should I handle numeric fields returned as strings?
Parse them to float or int in your code before calculations (e.g., BounceRate, PagePerVisit, TimeOnSite, Visits in Engagments).
Is there a free plan?
Zyla operates on subscription + quota, not pay-per-call. For first-time use, you’ll typically see a 7-day trial or 50 requests. Check the API page for current access options.
Ready to integrate traffic analytics? Open the listing, start your trial, grab your API key, and ship your first endpoint call: Start 7-day trial on Site Traffic API.
Official API response
[{"name":"Afghanistan","alpha-2":"AF","alpha-3":"AFG","country-code":"004","iso_3166-2":"ISO 3166-2:AF","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""},{"name":"Åland Islands","alpha-2":"AX","alpha-3":"ALA","country-code":"248","iso_3166-2":"ISO 3166-2:AX","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""},{"name":"Albania","alpha-2":"AL","alpha-3":"ALB","country-code":"008","iso_3166-2":"ISO 3166-2:AL","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""},{"name":"Algeria","alpha-2":"DZ","alpha-3":"DZA","country-code":"012","iso_3166-2":"ISO 3166-2:DZ","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""},{"name":"American Samoa","alpha-2":"AS","alpha-3":"ASM","country-code":"016","iso_3166-2":"ISO 3166-2:AS","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""},{"name":"Andorra","alpha-2":"AD","alpha-3":"AND","country-code":"020","iso_3166-2":"ISO 3166-2:AD","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""},{"name":"Angola","alpha-2":"AO","alpha-3":"AGO","country-code":"024","iso_3166-2":"ISO 3166-2:AO","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"},{"name":"Anguilla","alpha-2":"AI","alpha-3":"AIA","country-code":"660","iso_3166-2":"ISO 3166-2:AI","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"},{"name":"Antarctica","alpha-2":"AQ","alpha-3":"ATA","country-code":"010","iso_3166-2":"ISO 3166-2:AQ","region":"","sub-region":"","intermediate-region":"","region-code":"","sub-region-code":"","intermediate-region-code":""},{"name":"Antigua and Barbuda","alpha-2":"AG","alpha-3":"ATG","country-code":"028","iso_3166-2":"ISO 3166-2:AG","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","s…
Official API response
[{"name":"Afghanistan","alpha-2":"AF","alpha-3":"AFG","country-code":"004","iso_3166-2":"ISO 3166-2:AF","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""},{"name":"Åland Islands","alpha-2":"AX","alpha-3":"ALA","country-code":"248","iso_3166-2":"ISO 3166-2:AX","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""},{"name":"Albania","alpha-2":"AL","alpha-3":"ALB","country-code":"008","iso_3166-2":"ISO 3166-2:AL","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""},{"name":"Algeria","alpha-2":"DZ","alpha-3":"DZA","country-code":"012","iso_3166-2":"ISO 3166-2:DZ","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""},{"name":"American Samoa","alpha-2":"AS","alpha-3":"ASM","country-code":"016","iso_3166-2":"ISO 3166-2:AS","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""},{"name":"Andorra","alpha-2":"AD","alpha-3":"AND","country-code":"020","iso_3166-2":"ISO 3166-2:AD","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""},{"name":"Angola","alpha-2":"AO","alpha-3":"AGO","country-code":"024","iso_3166-2":"ISO 3166-2:AO","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"},{"name":"Anguilla","alpha-2":"AI","alpha-3":"AIA","country-code":"660","iso_3166-2":"ISO 3166-2:AI","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"},{"name":"Antarctica","alpha-2":"AQ","alpha-3":"ATA","country-code":"010","iso_3166-2":"ISO 3166-2:AQ","region":"","sub-region":"","intermediate-region":"","region-code":"","sub-region-code":"","intermediate-region-code":""},{"name":"Antigua and Barbuda","alpha-2":"AG","alpha-3":"ATG","country-code":"028","iso_3166-2":"ISO 3166-2:AG","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","s…