Python SDK
The official Python SDK for Venym Search APIs. Type-safe, async-ready Python bindings.
Type Safe
Full type hints & Pydantic models
Async Ready
Built-in async/await support
Error Handling
Typed exceptions for every error
Installation
# Install from GitHub
pip install git+https://github.com/doctadg/VENYM_SEARCH-python.git
# Update to latest version
pip install --upgrade git+https://github.com/doctadg/VENYM_SEARCH-python.gitQuick Start
Get up and running with all three APIs in minutes.
from VENYM_SEARCH import Venym Search
# Initialize client with your API key
client = Venym Search(api_key="sk_live_64_HEX_CHARS_key_here")
# Search: Real-time web search
search_results = client.venym_search(
query="Bitcoin price 2025 predictions",
max_results=10,
auto_scrape_top=3
)
print(f"Found {search_results.results_count} results")
print(f"Credits used: {search_results.credits_used}")
# Access results
for result in search_results.search_results:
print(f"Title: {result.title}")
print(f"URL: {result.link}")
print(f"Snippet: {result.snippet}\n")
# Scrape: Extract content from URLs
scraped_data = client.scrape(
url="https://coindesk.com/price/bitcoin"
)
print(f"Page title: {scraped_data.title}")
print(f"Content length: {len(scraped_data.text)}")Client Configuration
from VENYM_SEARCH import Venym Search
# Basic configuration with API key
client = Venym Search(
api_key="sk_live_64_HEX_CHARS_key_here"
)
# Full configuration
client = Venym Search(
api_key="sk_live_64_HEX_CHARS_key_here",
base_url="https://www.search.venym.io/api/v1",
timeout=30,
)
# Environment-based configuration (recommended)
import os
client = Venym Search() # Reads VENYM_SEARCH_API_KEY env var
# Check API health
health = client.health()
print(f"API Status: {health}")Search API
Real-time web search with automatic content extraction and data enrichment.
# Search examples
results = client.venym_search(
query="AI startups funding 2025",
max_results=20,
auto_scrape_top=5,
include_contacts=True,
include_social=True,
)
print("Search Results:")
for result in results.search_results:
print(f"- {result.title} ({result.link})")
# Handle errors gracefully
try:
results = client.venym_search("test query")
except VenymSearchError as e:
print(f"API Error: {e}")
except RateLimitError as e:
print(f"Rate limited: {e}")
except AuthenticationError as e:
print(f"Auth error: {e}")Scrape API
Extract structured content from any URL, including JavaScript-rendered pages.
# Scrape examples
scraped = client.scrape(
url="https://news.ycombinator.com",
extract=["title", "text", "links", "images", "metadata"],
wait_for=".storylink",
use_browser=True,
timeout=30,
)
print(f"Title: {scraped.title}")
print(f"Text: {scraped.text[:500]}...")
print(f"Credits used: {scraped.credits_used}")
# Batch scraping multiple URLs
urls = [
"https://example.com/page1",
"https://example.com/page2",
"https://example.com/page3"
]
batch_results = client.batch_scrape(urls, timeout=15000)
for result in batch_results:
print(f"{result.url}: {result.title if not result.error else 'Failed: ' + result.error}")Async Support
High-performance async/await support for concurrent requests and better scalability.
import asyncio
from VENYM_SEARCH import AsyncVenym Search
async def main():
client = AsyncVenym Search(api_key="sk_live_64_HEX_CHARS_key_here")
try:
results = await client.venym_search("Python async tutorial")
print(f"Found {results.results_count} results")
search_task = asyncio.create_task(client.venym_search("AI news"))
scrape_task = asyncio.create_task(client.scrape("https://example.com"))
search_res, scrape_res = await asyncio.gather(
search_task, scrape_task
)
finally:
await client.close()
asyncio.run(main())Error Handling
from VENYM_SEARCH import Venym Search
from VENYM_SEARCH.exceptions import VenymSearchError, AuthenticationError, RateLimitError
client = Venym Search(api_key="sk_live_64_HEX_CHARS_key_here")
try:
results = client.venym_search("test query")
except AuthenticationError:
print("Invalid API key - check your credentials")
except RateLimitError as e:
print(f"Rate limited: {e}")
except VenymSearchError as e:
print(f"API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")Response Models
All response objects are Pydantic models with full type support. Use .model_dump() or .model_dump_json() for serialization.
# Response shapes
# SearchResponse
search_results = client.venym_search("test query")
print(search_results.query) # str
print(search_results.search_results) # list of results
print(search_results.credits_used) # int
print(search_results.remaining_credits) # int
# ScrapeResponse
scrape_result = client.scrape("https://example.com")
print(scrape_result.url) # str
print(scrape_result.title) # str
print(scrape_result.text) # str
print(scrape_result.credits_used) # int
# Convert to dict/JSON for storage
data_dict = search_results.model_dump()
json_str = search_results.model_dump_json()Configuration Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
| api_key | str | VENYM_SEARCH_API_KEY env var | Your Venym Search API key |
| base_url | str | https://www.search.venym.io/api/v1 | API base URL |
| timeout | int | 30 | Request timeout in seconds |
Best Practices
Use environment variables for API keys
Store your API key in VENYM_SEARCH_API_KEY environment variable instead of hardcoding
Monitor credit usage
Check remaining_credits in responses and set up alerts before running out
Use async for high-throughput applications
AsyncVenym Search with async with context manager for concurrent requests