Metadata-Version: 2.5
Name: webz-haystack
Version: 0.1.0
Summary: Haystack component for Webz.io News Search
Project-URL: Homepage, https://webz.io
Project-URL: Documentation, https://docs.webz.io/docs/webz/news-search-api
Project-URL: Repository, https://github.com/Webhose/webz-news-search
Project-URL: Issues, https://github.com/Webhose/webz-news-search/issues
Author-email: "Webz.io" <support@webz.io>
License-Expression: MIT
License-File: LICENSE
Keywords: haystack,news,search,websearch,webz
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: haystack-ai>=2.0.0
Requires-Dist: httpx>=0.27
Requires-Dist: webzio-news-search>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# webz-haystack

Search global news from [Haystack](https://haystack.deepset.ai/) with [Webz.io News Search](https://docs.webz.io/docs/webz/news-search-api).

`WebzWebSearch` is a Haystack component. It returns one `Document` per article: the matching excerpt is `content`, and the title, URL, publish time, source, and entities are in `meta`. Coverage is the last 30 days.

## Install

```bash
pip install webz-haystack
export WEBZ_API_TOKEN="your-webz-api-token"
```

Get a token from your [Webz.io dashboard](https://webz.io). It is the same token as the News Search API.

## Pipeline

```python
from haystack import Pipeline
from haystack_integrations.components.websearch.webz import WebzWebSearch

pipeline = Pipeline()
pipeline.add_component(
    "news",
    WebzWebSearch(top_k=5, days=7, language=["english"], country=["US"]),
)
result = pipeline.run({"news": {"query": "recent developments on EU AI regulation"}})

for document in result["news"]["documents"]:
    print(document.meta["title"])
    print(document.meta["url"])
    print(document.content)
```

`WebzWebSearch()` reads `WEBZ_API_TOKEN`. To pass the token in code, use a Haystack `Secret`:

```python
from haystack.utils import Secret
from haystack_integrations.components.websearch.webz import WebzWebSearch

news = WebzWebSearch(api_key=Secret.from_token("your-webz-api-token"), top_k=5)
result = news.run(query="renewable energy investments", domain=["reuters.com"])
```

The same inputs are available on `run()` and override the values from `__init__`.

## Filters

| Input | Sent as |
| --- | --- |
| `top_k` | `k` |
| `language` | `filters.language` |
| `country` | `filters.country` |
| `domain` | `filters.domain` |
| `days` | `filters.published_from` (`YYYY-MM-DD`, UTC, today minus N days) |
| `score_gte`, `score_lte` | top-level score bounds, 0-10 |

The API has no `days` field. A bare string is accepted for the list filters: `language="english"` becomes `["english"]`.

## Token and endpoint

The component calls `POST https://api.webz.io/api/news/context` and sends the token as a bearer header. `api_url` or `WEBZ_NEWS_SEARCH_URL` can replace that endpoint. A URL that is not HTTPS is rejected before the token is sent.

## Coverage

The News Search index is the last 30 days. Leave `days` unset to search that whole window, or set `days` to narrow it. See the [News Search API](https://docs.webz.io/docs/webz/news-search-api).
