Integrations
BestSERP is a plain HTTPS API: any language or tool that can send a POST request with a JSON body and an X-API-KEY header can use it. Copy a complete example for cURL, PHP or Go below, or follow a guide for Python, Node.js, LangChain agents and n8n workflows.
Last updated:
cURL
From any terminal. Replace YOUR_API_KEY with a key from the dashboard.
curl -X POST 'https://api.bestserp.com/search' \
-H 'X-API-KEY: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"q":"best running shoes","gl":"us","hl":"en"}'PHP
With the curl extension, available in standard PHP builds.
<?php
$ch = curl_init('https://api.bestserp.com/search');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 130,
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'q' => 'best running shoes',
'gl' => 'us',
'hl' => 'en',
]),
]);
echo curl_exec($ch);Go
Standard library only (net/http).
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{"q":"best running shoes","gl":"us","hl":"en"}`)
req, _ := http.NewRequest("POST", "https://api.bestserp.com/search", body)
req.Header.Set("X-API-KEY", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}Status codes to handle
Every language gets the same answers. 202 means the search is still running: poll GET /requests/{requestId}.
| Status | Code | Meaning | Credits |
|---|---|---|---|
| 202 | - | Not finished within timeout (or async: true). Poll pollUrl. | Reserved |
| 400 | invalid_request | Malformed body or a parameter out of range. | No |
| 400 | unknown_parameter | A field the API does not know (typo?). | No |
| 400 | unsupported_parameter | A known field that this endpoint does not support yet (e.g. location). | No |
| 401 | missing_api_key / invalid_api_key | No key, or the key is wrong or revoked. | No |
| 402 | insufficient_credits | Your balance is too low for this request. | No |
| 403 | account_suspended | The account is suspended. | No |
| 404 | not_found | Unknown requestId, or it belongs to another account. | - |
| 429 | rate_limited | Too many requests this minute. See Retry-After. | No |
| 502 | search_failed | The search could not be completed (blocked or timed out). | Refunded |
| 503 | busy | No capacity right now. Retry after Retry-After seconds. | Refunded |
Frequently asked questions
Do I need an SDK?
No. Each example on this page is complete with the standard HTTP client of its language.
Where do I get an API key?
Sign in with Google, open API keys in the dashboard and create one. You get 3,000 free searches.
Which base URL do I use?
The one in the examples on this page. The path picks the result type: /search, /images, /news, /videos, /shopping, /places or /maps.
Can I test without writing code?
Yes, the dashboard playground runs searches and shows the code for the request you built.
Start with 3,000 free searches
No credit card. Sign in with Google, create a key, send your first request.