Serpent API Documentation

Complete guide to integrating search results into your application.

Getting Started

Serpent API provides programmatic access to search results from Google and Yahoo. It supports five types of search:

  • Web Search — Up to 100 organic results with related searches and ads
  • Quick Search — Fast single-page web search (~7-10 results)
  • News Search — News articles with sources, timestamps, and thumbnails
  • Image Search — Images with thumbnails, originals, dimensions, and sources
  • Video Search — Videos with duration, publisher, and descriptions

Quick Start

  1. Create an accountSign up with your Google account (free)
  2. Generate an API key — Go to the API Keys page and create a key
  3. Make your first request — Use your API key to search
curl "https://apiserpent.com/api/search?q=hello+world&api_key=YOUR_KEY"

You get 100 free searches to try the API. No credit card required.

Base URL

All API requests use the following base URL:

https://apiserpent.com

All endpoints are relative to this base. For example, the web search endpoint is:

https://apiserpent.com/api/search

Authentication

All search endpoints require an API key. You can authenticate in two ways:

Option 1: HTTP Header (Recommended)

X-API-Key: sk_live_your_api_key_here

Option 2: Query Parameter

GET /api/search?q=keyword&api_key=sk_live_your_api_key_here
Keep your API key secret. Never expose it in client-side code or public repositories. The header method is strongly preferred for security — query parameters may appear in server logs and browser history.
Credit cost: Each API call costs 1 credit ($0.10 per search at Standard tier, $0.06 per search at Volume tier). New accounts receive 100 free searches — no credit card required.

Web Search API

Perform a web search that returns up to 100 organic results with related searches, ads, and more. For more than 10 results, the API automatically scrapes multiple pages.

GET /api/search

Parameters

ParameterTypeDescription
q required string The search query
num integer Number of results: 10–100 (default: 10). Automatically determines pages to scrape. Rounded up to the nearest 10 (e.g., num=15 returns up to 20).
engine string google or yahoo (default: "google")
country string Country code for localized results (default: "us"). See Country Support.
format string Response format: full or simple (default: "full"). Simple returns just position, title, and URL.
pages integer Number of pages to scrape: 1–10 (default: 1). Alternative to num.
Use num or pages, not both. If you pass num=50, the API will automatically scrape 5 pages. Each page yields ~10 results.

Example Request

curl "https://apiserpent.com/api/search?q=best+seo+tools&num=30&engine=google&country=us" \
  -H "X-API-Key: sk_live_your_api_key"

Example Response

{
  "success": true,
  "query": "best seo tools",
  "engine": "google",
  "country": "us",
  "pagesScraped": 3,
  "results": {
    "organic": [
      {
        "position": 1,
        "title": "10 Best SEO Tools for 2025",
        "url": "https://example.com/seo-tools",
        "snippet": "Discover the top SEO tools...",
        "displayedUrl": "example.com"
      }
    ],
    "relatedSearches": [{ "query": "free seo tools" }, { "query": "seo tools for beginners" }],
    "ads": { "top": [], "bottom": [], "totalCount": 0 },
    "peopleAlsoAsk": [],
    "richSnippets": []
  },
  "meta": {
    "totalOrganic": 30,
    "requestedNum": 30,
    "elapsed": "3200ms",
    "timestamp": "2025-01-15T10:30:00.000Z"
  }
}

News Search API

Search for news articles from various sources. Returns article titles, sources, publication times, snippets, and thumbnails.

GET /api/news

Parameters

ParameterTypeDescription
q required string The search query
num integer Number of articles: 1–50 (default: all available)
pages integer Number of pages to scrape: 1–5 (default: 1). Alternative to num.
engine string google or yahoo (default: "google")
country string Country code for localized news (default: "us")
freshness string Time filter: day, week, or month (optional)

Example Request

curl "https://apiserpent.com/api/news?q=artificial+intelligence&num=20&country=us" \
  -H "X-API-Key: sk_live_your_api_key"

Example Response

{
  "success": true,
  "query": "artificial intelligence",
  "type": "news",
  "engine": "google",
  "country": "us",
  "pagesScraped": 2,
  "results": {
    "articles": [
      {
        "position": 1,
        "title": "AI Breakthroughs Reshape Industry",
        "url": "https://example.com/ai-news",
        "source": "Tech News Daily",
        "publishedTime": "2 hours ago",
        "snippet": "Major advances in AI...",
        "thumbnail": "https://..."
      }
    ],
    "totalResults": 20
  },
  "meta": {
    "totalArticles": 20,
    "elapsed": "1800ms",
    "timestamp": "2025-01-15T10:30:00.000Z"
  }
}

Image Search API

Search for images across the web. Returns thumbnails, original image URLs, dimensions, and source websites. A single request can return up to 100 images.

GET /api/images

Parameters

ParameterTypeDescription
q required string The search query
num integer Number of results: 1–100 (default: all available)
engine string google or yahoo (default: "google")
country string Country code for localized results (default: "us")
size string Filter by image size (optional)
type string Filter by image type (optional)

