Google search API
Google’s web results for a query as JSON: organic results with real URLs, snippets, dates and sitelinks, the knowledge graph, answer box, top stories, people also ask and related searches, per country, language and location, with time filters.
GET /v1/google/searchBeta1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/google/search?q=coffee&gl=us&hl=en",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "searchParameters": { "q": "coffee", "type": "search", "engine": "google", "gl": "us", "hl": "en", "num": 10, "page": 1 }, "knowledgeGraph": { "title": "Coffee", "type": "Beverages", "imageUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTE6lrHyuQPiYit9aNvXK7nG6zzLMa6qFWhAjo2Ye7T8aW8zHT0QVfZKOneYCpMuZgT…" }, "organic": [ { "title": "Coffee", "link": "https://en.wikipedia.org/wiki/Coffee", "snippet": "Coffee is a beverage brewed from roasted, ground coffee beans. Dark-colored and bitter, coffee has a stimulating effect …", "source": "Wikipedia", "displayedLink": "https://en.wikipedia.org › wiki › Coffee", "position": 1 }, { "title": "Specialty Coffee | Buy Coffee Online", "link": "https://www.drinktrade.com/collections/all?srsltid=AYCX9vIiydeZo_t93sXLy1r-rthRuzUwPVPD66jgXx7v0asDnTdDsIg2", "snippet": "Choose from a wide variety of coffee from the top roasters in the US. All our specialty coffee is roasted to order and s…", "source": "Trade Coffee", "displayedLink": "https://www.drinktrade.com › collections › all", "rating": 4.8, "position": 2 }, "… 6 more" ], "peopleAlsoAsk": [ { "question": "Which organ is most affected by coffee?" }, { "question": "What is the 80/20 rule for coffee?" }, "… 2 more" ], "relatedSearches": [ { "query": "Coffee nearby" }, { "query": "Coffee types" }, "… 6 more" ]}Parameters
| Name | Type | Description |
|---|---|---|
qquery · required | string | The search, as typed into Google (operators work). Example: coffee. |
glquery | string | Country to search from, default us. Example: gb. |
hlquery | string | Interface language, default en. Example: de. |
locationquery | string | Where the search happens, as a canonical place name ("Austin,Texas,United States"). Example: Austin,Texas,United States. |
numquery | integer | Results per page (default 10, at most 100). |
pagequery | integer | Page, from 1. |
tbsquery | string | Time filter: qdr:h (past hour), qdr:d, qdr:w, qdr:m, qdr:y, or a cdr:1,cd_min:…,cd_max:… range. Example: qdr:w. |
safequery | "active" | "off" | SafeSearch, default off. One of active, off. |
Status codes
| Status | Meaning |
|---|---|
200 | The result page. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | No Google Maps place matches that reference. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | Google is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
Same fields as other SERP APIs?
Yes: searchParameters, organic, knowledgeGraph, answerBox, topStories, peopleAlsoAsk, relatedSearches.
More than 10 results?
num up to 100 reads that many results over several pages; page moves through them.
Fresh results?
tbs=qdr:h is the past hour; those are cached 10 minutes, other searches longer.
Google is a trademark of Google LLC. We are not affiliated with or endorsed by Google.