SERPpost V1 returns a JSON response. To make a CSV, validate the response, select the result fields you need, then write those fields locally. The example below exports Google organic results with Python. It does not treat CSV as an API response format, and it does not try to extract the full text of every result page.
This is useful when a team wants a spreadsheet-friendly snapshot of a query while keeping the original JSON response for debugging or later processing.
Get a Google result set from the V1 API
The V1 Search endpoint is POST /api/v1/search. Send your API key from a
server-side environment, not from browser code. This request asks for a Google
result set in the United States. Change the query, country, and language to
match the search context you need.
import csv
import os
import requests
api_key = os.environ["SERPPOST_API_KEY"]
payload = {
"s": "python csv tutorial",
"t": "google",
"p": 1,
"d": 20000,
"country": "us",
"language": "en",
"maxCache": 0,
}
response = requests.post(
"https://serppost.com/api/v1/search",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
json=payload,
timeout=30,
)
response.raise_for_status()
body = response.json()
if body.get("code") != 0:
raise RuntimeError(body.get("msg", "SERPpost request failed"))
organic_results = body.get("data", {}).get("organic", [])
Check code before reading data. Result fields can vary by query, so inspect
the response you receive before relying on optional fields in a production
workflow. This example reads position, title, link, and snippet when
they are present in organic results.
Export selected organic results to CSV
Use the standard-library csv module to create a small, predictable export.
DictWriter handles quotes and commas in titles or snippets without manual
string concatenation.
columns = ["position", "title", "link", "snippet"]
with open("google-results.csv", "w", newline="", encoding="utf-8") as file:
writer = csv.DictWriter(file, fieldnames=columns)
writer.writeheader()
for item in organic_results:
writer.writerow({
"position": item.get("position", ""),
"title": item.get("title", ""),
"link": item.get("link", ""),
"snippet": item.get("snippet", ""),
})
The CSV is a view of the fields you selected. Keep the original JSON response if another part of your application needs fields that are not in the export. For example, a spreadsheet may need titles and links, while a later job may need the unmodified response for troubleshooting.
Choose JSON or CSV based on the next step
| If you need to… | Keep… | Why |
|---|---|---|
| Inspect the complete API response | JSON | It preserves the response structure returned by the API. |
| Share a small result set in a spreadsheet | CSV | It gives a tabular export of the fields you selected. |
| Capture the readable content of a public page or file | Reader output | Page and file capture use the separate /api/v1/url endpoint. |
CSV conversion happens in your application after the search response arrives. It is deliberately separate from searching, which makes the fields and file layout explicit in your code.
Verify the request before saving data
For a repeatable export, check these points before scheduling a job:
- Confirm that
codeis0before iterating through results. - Store the query, country, language, and retrieval time next to the export.
- Choose a fixed column list so spreadsheet users know what each file contains.
- Keep
maxCachedeliberate. This example uses0to inspect a live request; production cache behavior should match your own workflow. - Treat an empty result list as a valid response shape, not a CSV-writing error.
What this example does not do
This tutorial exports one returned Google result set. It does not guarantee a particular ranking, supply every result type, or fetch the body text behind each result link. Use the V1 API documentation to review available result types and the Google Search request guide when you need the broader request and response context.
If you already have a public URL and need readable page or file content, use the Reader capability instead of treating a search-result CSV as page content.
FAQ
Does SERPpost return CSV directly?
SERPpost V1 returns a JSON response. Your application can export selected fields from that response to CSV, as the Python example does above.
Which fields should I put in the CSV?
Start with position, title, link, and snippet for a simple Google
organic-results export. Inspect each response before adding optional fields,
because result fields can vary by query.
Can I export a different country or language?
Yes. Set country and language in the request to match the search context
you want to inspect, then keep those values with the resulting file.
Can this script extract the text of each result page?
No. This script writes fields from the search response. Public page and file capture are separate Reader requests.
You can test the request shape in the API Playground and create a free account when you are ready to use your own API key.