Skip to content

Repository files navigation

Website traffic-rank API

Top website / web traffic leaderboard via the Trends API live feeds. Competitive intel as JSON.

License: MITPyPIPythonnpm

Key: trendsapi.ai/#get-key. HTTP contract and every source: trendsapi-ai/trendsapi.

Authentication

pip install web-traffic-api
export TRENDSAPI_KEY=your_key

Python 3.9+. Same key as the HTTP API.

fromweb_traffic_apiimportTrendsAPIclient=TrendsAPI() # TRENDSAPI_KEY# client = TrendsAPI(api_key="YOUR_KEY")

get_top_websites() presets type: "Top Websites". Official full client (every source, no preset): trendsapi.

Methods

MethodREST modeReturns
get_top_websites(limit=, offset=, category=)get_top_trendsGetTopTrendsResponse
get_top_trends(type=, ...)get_top_trendsGetTopTrendsResponse

source is lowercase (google search). type is exact (Top Websites). Mixing them is a 400.

fromweb_traffic_apiimportTrendsAPIclient=TrendsAPI() # TRENDSAPI_KEY# client = TrendsAPI(api_key="YOUR_KEY")sites=client.get_top_websites(limit=25)
print(sites.data[0]) # [1, "google.com"]
sites=client.get_top_websites(limit=25)
FieldMeaning
as_of_tsSnapshot time
typeFeed name
limit, offset, countPagination
data[rank, label] rows

Python: hot.data. JS: hot.data. Optional offset= and category= (Amazon Best Sellers by Category, Top Websites only).

Async

importasynciofromweb_traffic_apiimportAsyncTrendsAPIasyncdefmain():
client=AsyncTrendsAPI()
returnawaitclient.get_top_websites(limit=25)
asyncio.run(main())

Each 200 is one billed request.

JavaScript / TypeScript

npm install web-traffic-api

Node 18+, Deno, Bun, Workers. Same API key. Field tables above apply.

Methods

MethodREST modeReturns
getTopWebsites({ limit, offset, category })get_top_trendslive feed
getTopTrends({ type, ... })get_top_trendslive feed
import{TrendsAPI}from"web-traffic-api";constclient=newTrendsAPI({apiKey: process.env.TRENDSAPI_KEY!});constsites=awaitclient.getTopWebsites({limit: 25});console.log(sites.data[0]);// [1, "google.com"]

Call (curl)

FieldValue
EndpointPOST https://api.trendsapi.ai/api
AuthAuthorization: Bearer $TRENDSAPI_KEY
Modeget_top_trends
typeTop Websites (exact capitalization)
Optionalcategory, limit, offset
curl -sS -X POST https://api.trendsapi.ai/api \
-H "Authorization: Bearer $TRENDSAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"mode":"get_top_trends","type":"Top Websites","limit":25}'

Source notes

  • There is no source: web traffic (that string is 400).
  • Parsed data is [rank, hostname] pairs.
  • This is third-party rank estimation, not Google Analytics.

Errors

HTTPClient
200Parsed payload. Python dataclasses / JS typed objects
400Raises. Fix source or type spelling
401Raises. Check TRENDSAPI_KEY
404Raises. No series for that keyword. Do not retry
429Raises. Quota
5xxClient retries, then raises

The HTTP body field is a JSON string. SDKs decode it. Raw curl must parse body a second time.

Site: https://trendsapi.ai/trends/web-traffic.

License

MIT. See LICENSE.