SERPHouseSERPHouse

Python SDK

Official SERPHouse Python SDK for integrating SERP search into any Python application.

The official Python SDK makes it easy to integrate the SERPHouse API into any Python application.

Instead of manually creating HTTP requests, the SDK handles authentication, request formatting, and response parsing so you can focus on building your application.

The SDK provides access to Google SERP, Google News, and Google Short Videos directly through a simple typed client.

Requirements

  • Python 3.10+
  • pip

Installation

pip install serphouse-ai-sdk

Get Your API Key

Create a SERPHouse account and generate an API key from your dashboard.

Initialize the Client

from serphouse import SERPHouseClient

client = SERPHouseClient(api_key="YOUR_API_KEY")

Using environment variables is recommended. Never hardcode your API key in source code.

The SDK reads the SERPHOUSE_API_KEY environment variable automatically, so the api_key argument is optional when it is set:

export SERPHOUSE_API_KEY=your_api_key
from serphouse import SERPHouseClient

client = SERPHouseClient()

Quick Start

from serphouse import SERPHouseClient

client = SERPHouseClient()

result = client.post("/web-search-lite", {
    "q": "Coffee",
    "gl": "US",
    "device": "desktop",
    "num_result": 10,
})

print(result)

Available Endpoints

The client exposes get and post methods for the SERPHouse API.

EndpointDescription
POST /web-search-liteGoogle organic web search
POST /google-newsGoogle News search
POST /google-short-videos-apiGoogle Short Videos (Shorts)

Search the web with optional location and language targeting.

result = client.post("/web-search-lite", {
    "q": "coffee shops",
    "domain": "google.com",
    "lang": "en",
    "loc": "Austin,Texas,United States",
    "device": "desktop",
    "page": 1,
})

You can target a country directly with the gl parameter (ISO 3166-1 alpha-2) instead of loc.

result = client.post("/web-search-lite", {
    "q": "coffee shops",
    "gl": "US",
})

Google News

result = client.post("/google-news", {
    "q": "artificial intelligence",
    "date_range": "w",
    "device": "desktop",
})

Google Short Videos

result = client.post("/google-short-videos-api", {
    "q": "cooking recipes",
    "video_quality": "high",
})

Request Parameters

ParameterTypeDefaultDescription
qstrSearch query (required)
domainstrgoogle.comSearch domain
langstrenLanguage code
locstrNew York,New York,United StatesLocation in City,State,Country format
glstrUSCountry code (web search only)
devicestrdesktopdesktop or mobile
pageintPage number
date_rangestryh, d, w, m, y, or YYYY-MM-DD,YYYY-MM-DD
num_resultintNumber of results (1–10)

Error Handling

Always handle errors

Network issues, invalid API keys, and rate limits can all cause requests to fail. Always wrap calls in try-catch.

from serphouse import SERPHouseClient, ApiError

client = SERPHouseClient()

try:
    result = client.post("/web-search-lite", {
        "q": "Coffee",
    })
    print(result)
except ApiError as error:
    print(f"Request failed with status {error.status}: {error}")

The SDK raises ApiError with a status code and body payload for any non-success response.

Complete Example

import os

from serphouse import SERPHouseClient

client = SERPHouseClient()

def main():
    results = client.post("/web-search-lite", {
        "q": "Coffee",
        "domain": "google.com",
        "lang": "en",
        "device": "desktop",
        "gl": "US",
        "num_result": 10,
    })

    print(results)

if __name__ == "__main__":
    main()

Support

If you encounter any issues while installing, configuring, or using the SERPHouse Python SDK, we're here to help.

  • Contact the SERPHouse support team at [email protected] for assistance.
  • Report bugs or request features by opening an issue on the GitHub repository.

Last updated on

How is this guide?

On this page