Skip to main content

webzio-news-search

Search global news with Webz.io from Python - in natural language, with the most relevant articles first.

Webz.io News Search covers news and current events from sources worldwide over the last 30 days. Ask a question in plain language, narrow results with filters (language, country, date, sentiment, domain, ticker, and more), and get back article titles, URLs, metadata, and the excerpt that matched.

This package calls the News Search API over HTTPS. It has one dependency (httpx) and no MCP or agent-framework requirement. Use it in scripts, services, notebooks, or as a function tool for any LLM that supports tool calling.

Looking for a framework wrapper instead? See langchain-webz, llama-index-tools-webz, ag2-webzio, crewai-webzio, or @webz.io/ai-sdk. Those connect through the hosted MCP server.

What you get

  • Natural-language search - "EU AI Act enforcement updates", "How is Tesla stock reacting to earnings?"
  • Typed results - NewsSearchResponse → NewsResult → article, chunk, metadata, plus the raw JSON.
  • Every filter - language, country, category, sentiment, dates, domain, exclude_domain, topic, person, organization, location, ticker, political_bias, trust_category, source_type, domain rank. Unknown filter names pass straight through, so new server-side filters work without a package update.
  • Sync and async - search() and asearch() on the same client.
  • LLM tool calling - tool_definition() gives you the JSON schema; run_tool() executes the model's arguments and returns prompt-ready text.

Install

pip install webzio-news-search
export WEBZ_API_TOKEN="your-webz-api-token"

Get a token from your Webz.io dashboard. It is the same token as the News Search API and MCP server.

from webzio_news_search import WebzNewsSearch

client = WebzNewsSearch()  # reads WEBZ_API_TOKEN from the environment
# client = WebzNewsSearch(api_token="your-webz-api-token")

response = client.search("recent developments on EU AI regulation", k=10, days=30)

print(response.total_results, "results |", response.credits_used, "credits used")
for result in response:
    print(result.score, result.title, result.url)
    print("  ", result.text)  # the matching excerpt
# language, country, and date window
client.search(
    "trade agreements between USA and Germany",
    k=10,
    days=7,
    language=["english"],
    country=["US", "DE"],
)

# ticker and trusted publishers
client.search(
    "earnings guidance and analyst reactions",
    ticker=["NVDA"],
    domain=["yahoo.com", "cnn.com"],
    score_gte=5,
    k=5,
)

# explicit dates and a filters dict, exactly as the API documents it
client.search(
    "central bank interest rate decision",
    filters={
        "published_from": "2026-07-01",
        "published_to": "2026-07-31",
        "sentiment": ["negative"],
        "political_bias": ["center"],
    },
)

days=N is shorthand for published_from = today - N days (UTC). Pass one or the other, not both.

Bare strings are accepted for list filters: language="english" becomes ["english"].

Async

from webzio_news_search import WebzNewsSearch

async with WebzNewsSearch() as client:
    response = await client.asearch("renewable energy investments", k=5)

One-shot helpers

from webzio_news_search import news_search, anews_search

response = news_search("semiconductor export controls", k=3)
response = await anews_search("semiconductor export controls", k=3)

Results

response.query            # echoed query
response.total_results    # matches returned, up to k
response.requests_left    # remaining credit balance
response.credits_used     # credits charged for this call
response.raw              # full JSON payload

result = response.results[0]
result.score              # 0-10 match quality
result.article.title / url / published_at / summary / main_image / article_id
result.chunk.text         # most relevant excerpt
result.metadata           # language, country, category, sentiment, domain, site_type,
                          # topic, person, organization, location, ticker,
                          # political_bias, trust_category, source_type, domain_rank

response.to_text()        # prompt-friendly text block
response.to_dicts()       # flat rows for sheets / dataframes

To fetch the full article body, use result.article.article_id as a uuid: query on the News API.

As an LLM tool

The tool schema is framework-agnostic JSON. Example with the OpenAI chat completions API:

import json
from openai import OpenAI
from webzio_news_search import WebzNewsSearch

openai_client = OpenAI()
news = WebzNewsSearch()

messages = [{"role": "user", "content": "What happened with Nvidia this week? Cite sources."}]
completion = openai_client.chat.completions.create(
    model="gpt-4.1-mini",
    messages=messages,
    tools=[WebzNewsSearch.openai_tool_definition()],
)

for call in completion.choices[0].message.tool_calls or []:
    tool_output = news.run_tool(call.function.arguments)  # JSON string or dict
    messages.append({"role": "tool", "tool_call_id": call.id, "content": tool_output})

tool_definition() returns {"name", "description", "parameters"} for providers that take a bare function schema (Anthropic, Groq, Gemini, and others). The tool name is news_search_by_webz, the same as the MCP server, so prompts written for one work with the other.

run_tool() accepts query, k, days, score_gte, score_lte, allow_multiple_chunks_per_article, and any filter name. It returns response.to_text().

A full agent loop is in examples/openai_tool_calling.py.

Errors

Exception When
WebzConfigError Missing token, empty or over-long query, bad k/score combination, days together with published_from, a domain in both domain and exclude_domain
WebzAPIError Any HTTP error. status_code and detail are set; the message includes a hint for 400, 401, 402, 403, 422, 429, and 5xx. Transport failures raise with status_code == 0.

Failed requests are not charged. See Errors, Rate Limits & Credits.

Configuration

Name Default Purpose
WEBZ_API_TOKEN required Webz API token from the dashboard
WEBZ_NEWS_SEARCH_URL https://api.webz.io/api/news/context Endpoint override for testing

Constructor options: api_token=, api_url=, timeout= (seconds or httpx.Timeout), and client= / async_client= to reuse your own httpx clients.

Development

cd packages/news-search
pip install -e '.[dev]'
pytest                       # unit tests, no network
WEBZ_API_TOKEN=... pytest    # also runs tests/test_live.py

Metadata

Release files for webzio-news-search 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webzio-news-search 0.1.0
File Size Uploaded
webzio_news_search-0.1.0.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for webzio-news-search 0.1.0
File Interpreter ABI Platform
webzio_news_search-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / webzio_news_search-0.1.0.tar.gz

Download URL webzio_news_search-0.1.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dac66c939528e63be50a7d06d9d7bea44c9ce428f331d0fb64456b01d129bd8b
BLAKE2b-256 checksum
How to use checksums
2167cd46428ddb9fc6248467ac183c45b84d1009356ed0355a08faa01037a8a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / webzio_news_search-0.1.0-py3-none-any.whl

Download URL webzio_news_search-0.1.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bcc23c4c2ab8b79d4456e175840181605a736d0b7f0aeb2f957640f63321f60
BLAKE2b-256 checksum
How to use checksums
b22889b2a975f60537ef68217910e4fb0f9021638586c31cd8313cab32747bdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page