Fetching Google search results programmatically is a core requirement for SEO tools, research pipelines, and AI agents. The traditional approach — managing proxies, rotating user agents, and parsing raw HTML — is fragile and expensive. The Scavio API provides a single POST endpoint that returns structured JSON including organic results, featured snippets, knowledge graphs, and People Also Ask data. This tutorial walks through authenticating, forming a request, and parsing the response in Python using the requests library.
Prerequisites
- Python 3.8 or higher installed
- requests library installed (pip install requests)
- A Scavio API key from scavio.dev
- Basic familiarity with Python dictionaries and JSON
Walkthrough
Step 1: Install the requests library
If you do not already have requests installed, add it to your environment. It is the only dependency needed for this tutorial.
pip install requestsStep 2: Set your API key
Store your Scavio API key in an environment variable rather than hard-coding it. This keeps credentials out of source control.
import os
API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")Step 3: Send the search request
POST to the Scavio endpoint with your query and country code. The response is a JSON object containing organic results and SERP features.
import requests
response = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"query": "best python web frameworks", "country_code": "us"}
)
data = response.json()Step 4: Parse and print organic results
The organic_results key contains a list of result objects. Each has title, link, and snippet fields.
for result in data.get("organic_results", []):
print(result["title"])
print(result["link"])
print(result.get("snippet", ""))
print()Python Example
import os
import requests
API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"
def search_google(query: str, country: str = "us") -> dict:
response = requests.post(
ENDPOINT,
headers={"x-api-key": API_KEY, "Content-Type": "application/json"},
json={"query": query, "country_code": country}
)
response.raise_for_status()
return response.json()
def main():
results = search_google("best python web frameworks")
organic = results.get("organic_results", [])
print(f"Found {len(organic)} results")
for r in organic[:5]:
print(f"- {r['title']}")
print(f" {r['link']}")
if __name__ == "__main__":
main()JavaScript Example
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";
async function searchGoogle(query, country = "us") {
const response = await fetch(ENDPOINT, {
method: "POST",
headers: {
"x-api-key": API_KEY,
"Content-Type": "application/json"
},
body: JSON.stringify({ query, country_code: country })
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
async function main() {
const results = await searchGoogle("best python web frameworks");
const organic = results.organic_results || [];
console.log(`Found ${organic.length} results`);
organic.slice(0, 5).forEach(r => {
console.log(`- ${r.title}`);
console.log(` ${r.link}`);
});
}
main().catch(console.error);Expected Output
{
"search_metadata": { "query": "best python web frameworks", "country_code": "us" },
"organic_results": [
{
"position": 1,
"title": "Top Python Web Frameworks in 2026",
"link": "https://example.com/python-frameworks",
"snippet": "Django, FastAPI, and Flask remain the top choices..."
},
{
"position": 2,
"title": "FastAPI vs Django: Which Should You Use?",
"link": "https://example.com/fastapi-vs-django",
"snippet": "FastAPI is ideal for async microservices..."
}
]
}