Home / Product / Python

Developers

News API in Python

Search the news from Python with one header and no SDK. Get a free key, paste the first example, and you have today's coverage of anything in a list of dicts.

1. Get a free API key

Sign up at console.unzoi.com and copy your key. The free plan is 1,000 credits / month, 30 days of history, 120 credits / minute, 2 watches, 60-minute minimum interval, with no delay on articles and no card. Keep the key out of your code:

Shell
export UNZOI_KEY="your-key"
pip install requests

2. Search news

Python
import os, requests

API = "https://api.unzoi.com"
HEADERS = {"x-api-key": os.environ["UNZOI_KEY"]}

r = requests.get(f"{API}/search", headers=HEADERS,
                 params={"q": "chip export controls", "mode": "hybrid", "limit": 10})
r.raise_for_status()

for a in r.json()["results"]:
    print(a["published_at"], a["source"], a["title"])
    print("   ", a["url"])

mode chooses how the query matches: keyword for exact words (1 credit), semantic for meaning (2), hybrid for both (3). Use hybrid when a person or a model wrote the query, because they paraphrase.

3. One story per event, not forty copies

A wire report republished by forty sites is forty rows from /search. Ask /stories instead and it is one row with the outlet count, which is what you want for a digest, a feed or a model's context window.

Python
r = requests.get(f"{API}/stories", headers=HEADERS,
                 params={"q": "central bank rate decision", "mode": "hybrid", "limit": 10})

for s in r.json()["stories"]:
    print(f'{s["outlets"]:>3} outlets  {s["title"]}')

4. Date ranges, languages and paging

Python
params = {
    "q": "heatwave",
    "language": "fra",          # ISO 639-3: eng, deu, fra, spa, jpn, ara …
    "from": "2026-11-01",       # also accepts 20261101120000
    "to": "2026-11-30",
    "limit": 100,
}
offset = 0
while True:
    page = requests.get(f"{API}/search", headers=HEADERS,
                        params={**params, "offset": offset}).json()
    for a in page["results"]:
        ...                      # each page is a billed request
    if not page["has_more"]:
        break
    offset += 100

# Your plan's history window moves "from" forward instead of failing; say so.
if page["from_clamped"]:
    print("window clamped to the last", page["history_days"], "days")

5. The two errors worth handling

The complete Python client in the docs handles both, plus paging and the other endpoints, in about sixty lines of httpx.

Questions

How do I get a news API key?

Create a free account at console.unzoi.com and copy the key from the Keys page. The free plan gives 1,000 credits / month with no card, and the key works for both the REST API and the MCP server.

Is there a pip package?

No package is needed. The API is plain HTTPS with one header, so requests or httpx is the whole dependency. The docs publish a complete client class with retries and paging you can copy into your project.

How much does a call cost?

A keyword search costs 1 credit, a semantic search 2 and a hybrid search 3. Add estimate=true to any request to see the price without running it; checking your balance with /account is free.

Can I search news in other languages from Python?

Yes. Pass language with an ISO 639-3 code such as deu, fra, jpn or ara. Semantic and hybrid modes match by meaning, so an English query also finds relevant reporting written in other languages.