Example Request

curl "https://apiserpent.com/api/images?q=mountain+landscape&num=20&engine=google" \
  -H "X-API-Key: sk_live_your_api_key"

Example Response

{
  "success": true,
  "query": "mountain landscape",
  "type": "images",
  "engine": "google",
  "country": "us",
  "results": {
    "images": [
      {
        "position": 1,
        "title": "Beautiful Mountain View",
        "thumbnail": "https://tse.mm.bing.net/th/...",
        "original": "https://example.com/image.jpg",
        "width": 1920,
        "height": 1080,
        "source": "example.com",
        "pageUrl": "https://example.com/gallery"
      }
    ],
    "totalResults": 20
  },
  "meta": {
    "totalImages": 20,
    "elapsed": "2100ms",
    "timestamp": "2025-01-15T10:30:00.000Z"
  }
}

Video Search API

Search for videos across the web. Returns video titles, URLs, thumbnails, duration, publisher info, and descriptions.

Note: Video search requires the dedicated API server. The Cloud Functions deployment (apiserpent.com) returns 501 Not Implemented for this endpoint. Video search is available when using the direct API server.
GET /api/videos

Parameters

ParameterTypeDescription
q required string The search query
num integer Number of results: 1–50 (default: 20)
engine string google or yahoo (default: "google")
country string Country code for localized results (default: "us")

Example Request

curl "https://apiserpent.com/api/videos?q=javascript+tutorial&num=10&engine=yahoo" \
  -H "X-API-Key: sk_live_your_api_key"

Example Response

{
  "success": true,
  "query": "javascript tutorial",
  "type": "videos",
  "engine": "yahoo",
  "country": "us",
  "results": {
    "videos": [
      {
        "position": 1,
        "title": "Learn JavaScript - Full Course",
        "url": "https://www.youtube.com/watch?v=...",
        "description": "Complete JavaScript tutorial...",
        "publisher": "freeCodeCamp.org",
        "duration": "3:26:43",
        "publishedTime": "2024-01-15T10:00:00.000Z"
      }
    ],
    "totalResults": 10
  },
  "meta": {
    "totalVideos": 10,
    "elapsed": "2500ms",
    "timestamp": "2025-01-15T10:30:00.000Z"
  }
}

Search Engines

Serpent API supports two search engines. Pass the engine parameter on any endpoint to select which one to use.

EngineValueDescription
Google google Default engine. Returns results from Google's search index. Supports all 5 search types.
Yahoo yahoo Returns results directly from Yahoo Search. Supports all 5 search types. Yahoo web search returns ~7 results per page (vs ~10 for Google).
Both engines cost the same per search. Choose based on which search index better suits your use case. The engine field is always returned in the response so you know which engine served the results.

Country/Region Support

Get localized search results by specifying a country code. This affects the language, regional rankings, and availability of results.

GET /api/countries

Returns a list of all supported country codes programmatically. This endpoint does not require an API key.

Example Response

{
  "success": true,
  "count": 37,
  "countries": [
    { "code": "us", "region": "en-us" },
    { "code": "uk", "region": "en-gb" },
    ...
  ]
}

Supported Countries

We support 35+ countries for localized search results.

Popular Countries

CodeCountryCodeCountry
usUnited StatesukUnited Kingdom
caCanadaauAustralia
deGermanyfrFrance
inIndiajpJapan
View All 35+ Supported Countries

English-Speaking

CodeCountryCodeCountry
usUnited StatesukUnited Kingdom
caCanadaauAustralia
nzNew ZealandieIreland
sgSingaporephPhilippines
myMalaysiainIndia

Europe

CodeCountryCodeCountry
deGermanyfrFrance
esSpainitItaly
nlNetherlandsbeBelgium
atAustriachSwitzerland
seSwedennoNorway
dkDenmarkfiFinland
plPolandroRomania

Asia

CodeCountryCodeCountry
jpJapantwTaiwan
hkHong KongidIndonesia
thThailandvnVietnam

Latin America

CodeCountryCodeCountry
mxMexicobrBrazil
arArgentinaclChile
coColombiapePeru
veVenezuela

Example: Search in Germany

curl "https://apiserpent.com/api/search?q=beste+seo+tools&country=de" \
  -H "X-API-Key: sk_live_your_api_key"

Check Status

Check your API key status, credit balance, free search usage, and pricing tier.

GET /api/status

Example Response

{
  "success": true,
  "data": {
    "plan": "paid",
    "credits": 45.50,
    "costPerSearch": 0.0001,
    "priceTier": "default",
    "freeSearches": {
      "used": 87,
      "limit": 100,
      "remaining": 13
    }
  }
}

Response Format

All responses are JSON. Every response includes a success boolean. Search responses include engine, country, and a meta object with timing info.

Full Response (Web Search)

The default format=full response includes all available data:

