Letter S Streamline Icon: https://streamlinehq.comserpex
Pricing
Docs
Sign InGet Started

Documentation

Quick Start
GoogleBingDuckDuckGoBraveYahooYandexAuto Route
Web Scraping
TypeScriptPython
Rate Limits & Cost
Letter S Streamline Icon: https://streamlinehq.comSerpex

The fast, affordable search API for AI & data projects.

Product

  • Playground
  • Dashboard
  • Google search API
  • Bing Search API
  • Brave Search API
  • DuckDuckGo Search API

Legal

  • Terms
  • Privacy
  • Data Processing Agreement
  • GDPR
  • SLA

Resources

  • Status page
  • Blog
  • Docs
  • Support

© 2025 Serper.dev. All rights reserved.

Building the future of AI data

Back to Documentation

Python SDK

pip

Official Python SDK for the Serpex SERP API. Fetch search results in JSON format with full Python support.

Installation

pip

pip install serpex

poetry

poetry add serpex

Requirements

  • • Python 3.8+
  • • requests library

Quick Start

Get started with the Serpex Python SDK in just a few lines of code.

from serpex import SerpexClient

# Initialize the client with your API key
client = SerpexClient('your-api-key-here')

# Web search with Google
results = client.search({
    'q': 'python tutorial',
    'engine': 'google',
    'category': 'web',
    'time_range': 'week'  # Only for web search
})

# News search - always returns latest news
news_results = client.search({
    'q': 'artificial intelligence',
    'engine': 'google',
    'category': 'news'  # Always returns latest news
})

print(results.results[0].title)
print(news_results.results[0].published_date)

API Reference

SerpexClient Constructor

SerpexClient(api_key: str, base_url: str = "https://api.serpex.dev")
  • api_key - Your API key from the Serpex dashboard
  • base_url - Optional base URL (defaults to production API)

search() Method

# Using dictionary (simple approach)
results = client.search({
    'q': 'javascript frameworks',
    'engine': 'brave',
    'category': 'search',
    'country': 'US'
})

# Using SearchParams object (type-safe approach)
from serpex_sdk import SearchParams

params = SearchParams(
    q='javascript frameworks',
    engine='brave',
    category='search',
    country='US'
)
results = client.search(params)

Search Parameters

ParameterTypeRequiredDescription
qstrYesSearch query
enginestrYesSearch engine (auto, google, bing, duckduckgo, brave, yahoo, yandex)
categorystrNoSearch category (web, news). News always returns latest articles.
time_rangestrNoTime range filter (day, week, month, year). Only for web search, ignored for news.

Response Format

@dataclass
class SearchResponse:
    metadata: SearchMetadata
    id: str
    query: str
    engines: List[str]
    results: List[SearchResult]
    answers: List[Any]
    corrections: List[str]
    infoboxes: List[Any]
    suggestions: List[str]

Error Handling

from serpex import SerpexClient, SerpApiException

try:
    results = client.search({'q': 'test query', 'engine': 'google'})
except SerpApiException as e:
    print(f"API error: {e}")
    print(f"Status code: {e.status_code}")
    print(f"Details: {e.details}")