Web search plugin for twat
Project description
this_file: README.md
twat-search 2.0
twat-search is the search layer for the twat toolchain: one Python package
and CLI for API search, browser search, scraper search, LLM-assisted search,
metasearch, enrichment, deduplication, and evidence capture.
Version 2.0 treats search as a routing problem. A query can fan out through official APIs, unofficial endpoints, browser automation, direct HTML scrapers, and LLM research providers, then return one normalized result stream with source provenance, ranking metadata, raw payloads, and reproducible diagnostics.
Install
uv pip install "twat-search[all]"
For local development:
uv sync --all-extras
uvx hatch test
CLI
twat-search web q "Adam Twardoch" -e brave,serpapi,duckduckgo -n 5 --json
twat-search web info --plain
twat search web q "font engineering news" --route resilient --json
The twat host package exposes this plugin as twat search.
Python API
import asyncio
from twat_search.web.api import search, search_detailed
async def main() -> None:
results = await search(
"best current browser automation anti-bot patterns",
engines=["brave", "google_serpapi", "duckduckgo"],
num_results=5,
)
for result in results:
print(result.source, result.title, result.url)
detailed = await search_detailed("same query", route="resilient")
for failure in detailed.failures:
print(failure.engine, failure.kind, failure.message)
asyncio.run(main())
Engines
2.0 supports four backend families:
- API engines: Brave, Brave News, SerpAPI, HasData, Tavily, You.com, You.com News, Perplexity, Critique, Google CSE, Serper, DataForSEO, Exa, Firecrawl, Jina, Search1API, Gensearch, and other configured providers.
- Scraper engines: DuckDuckGo, Google, Bing, qbittorrent-style plugin scrapers, GitHub/code search providers, and specialized dork engines.
- Browser engines: Playwright-controlled Google, Bing, Qwant, Yahoo, Yandex, Mojeek, Gibiru, and future browser-to-API adapters.
- LLM engines: user-selected OpenAI-compatible models for query planning, reranking, source critique, summary extraction, and answer synthesis.
Engines are independent adapters behind a common SearchEngine contract. A
failure in one adapter is reported as data and does not poison the whole run.
Configuration
Configuration is loaded from .env, environment variables, optional JSON
config, and explicit Python arguments. API keys are discovered from provider
specific names when possible.
Key providers already visible in /Users/adam/.env.anon.txt and targeted for
2.0 integration include:
BRAVE_API_KEYSERPAPI_API_KEYTAVILY_API_KEYHASDATA_API_KEYGOOGLE_CSE_API_KEYandGOOGLE_CSE_IDDATAFORSEO_API_KEYSERPER_API_KEYEXAAI_API_KEYFIRECRAWL_API_KEYJINA_API_KEYGENSEE_SEARCH_API_KEYSEARCH1API_KEYAISEARCH_API_KEYAPIFY_API_KEYBRIGHTDATA_API_KEY,DECODO_API_KEY, and Webshare proxy variables
Rotating Proxies
twat-search understands Webshare-style rotating proxy variables:
export WEBSHARE_PROXY_USER="user"
export WEBSHARE_PROXY_PASS="pass"
export WEBSHARE_DOMAIN_NAME="p.webshare.io"
export WEBSHARE_PROXY_PORT="80"
When configured, HTTP and browser engines can use the proxy URL for resilient scraping, relaxed pacing, and parallel browser sessions. Proxy use is explicit per route or engine so API-backed searches remain clean by default.
LLM Routing
LLM use is provider-neutral. Any OpenAI-compatible endpoint can be selected for query rewriting, provider choice, result reranking, or synthesis:
export TWAT_SEARCH_LLM_PROVIDER="openai-compatible"
export TWAT_SEARCH_LLM_MODEL="gpt-5-mini"
export TWAT_SEARCH_LLM_API_KEY="$OPENAI_API_KEY"
export TWAT_SEARCH_LLM_BASE_URL="https://api.openai.com/v1"
The package stores LLM decisions as provenance, not hidden magic. A result set can show whether a title/snippet came from the source, an extractor, or a model.
Result Model
Every result carries:
- normalized
title,url,snippet,source, andrank - optional raw provider payload
- detailed
SearchResponsedata with the parsedSearchRequest, per-engineEngineOutcomerecords, and structuredSearchFailureobjects - future engine timing, proxy, and route metadata
- future content artifacts such as fetched HTML, extracted text, screenshots, citations, and LLM summaries
Reference Integrations
The 2.0 design borrows from the local private/ reference projects instead of
adding dependencies blindly:
private/ytrix: Webshare proxy URL construction, proxy-aware pacing, and parallelism decisions.private/crapi: browser lifecycle, stealth, browser-to-API, and proxy manager patterns.private/abersetz: OpenAI-compatible provider catalog and local/offline LLM selection patterns.private/flchimp: explicit validation, dirty-data handling, and operational CLI ergonomics.private/TO_INTEGRATE.md: external search project ideas including plugin search, deep search, GitHub search, dorks, and open deep research.
Development Contract
2.0 is allowed to break compatibility with the current 0.x code. The priority is a smaller, typed, testable core:
- clean engine registry
- strict provider capability metadata
- explicit proxy and browser configuration
- normalized result and error data
- no obsolete Falla-specific mess in the public API
- tests for each adapter boundary before live provider tests
Run the normal check before handing off changes:
uvx hatch test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twat_search-2.7.12.tar.gz.
File metadata
- Download URL: twat_search-2.7.12.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
192df027efd96870a81a6ca54d44be68f85099d8786ffb8996bea7fb48b2b614
|
|
| MD5 |
064c5853739ee4a1588c41abb622df45
|
|
| BLAKE2b-256 |
a9b134da81a09710c5aaf0c73a329abfb29c4c1a6d1e71351353f5001e2b72f1
|
File details
Details for the file twat_search-2.7.12-py3-none-any.whl.
File metadata
- Download URL: twat_search-2.7.12-py3-none-any.whl
- Upload date:
- Size: 122.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c854defd8eaa55d3882c7bec3961a65844daf12796b24614872ce09319d80c33
|
|
| MD5 |
c9b5982d7b1a26953b86c25c5de1ac9d
|
|
| BLAKE2b-256 |
cc7f841c35b8b36b6028815ccfdfeed7c8f12a1cd012c5438f22319f245a2491
|