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}.
StatusCodeMeaningCredits
202-Not finished within timeout (or async: true). Poll pollUrl.Reserved
400invalid_requestMalformed body or a parameter out of range.No
400unknown_parameterA field the API does not know (typo?).No
400unsupported_parameterA known field that this endpoint does not support yet (e.g. location).No
401missing_api_key / invalid_api_keyNo key, or the key is wrong or revoked.No
402insufficient_creditsYour balance is too low for this request.No
403account_suspendedThe account is suspended.No
404not_foundUnknown requestId, or it belongs to another account.-
429rate_limitedToo many requests this minute. See Retry-After.No
502search_failedThe search could not be completed (blocked or timed out).Refunded
503busyNo 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.