Skip to content

SERP API

Query Bing or Google and receive structured { title, url, content } web-search results.

Endpoint

POST https://serpforai.dev/api/v1/search
GET  https://serpforai.dev/api/v1/search

Authentication is a bearer header carrying your API key:

Authorization: Bearer <userKey>

This page covers general web search (t: bing / t: google). For Google’s vertical search engines, see their dedicated pages: Google Images, Google Shopping, Google Videos, Google Short Videos and Google News.

Request parameters

POST requests send JSON; GET requests send the same fields as query parameters.

FieldTypeRequiredDefaultDescription
sstringyes-The search keyword
tstringnobingbing, google, or a Google vertical engine - see below
countrystringno-ISO 3166-1 alpha-2 country code, e.g. us
languagestringno-ISO 639-1 language code, e.g. en
pnumberno1Single-page override. Only sent when greater than 1
pagenumberno1Batch pagination (1..N) for pulling several result pages in one call. +1 credit per extra page
dnumberno5000Maximum time the API may spend, in milliseconds
htmlnumberno01 = include the raw result-page HTML, 0 = omit
knowledgeGraphbooleannofalset: google only - include the knowledge graph panel
peopleAlsoAskbooleannofalset: google only - include “People also ask”
aiSummarybooleannofalset: google only - include the AI-generated summary
newsAggregationbooleannofalset: google only - include the news carousel
videoAggregationbooleannofalset: google only - include the video carousel
peopleAlsoSearchForbooleannofalset: google only - include “People also search for”

The six t: google-only toggles are additive: enable only the panels your agent actually reads to keep the response small and the extraction fast.

Response

{
  "code": 0,
  "msg": "",
  "data": [
    { "title": "...", "url": "https://...", "content": "..." }
  ]
}
FieldDescription
code0 means success; anything else is a failure
msgHuman readable failure reason, empty on success
dataArray of { title, url, content } rows

Examples

import httpx

response = httpx.post(
    "https://serpforai.dev/api/v1/search",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"s": "agentic rag patterns", "t": "bing", "d": 20000, "p": 1},
    timeout=30,
)
payload = response.json()
for row in payload["data"]:
    print(row["title"], row["url"])
const response = await fetch('https://serpforai.dev/api/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SERPFORAI_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ s: 'agentic rag patterns', t: 'google', d: 20000, p: 1 }),
});
const payload = await response.json();

Choosing a latency budget

d is a hard ceiling, not a target. Interactive agents usually set d between 5000 and 8000 ms so a slow engine cannot stall a user-facing turn. Batch pipelines can raise it to 20000 ms to trade latency for recall.