curl
curl -G https://www.searchapi.io/api/v1/search \ -H "Authorization: Bearer $SEARCHAPI_API_KEY" \ --data-urlencode 'engine=google' \ --data-urlencode 'q=best brazilian footballer' \ --data-urlencode 'gl=us'curl -G https://www.searchapi.io/api/v1/search \ -H "Authorization: Bearer $SEARCHAPI_API_KEY" \ --data-urlencode 'engine=google' \ --data-urlencode 'q=best brazilian footballer' \ --data-urlencode 'gl=us'
Python
import os
import requests
response = requests.get(
"https://www.searchapi.io/api/v1/search",
headers={"Authorization": f"Bearer {os.environ['SEARCHAPI_API_KEY']}"},
params={
"engine": "google",
"q": "best brazilian footballer",
"gl": "us",
},
)
print(response.json())
import os
import requests
response = requests.get(
"https://www.searchapi.io/api/v1/search",
headers={"Authorization": f"Bearer {os.environ['SEARCHAPI_API_KEY']}"},
params={
"engine": "google",
"q": "best brazilian footballer",
"gl": "us",
},
)
print(response.json())
JavaScript
const params = new URLSearchParams({
"engine": "google",
"q": "best brazilian footballer",
"gl": "us",
});
const response = await fetch(`https://www.searchapi.io/api/v1/search?${params}`, {
headers: { Authorization: `Bearer ${process.env.SEARCHAPI_API_KEY}` },
});
console.log(await response.json());
const params = new URLSearchParams({
"engine": "google",
"q": "best brazilian footballer",
"gl": "us",
});
const response = await fetch(`https://www.searchapi.io/api/v1/search?${params}`, {
headers: { Authorization: `Bearer ${process.env.SEARCHAPI_API_KEY}` },
});
console.log(await response.json());
Ruby
require "json"
require "net/http"
uri = URI("https://www.searchapi.io/api/v1/search")
uri.query = URI.encode_www_form(
"engine" => "google",
"q" => "best brazilian footballer",
"gl" => "us"
)
request = Net::HTTP::Get.new(uri, "Authorization" => "Bearer #{ENV.fetch("SEARCHAPI_API_KEY")}")
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
puts JSON.parse(response.body)
require "json"
require "net/http"
uri = URI("https://www.searchapi.io/api/v1/search")
uri.query = URI.encode_www_form(
"engine" => "google",
"q" => "best brazilian footballer",
"gl" => "us"
)
request = Net::HTTP::Get.new(uri, "Authorization" => "Bearer #{ENV.fetch("SEARCHAPI_API_KEY")}")
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
puts JSON.parse(response.body)
With a token placeholder
curl -G https://www.searchapi.io/api/v1/search \ -H "Authorization: Bearer $SEARCHAPI_API_KEY" \ --data-urlencode 'engine=google_ai_overview' \ --data-urlencode 'page_token=PASTE_FROM_PREVIOUS_RESPONSE'curl -G https://www.searchapi.io/api/v1/search \ -H "Authorization: Bearer $SEARCHAPI_API_KEY" \ --data-urlencode 'engine=google_ai_overview' \ --data-urlencode 'page_token=PASTE_FROM_PREVIOUS_RESPONSE'
Replace PASTE_FROM_PREVIOUS_RESPONSE with ai_overview.page_token from the response before it. It is valid for a few minutes.