Metadata-Version: 2.5
Name: searxng-serpapi
Version: 1.0.0
Summary: External SearXNG plugin for SerpAPI-backed Google web and image results
Project-URL: Homepage, https://github.com/veirt/searxng-serpapi
Project-URL: Repository, https://github.com/veirt/searxng-serpapi
Project-URL: Issues, https://github.com/veirt/searxng-serpapi/issues
Project-URL: SerpAPI, https://serpapi.com/search-api
Project-URL: SearXNG, https://docs.searxng.org/
Author-email: Veirt <veirt@duck.com>
License-Expression: AGPL-3.0-or-later
License-File: LICENSE
Keywords: plugin,search,searxng,serpapi
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Plugins
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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 :: 3.15
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# searxng-serpapi

An external [SearXNG](https://docs.searxng.org/) plugin that fetches Google web
and image results from [SerpAPI](https://serpapi.com/search-api). Useful when a
SearXNG instance cannot scrape Google directly because of IP blocks or
CAPTCHAs.

The plugin routes the `images` category to `google_images` and other categories
to `google`, and forwards pagination, time range, safe search, and locale
settings.

## Installation

Install from PyPI into the Python environment running SearXNG:

```bash
pip install searxng-serpapi
```

In a Docker image:

```dockerfile
FROM searxng/searxng:latest
RUN pip install searxng-serpapi
```

From a local checkout:

```bash
pip install .
```

To use the plugin without rebuilding a SearXNG container image, copy
`src/searxng_serpapi/` into a mounted directory such as
`/etc/searxng/searxng_serpapi/` and set `PYTHONPATH=/etc/searxng`. Do not place
this package inside `searx/engines`.

## Configuration

Enable the plugin under `plugins:` and put SerpAPI options under a top-level `serpapi:` block in `settings.yml`:

```yaml
use_default_settings: true

plugins:
  searxng_serpapi.plugin.SXNGPlugin:
    active: true

serpapi:
  api_key: "YOUR_SERPAPI_KEY_HERE"
  backend: auto
  timeout: 10.0
  safe_search: true
  # language: "en"
  # country: "us"
```

See [example-settings.yml](example-settings.yml) for a full example.

| Option | Default | Description |
| --- | --- | --- |
| `serpapi.api_key` | none | SerpAPI API key. |
| `SERPAPI_API_KEY` | none | Environment variable fallback for the SerpAPI API key. |
| `serpapi.backend` | `auto` | `auto`, `google`, or `google_images`. |
| `serpapi.timeout` | `10.0` | Request timeout in seconds. |
| `serpapi.safe_search` | `true` | Forward SearXNG safe search to SerpAPI. |
| `serpapi.language` | `""` | Fallback `hl` language code when the SearXNG query language is `all` or `auto`. |
| `serpapi.country` | `""` | Fallback two-letter ISO `gl` country code when the query locale has no region. |

Restart SearXNG after changing `settings.yml` or updating the package.

## Development

```bash
uv sync --frozen
uv run ruff format --check .
uv run ruff check .
uv run pyright
uv run pytest -v
```

## License

AGPL-3.0-or-later. See [LICENSE](LICENSE).
