Market and trend research

See what is rising: daily trending searches, news volume over time, Wikipedia attention for a topic and the Hacker News front page.

The problem#

Trend work usually starts with a question like "is interest in this topic growing?" and ends in five browser tabs. Each signal (search interest, news coverage, reference-page traffic, tech-community attention) lives somewhere different.

Each one is a single Onekey call, and they all return dated series or ranked lists in the same shape.

Endpoints to call#

EndpointUsed forCreditsStatus
google.trendsTrending searches for a country, with approximate traffic.5stable
gdelt.volume_timelineShare of news coverage over time for a query.5stable
wikipedia.pageviewsDaily pageviews of one Wikipedia article between two dates.5stable
hackernews.front_pageWhat the Hacker News front page holds right now.5stable

Each endpoint name links to its reference page with every parameter, the caching window and a recorded response.

Your first call#

This is google.trends (5 credits). Replace YOUR_API_KEY with your key; sign up, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

curl "https://api.onekey.dev/v1/google/trends?geo=US" \
  -H "x-api-key: YOUR_API_KEY"

A working script#

Pull today's trending searches, then check one topic across news volume and Wikipedia pageviews for the last 30 days.

python
import os
import requests

API = "https://api.onekey.dev"
HEADERS = {"x-api-key": os.environ["ONEKEY_KEY"]}


def call(path, **params):
    """GET /v1/<platform>/<endpoint>; returns the data or raises with the error code."""
    r = requests.get(f"{API}/v1/{path}", params=params, headers=HEADERS, timeout=30)
    body = r.json()
    if not body["success"]:
        raise RuntimeError(f"{path}: {body['error']['code']}")
    return body["data"]


def get(item, field):
    """get(item, 'content.title'): a field of the unified schema, or None."""
    for key in field.split("."):
        item = (item or {}).get(key)
    return item

from datetime import date, timedelta

for t in call("google/trends", geo="US")[:10]:
    print(get(t, "content.title"), "|", get(t, "engagement.views"))

TOPIC = "heat pumps"
for p in call("gdelt/volume_timeline", q=TOPIC)[-7:]:
    print("news volume", get(p, "entity.date"), get(p, "ext.volumeIntensity"))

end = date.today()
start = end - timedelta(days=30)
views = call("wikipedia/pageviews", title="Heat pump", start=start.strftime("%Y%m%d"), end=end.strftime("%Y%m%d"))
print("wikipedia views, last 30 days:", sum(get(v, "engagement.views") or 0 for v in views))

for story in call("hackernews/front_page")[:5]:
    print("HN", get(story, "engagement.likes"), get(story, "content.title"))

What a month costs#

Illustrative volume, not a benchmark: Daily trending searches for 5 countries, weekly news-volume and Wikipedia timelines for 20 topics, and a daily Hacker News front page, for 30 days.

EndpointCallsCredits per callCredits
google.trends1505750
gdelt.volume_timeline805400
wikipedia.pageviews805400
hackernews.front_page305150
Total1,700

About 1,700 credits: the Starter pack (5,000 credits, $9) covers it, at $1.80 per 1,000 credits. Prices are in USD (regional pricing is planned); credits never expire. See pricing.

Every figure above assumes every call is a fresh fetch. These endpoints cache for 30 seconds to 1 hour. Free when served from cache (0.2 credit for a cached response over 100 KB). Repeating a call inside that window costs nothing. Invalid, failed and not-found calls are not charged either.

Good to know#

Keep reading#