Your stakeholders want a dashboard that shows where traffic comes from, which countries matter, and how engaged visitors are. By the end of this article, you’ll ship an integration that fetches country coverage and domain-level traffic sources, top countries, and engagement metrics using the Site Traffic API on Zyla API Hub.
What this API delivers
The Site Traffic API provides domain-level traffic intelligence you can drop into product analytics, SEO tooling, or competitive research workflows. You pass a domain and receive:
- Top 5 countries by traffic share (with both numeric country identifiers and ISO alpha-2 codes).
- Engagement metrics, including bounce rate, pages per visit, visits, and time on site.
- High-level site metadata (title, description).
It also exposes a countries directory with ISO codes and regions so you can label or filter country-specific traffic accurately in your UI or reports.
Getting started on Zyla API Hub
Open the Site Traffic API listing on Zyla API Hub and subscribe. Zyla provides one account, one API key, and a subscription + quota model across more than 10,000 public APIs. For this API, you can start with a 7-day trial or 50 requests; check the listing for current access options and pricing.
Once subscribed, you’ll receive an API key. All requests below use:
- Header: Authorization: Bearer YOUR_API_KEY
- HTTP method: GET
Browse other categories or manage your subscriptions anytime from Zyla API Hub. When you’re ready to implement, grab the trial here: Start 7-day trial on Site Traffic API.
Endpoints you’ll use
1) Countries List
Receive the list of all supported countries and their codes. These codes are referenced in traffic analysis responses so you can render country names and regions correctly.
Method: GET
URL: https://zylalabs.com/api/29/site-traffic-api/1372/countries-list
cURL
curl -s -X GET "https://zylalabs.com/api/29/site-traffic-api/1372/countries-list" \
-H "Authorization: Bearer YOUR_API_KEY"
Official sample 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…
How to use it:
- Map two-letter ISO codes from traffic responses to human-readable names using the “alpha-2” field.
- Group or filter by “region” and “sub-region” when building rollups.
- Store this dataset locally and refresh periodically to avoid repeated lookups.
2) Traffic Source and Overview
Provide a domain (without protocol or “www”) to retrieve top 5 countries by traffic share and engagement metrics, plus high-level site metadata.
Method: GET
URL: https://zylalabs.com/api/29/site-traffic-api/93/traffic-source-and-overview
Required query parameter:
- domain: the domain you want to analyze (example: google.com)
cURL
The response includes fields such as:
- SiteName, Title, Description
- TopCountryShares: array of objects with Country, CountryCode, Value
- Engagments: BounceRate, PagePerVisit, Visits, TimeOnSite, Month, Year
- EstimatedMonthlyVisits: an object keyed by dates (e.g., “YYYY-MM-01”) mapping to visit counts
Note: The Traffic Source and Overview endpoint requires only the domain parameter; do not include protocols or subdomains like “www”.
Code you can paste
Python example: fetch traffic overview and summarize key fields
This snippet calls the Traffic Source and Overview endpoint for a single domain and prints country shares and engagement metrics. Replace YOUR_API_KEY with your key from Zyla.
import requests
from typing import Dict, Any
API_KEY = "YOUR_API_KEY"
DOMAIN = "google.com"
url = "https://zylalabs.com/api/29/site-traffic-api/93/traffic-source-and-overview"
params = {"domain": DOMAIN}
headers = {"Authorization": f"Bearer {API_KEY}"}
resp = requests.get(url, headers=headers, params=params, timeout=30)
resp.raise_for_status()
data: Dict[str, Any] = resp.json()
print("Site:", data.get("SiteName"))
print("Title:", data.get("Title"))
print("Description:", data.get("Description"))
eng = data.get("Engagments", {}) or {}
print("Engagement:")
print(" BounceRate:", eng.get("BounceRate"))
print(" PagePerVisit:", eng.get("PagePerVisit"))
print(" Visits:", eng.get("Visits"))
print(" TimeOnSite (seconds):", eng.get("TimeOnSite"))
print(" Period:", f'{eng.get("Year")}-{eng.get("Month")}')
top_countries = data.get("TopCountryShares", []) or []
print("\nTop Country Shares:")
for item in top_countries:
code = item.get("CountryCode")
share = item.get("Value")
print(f" {code}: {share}")
monthly = data.get("EstimatedMonthlyVisits", {}) or {}
# Take the latest month key if available, sorted by key (YYYY-MM-01 format)
if monthly:
latest_key = sorted(monthly.keys())[-1]
print("\nLatest Estimated Monthly Visits:")
print(f" {latest_key}: {monthly[latest_key]}")
Tip: The response contains numeric values and some string-encoded numbers (e.g., bounce rate, visits in Engagments). If you need numeric math, coerce the strings to float or int before aggregations.
Practical use cases you can ship this week
- Country-aware traffic breakdown inside a marketing dashboard: Call Traffic Source and Overview, render TopCountryShares with country names from Countries List.
- Competitive monitoring widget: For a shortlist of competitor domains, poll the endpoint on a schedule and plot EstimatedMonthlyVisits over time.
- SEO opportunity analysis: Combine SiteName/Title/Description with PagePerVisit and BounceRate to prioritize domains worth outreach or partnerships.
- Territory planning: Use the Countries List to tag countries with regions and sum traffic share by region, helping sales teams focus their efforts.
- Engagement health checks: Track TimeOnSite, PagePerVisit, and BounceRate each month to alert when engagement drifts beyond a threshold.
Request/response details that save time
- Authentication: Use Authorization: Bearer YOUR_API_KEY in every request.
- Domain format: Provide only the domain (e.g., “example.com”). Do not include protocol or “www”.
- Time period fields: Engagments includes Month and Year; EstimatedMonthlyVisits keys look like “YYYY-MM-01”. Store as strings or parse to dates.
- Country codes: Traffic responses include Country (numeric code) and CountryCode (ISO alpha-2). Use Countries List to map to country names and regions.
- Caching: Both endpoints are GET; implement client-side caching to reduce redundant calls in dashboards or server-rendered pages.
- Pagination: Not applicable on these endpoints; responses are complete payloads for the requested domain or dataset.
- Access model: Subscription + quota. First-time usage often starts with a 7-day trial or 50 requests—see the listing for current details.
Calling the API from AI agents via MCP
If you run your workflow in an MCP-compatible client, you can route calls through Zyla’s MCP endpoint. Configure your agent to reach:
Endpoint: https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY
This lets your AI agent invoke the same Site Traffic API endpoints documented above while centralizing auth through your Zyla key. For more about MCP, see the MCP page. You still control which API paths your tool calls and how results are rendered into your agent’s outputs.
End-to-end workflow example
- Fetch Countries List once and cache by ETag or timestamp in your app, keyed by alpha-2.
- For each user-provided domain, call Traffic Source and Overview with domain=example.com.
- Join TopCountryShares.CountryCode to your cached country map for labels and regions.
- Render engagement metrics (BounceRate, PagePerVisit, Visits, TimeOnSite) alongside country shares.
- If you chart trends, index EstimatedMonthlyVisits by parsed date to ensure correct sorting.
Validation and QA tips
- Domain normalization: Lowercase and strip prefixes before calling the API to avoid duplicates.
- Number handling: Convert string numerics in Engagments to numeric types for arithmetic, but retain raw strings for display if you need exact formatting.
- Regional rollups: Use Countries List “region” and “sub-region” to aggregate traffic; keep a fallback for empty region fields (e.g., Antarctica).
- Resilience: Wrap calls with timeouts and retries; treat the dataset as eventually consistent and cache recent results.
Why Zyla for shipping fast
With one account and one API key across the catalog, you can add adjacent analytics or enrichment later without changing your auth model. Billing is subscription + quota, which simplifies cost tracking. Explore the catalog on Zyla API Hub, then subscribe to the Site Traffic API to pull the exact traffic insights you need this week.
FAQ
What parameter format does the domain field expect?
Use the bare domain without protocol or “www”, for example: domain=example.com.
How do I map country codes in TopCountryShares to readable names?
Call the Countries List endpoint and join on the alpha-2 code (CountryCode in TopCountryShares) to display the country name and region.
Are there pagination or batch endpoints?
The documented endpoints are single-call GETs without pagination. For batch processing, loop over your domain list and cache results.
What time units are used in engagement data?
Engagments.TimeOnSite is expressed in seconds. BounceRate, PagePerVisit, and Visits may be string-encoded—convert to numeric types if you need calculations. Month and Year indicate the period of the engagement snapshot.
How do I start a trial and get an API key?
Subscribe on the listing page to begin a 7-day trial or 50 requests (check the page for current access). Your key appears in the Zyla console and is used as Bearer YOUR_API_KEY in headers.
Ready to build? Subscribe and start pulling traffic intelligence now: 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…