This guide walks through a first request to the Google Search API, the handful of parameters that change what comes back, and the shape of the response. All you need is an API key from your dashboard.
Your first request
curl "https://www.searchapi.io/api/v1/search?engine=google&q=coffee&api_key=YOUR_API_KEY"
The key can travel in the query string as above or in an Authorization: Bearer YOUR_API_KEY header. The response is a JSON document describing the results page Google returned for the query, as seen from the United States, in English, on a desktop browser. Those are the defaults: gl=us, hl=en and device=desktop.
The parameters that change results
Google shows different pages to different people. These are the parameters that control which page you get:
locationsets the canonical location of the search, for examplelocation=London. The Locations API lists the accepted names; if several match, the most popular one is used. For precise control pass your own Google-encodeduule, orlatitudeandlongitudein decimal degrees. The three are mutually exclusive.glandhlset the country and the interface language. Google phased out country domains such asgoogle.dein April 2025, so these two parameters are the way to localize a search.deviceswitches betweendesktop,mobileandtablet. Mobile pages carry different blocks and often a different order.pageselects the page of results.numis constant at 10 since Google phased it out in September 2025; the Google Rank Tracking API coversnum=100.time_periodrestricts results by date, withtime_period_minandtime_period_maxfor a custom range inMM/DD/YYYYformat.nfpr=1drops results from auto-corrected queries, andverbatim=truegoes further by disabling every query modification, including synonyms and personalization.safetoggles SafeSearch:active,blur(the default) oroff.
Putting a few together:
curl "https://www.searchapi.io/api/v1/search?engine=google&q=coffee&location=London&gl=gb&hl=en&device=mobile&api_key=YOUR_API_KEY"
Reading the response
Every successful search returns the same core keys:
search_metadatahas the searchid,status, the timings, and two links:html_url, the exact page that was parsed, andjson_url, this response again. Keep the id; it is how you re-open a search later.search_parametersechoes the parameters as applied, defaults included, so you can see whatglordeviceactually was.search_informationis what Google reported about the query:query_displayed,total_results,time_taken_displayedand, when a location was set,detected_location.organic_resultsis the list of results in order. Each hasposition,title,link,domain,displayed_link,snippetandfavicon.paginationhascurrentandnext.
Anything else on the page, such as a knowledge panel, an answer box or People also ask, shows up as its own top-level key only when Google shows it. A short Ruby example that prints the organic results:
require "net/http"
require "json"
uri = URI("https://www.searchapi.io/api/v1/search")
uri.query = URI.encode_www_form(engine: "google", q: "coffee", location: "London", api_key: ENV.fetch("SEARCHAPI_KEY"))
data = JSON.parse(Net::HTTP.get(uri))
data["organic_results"].each do |result|
puts "#{result["position"]}. #{result["title"]} - #{result["link"]}"
end
Where to go next
The Google Search API documentation lists every parameter and has a full example response for each block Google can show, from knowledge graph variants to AI Overview and local results. When a field you expect is missing, open search_metadata.html_url first: if the block is not on the page, there is nothing to parse.