Google Search · 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": "what causes the aurora borealis",
},
)
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": "what causes the aurora borealis",
},
)
print(response.json())
Fetch AI Overview · 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_ai_overview",
"page_token": "PASTE_FROM_PREVIOUS_RESPONSE",
},
)
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_ai_overview",
"page_token": "PASTE_FROM_PREVIOUS_RESPONSE",
},
)
print(response.json())
Replace PASTE_FROM_PREVIOUS_RESPONSE with ai_overview.page_token from the response before it. It is valid for a few minutes.
The key is read from SEARCHAPI_API_KEY and sent as a Bearer token.