{
  "success": true,
  "query": "best seo tools",
  "engine": "google",
  "country": "us",
  "pagesScraped": 5,
  "results": {
    "organic": [{ "position", "title", "url", "snippet", "displayedUrl" }],
    "relatedSearches": [{ "query": "free seo tools" }, ...],
    "ads": { "top": [], "bottom": [], "totalCount": 0 },
    "peopleAlsoAsk": [],
    "richSnippets": []
  },
  "meta": { "totalOrganic", "requestedNum", "elapsed", "timestamp" }
}

Simple Response

Use format=simple for a lightweight response with just titles and URLs (web search only):

{
  "success": true,
  "query": "best seo tools",
  "engine": "google",
  "country": "us",
  "results": [
    { "position": 1, "title": "...", "url": "..." }
  ],
  "meta": { "total": 50, "requestedNum": 50, "elapsed": "2450ms" }
}

Error Codes

All error responses include an error field with a human-readable message.

CodeMeaningDescription
400 Bad Request Missing or invalid parameters (e.g., no q param, invalid engine)
401 Unauthorized Invalid or missing API key
402 Payment Required Insufficient credits. Free searches exhausted and no credit balance.
404 Not Found Endpoint does not exist
429 Too Many Requests Rate limit exceeded (100 requests/minute per IP)
500 Server Error Internal error — try again or contact support
502 Bad Gateway Search backend returned no results. Retry with a different query or engine.

Error Response Example

{
  "error": "Query parameter \"q\" is required"
}

Rate Limits

LimitValue
Requests per minute (per IP)100
Daily limitNone (pay per use)
Concurrent requestsNo hard limit

Typical Response Times

EndpointTypical Speed
Quick search (/api/search/quick)1–3 seconds
Web search (/api/search, 10 results)2–4 seconds
Web search (50–100 results)5–15 seconds
News search2–4 seconds
Image search2–4 seconds
Video search2–4 seconds

Code Examples

JavaScript / Node.js

const API_KEY = 'sk_live_your_api_key';
const BASE = 'https://apiserpent.com';

// Web search with 30 results from Yahoo
async function webSearch(query, options = {}) {
  const params = new URLSearchParams({
    q: query,
    num: options.num || 10,
    engine: options.engine || 'google',
    country: options.country || 'us',
  });

  const res = await fetch(`${BASE}/api/search?${params}`, {
    headers: { 'X-API-Key': API_KEY }
  });

  const data = await res.json();
  if (!data.success) throw new Error(data.error);
  return data.results.organic;
}

// News search
async function newsSearch(query) {
  const res = await fetch(
    `${BASE}/api/news?q=${encodeURIComponent(query)}&num=20`,
    { headers: { 'X-API-Key': API_KEY } }
  );
  return (await res.json()).results.articles;
}

// Usage
const results = await webSearch('best seo tools', { num: 30, engine: 'yahoo' });
const news = await newsSearch('artificial intelligence');

Python

import requests

API_KEY = 'sk_live_your_api_key'
BASE = 'https://apiserpent.com'
HEADERS = {'X-API-Key': API_KEY}

# Web search
def web_search(query, num=10, engine='google', country='us'):
    resp = requests.get(f'{BASE}/api/search', headers=HEADERS,
        params={'q': query, 'num': num, 'engine': engine, 'country': country})
    data = resp.json()
    if not data.get('success'):
        raise Exception(data.get('error', 'Search failed'))
    return data['results']['organic']

# News search
def news_search(query, num=20):
    resp = requests.get(f'{BASE}/api/news', headers=HEADERS,
        params={'q': query, 'num': num})
    return resp.json()['results']['articles']

# Image search
def image_search(query, num=50):
    resp = requests.get(f'{BASE}/api/images', headers=HEADERS,
        params={'q': query, 'num': num})
    return resp.json()['results']['images']

# Usage
results = web_search('best seo tools', num=50, engine='yahoo')
news = news_search('AI breakthroughs')
images = image_search('sunset beach')

cURL

# Web search (30 results from Yahoo in Germany)
curl "https://apiserpent.com/api/search?q=beste+seo+tools&num=30&engine=yahoo&country=de" \
  -H "X-API-Key: sk_live_your_api_key"

# Quick search
curl "https://apiserpent.com/api/search/quick?q=weather+today" \
  -H "X-API-Key: sk_live_your_api_key"

# News search
curl "https://apiserpent.com/api/news?q=technology&num=20&freshness=week" \
  -H "X-API-Key: sk_live_your_api_key"

# Image search
curl "https://apiserpent.com/api/images?q=mountain+landscape&num=50" \
  -H "X-API-Key: sk_live_your_api_key"

# Video search
curl "https://apiserpent.com/api/videos?q=javascript+tutorial&num=10" \
  -H "X-API-Key: sk_live_your_api_key"

# Check credits
curl "https://apiserpent.com/api/status" \
  -H "X-API-Key: sk_live_your_api_key"