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.3.tar.gz (343.8 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.3-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: twat_search-2.0.3.tar.gz
  • Upload date:
  • Size: 343.8 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.3.tar.gz
Algorithm Hash digest
SHA256 bec783278b624e6cebda929e9d6178f9b48b717b18652d9e1703859388c7240e
MD5 079bd68605418aba2af331237d9a37fd
BLAKE2b-256 5cd5567d78c87375e8cc2e6b4139477f938e2618e97791c95f486d94d1173a4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: twat_search-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 42.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b6f9c958558bf1cbd4cc997c6eca264d1cdb3afc164df96d75b5c255dcd16c
MD5 9bf162fbed7131d30561a2dde6f4066a
BLAKE2b-256 f09b442079192f3b0982060ecbf0c9e38cb8d1c72bea106ede86417a249833cb

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