Skip to content

Searchly

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this month Package status PyUp

Read the documentation!

Searchly gives AI agents (and anyone else) one async interface to many web and news search APIs. Every provider returns the same pydantic result models, so switching from Serper to Tavily or Brave is a one-line change.

Installation

pip install searchly
# optional SDK-based providers
pip install "searchly[exa]"                         # Exa
pip install "searchly[brave_search_python_client]"  # Brave
pip install "searchly[all]"

Requires Python 3.13+.

Quickstart

import asyncio

from searchly import AsyncSerperClient


async def main() -> None:
    client = AsyncSerperClient()  # reads SERPER_API_KEY, or pass api_key="..."
    response = await client.web_search("python asyncio tutorial", max_results=5, country="US")
    for result in response.results:
        print(result.title, result.url)

    news = await client.news_search("open source AI", max_results=3)
    for item in news.results:
        print(item.published, item.source, item.title)


asyncio.run(main())

Configuration-driven providers

searchly_config holds lightweight pydantic configs (a discriminated union on type) that create providers lazily, which makes search backends easy to put into YAML/JSON settings:

from pydantic import TypeAdapter

from searchly import WebSearchProviderConfig

config = TypeAdapter(WebSearchProviderConfig).validate_python({"type": "tavily"})
if config.is_configured():  # api_key field or TAVILY_API_KEY env var
    provider = config.get_provider()

The anyenv-based clients (DataForSEO, JigsawStack, Kagi, LinkUp, Search1API, SerpAPI, Serper, You.com) keep one HTTP connection per instance (per event loop); close it with await provider.aclose() or use the provider as async with provider: ....

Providers

Provider Client Web News API key env var
Brave AsyncBraveSearch yes yes BRAVE_API_KEY
DataForSEO AsyncDataForSEOClient yes yes DATAFORSEO_LOGIN, DATAFORSEO_PASSWORD
Exa AsyncExaClient yes EXA_API_KEY
JigsawStack AsyncJigsawStackClient yes JIGSAWSTACK_API_KEY
Kagi AsyncKagiClient yes KAGI_API_KEY
LinkUp AsyncLinkUpClient yes LINKUP_API_KEY
Search1API AsyncSearch1API yes SEARCH1API_KEY
SerpAPI AsyncSerpAPIClient yes yes SERPAPI_KEY
Serper AsyncSerperClient yes yes SERPER_API_KEY
Tavily AsyncTavilyClient yes yes TAVILY_API_KEY
You.com AsyncYouClient yes yes YOU_API_KEY

Features

  • Common protocols: WebSearchProvider.web_search() and NewsSearchProvider.news_search() with shared query, max_results, country and language arguments; provider-specific options are extra keyword arguments.
  • Unified results: WebSearchResponse / NewsSearchResponse with WebSearchResult (title, url, snippet) and NewsSearchResult (adds source, published).
  • Typed: CountryCode and LanguageCode literals, full type hints, py.typed.
  • Config models: WebSearchProviderConfig, NewsSearchProviderConfig, get_config_class() for building providers from settings, with secrets stored as SecretStr.