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.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
s | string | yes | - | The search keyword |
t | string | no | bing | bing, google, or a Google vertical engine - see below |
country | string | no | - | ISO 3166-1 alpha-2 country code, e.g. us |
language | string | no | - | ISO 639-1 language code, e.g. en |
p | number | no | 1 | Single-page override. Only sent when greater than 1 |
page | number | no | 1 | Batch pagination (1..N) for pulling several result pages in one call. +1 credit per extra page |
d | number | no | 5000 | Maximum time the API may spend, in milliseconds |
html | number | no | 0 | 1 = include the raw result-page HTML, 0 = omit |
knowledgeGraph | boolean | no | false | t: google only - include the knowledge graph panel |
peopleAlsoAsk | boolean | no | false | t: google only - include “People also ask” |
aiSummary | boolean | no | false | t: google only - include the AI-generated summary |
newsAggregation | boolean | no | false | t: google only - include the news carousel |
videoAggregation | boolean | no | false | t: google only - include the video carousel |
peopleAlsoSearchFor | boolean | no | false | t: 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": "..." }
]
}
| Field | Description |
|---|---|
code | 0 means success; anything else is a failure |
msg | Human readable failure reason, empty on success |
data | Array 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.