Skip to main content

Advanced search utilities and tools for the twat ecosystem

Project description

twat-search

A powerful Python web search aggregator that combines results from multiple search engines.

Features

  • Multi-Engine Search: Unified interface for searching across multiple providers:
    • Brave Search
    • Google Search
    • Tavily Research
    • Perplexity
    • You.com
  • Async Support: Concurrent searches across engines
  • Rate Limiting: Built-in rate limiting per search engine
  • Type Safety: Full type annotations and runtime validation
  • Error Handling: Robust error handling and fallbacks
  • Configuration: Flexible configuration via environment variables or code

Installation

pip install twat-search

Quick Start

from twat_search.web import WebSearch

# Initialize with default configuration
search = WebSearch()

# Search across all configured engines
results = await search.q("Python async programming")

# Print results
for result in results:
  print(f"{result.title} ({result.source})")
  print(f"URL: {result.url}")
  print(f"Snippet: {result.snippet}\n")

Configuration

Configure search engines via environment variables:

# API Keys
BRAVE_API_KEY=...
GOOGLE_API_KEY=...
TAVILY_API_KEY=...
PERPLEXITY_API_KEY=...
YOU_API_KEY=...

# Engine-specific settings
BRAVE_ENABLED=true
GOOGLE_ENABLED=true
TAVILY_ENABLED=true
PERPLEXITY_ENABLED=true
YOU_ENABLED=true

Or programmatically:

from twat_search.web import WebSearch, Config

config = Config(
    brave_api_key="...",
    google_enabled=True,
    tavily_enabled=False
)

search = WebSearch(config)

Response Format

Search results are returned as SearchResult objects:

@dataclass
class SearchResult:
    title: str           # Result title
    url: HttpUrl        # Validated URL
    snippet: str        # Text snippet/description  
    source: str         # Source search engine

Error Handling

The package provides custom exception classes:

  • SearchError: Base exception class
  • EngineError: Engine-specific errors
  • ConfigError: Configuration errors

Development Status

Version: 1.8.1

See TODO.md for planned improvements and feature roadmap.

Contributing

Contributions welcome! Please check TODO.md for areas that need work.

License

MIT License - See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twat_search-2.0.2.tar.gz (304.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twat_search-2.0.2-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file twat_search-2.0.2.tar.gz.

File metadata

  • Download URL: twat_search-2.0.2.tar.gz
  • Upload date:
  • Size: 304.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for twat_search-2.0.2.tar.gz
Algorithm Hash digest
SHA256 d8065cfebd8ee8eb541e91f059fb2b89d7f513be948bcfec2590a82fd12a0ae7
MD5 12e5578fb55d315da1835d0afaa72947
BLAKE2b-256 4155b1169c5581f76c69b2ceba1a509ebdd6880f590feaff2e21041b15db4f14

See more details on using hashes here.

File details

Details for the file twat_search-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: twat_search-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for twat_search-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2b325ecbfbfe783e749cfc3c1a42052154acedfd395622f4bf49526661c6e2df
MD5 668e6b99634aeeee72d5919b52aefa65
BLAKE2b-256 f2aeb95353f0d3a9f1ffe2b041b8f1068f128298eab4bac5c0e1e3cf894c322d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page