Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Website traffic-rank API

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

License: MIT PyPI Python npm

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.

from web_traffic_api import TrendsAPI

client = 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

Method REST mode Returns
get_top_websites(limit=, offset=, category=) get_top_trends GetTopTrendsResponse
get_top_trends(type=, ...) get_top_trends GetTopTrendsResponse

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

from web_traffic_api import TrendsAPI

client = 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)
Field Meaning
as_of_ts Snapshot time
type Feed name
limit, offset, count Pagination
data [rank, label] rows

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

Async

import asyncio
from web_traffic_api import AsyncTrendsAPI

async def main():
    client = AsyncTrendsAPI()
    return await client.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

Method REST mode Returns
getTopWebsites({ limit, offset, category }) get_top_trends live feed
getTopTrends({ type, ... }) get_top_trends live feed
import { TrendsAPI } from "web-traffic-api";

const client = new TrendsAPI({ apiKey: process.env.TRENDSAPI_KEY! });
const sites = await client.getTopWebsites({ limit: 25 });
console.log(sites.data[0]);             // [1, "google.com"]

Call (curl)

Field Value
Endpoint POST https://api.trendsapi.ai/api
Auth Authorization: Bearer $TRENDSAPI_KEY
Mode get_top_trends
type Top Websites (exact capitalization)
Optional category, 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

HTTP Client
200 Parsed payload. Python dataclasses / JS typed objects
400 Raises. Fix source or type spelling
401 Raises. Check TRENDSAPI_KEY
404 Raises. No series for that keyword. Do not retry
429 Raises. Quota
5xx Client 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.