SerpCheap
Browse documentation

SERPCHEAP / Getting started

Code examples

Copy a curl, Python or JavaScript request and run it from your own server.

On this page

curl

CURL
curl -X POST 'https://serpcheap.com/search' \
  -H 'X-API-KEY: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"q":"Nike","gl":"us","hl":"en"}'

Python

Python
import json, os, urllib.request
request = urllib.request.Request("https://serpcheap.com/search",
    data=json.dumps({"q":"Nike", "gl":"us", "hl":"en"}).encode(),
    headers={"X-API-KEY":os.environ["SERP_API_KEY"],
             "Content-Type":"application/json"})
with urllib.request.urlopen(request, timeout=55) as response:
    print(json.load(response))

JavaScript

JavaScript
const response = await fetch("https://serpcheap.com/search", {
  method: "POST",
  headers: {"X-API-KEY":process.env.SERP_API_KEY,
            "Content-Type":"application/json"},
  body: JSON.stringify({q:"Nike", gl:"us", hl:"en"})
});
const result = await response.json();
if (!response.ok) throw new Error(result.error.code);
console.log(result);

Examples describe the API contract and do not execute searches. Never share your API key with support.