The Search API endpoint: https://seo-api.p.rapidapi.com/v1/search/{query
For search the minimum query must have the q
parameter. The best module to encode the query parameters is urllib.
The News API endpoint : https://seo-api.p.rapidapi.com/v1/news/{query
This tutorial will be using Python3.5.
This example is a simple search for the keyword “president election”. The query should be properly url encoded. So the query will end up being q=president+election
python script:
import urllib
import requests
headers = {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host" :"seo-api.p.rapidapi.com"
}
query = {
"q": "president election"
}
resp = requests.get("https://seo-api.p.rapidapi.com/v1/search/" + urllib.parse.urlencode(query), headers=headers)
results = resp.json()
print(results)
Google’s mobile and desktop are governed by different Google Algorithms. Your pages will rank differently on mobile vs. desktop search results. So it is important when performing SEO and SERP analysis it is recommend to check both mobile and desktop results. That way you’ll know what to optimize for.
By default the Google Search API searches for desktop results. To switch to mobile results you’ll need to set the x-user-agent
header to mobile
.
Python script to return the top 75 results:
import urllib
import requests
headers = {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host" :"seo-api.p.rapidapi.com",
"x-user-agent" : "mobile"
}
query = {
"q": "president election",
"num": 75
}
resp = requests.get("https://seo-api.p.rapidapi.com/v1/search/" + urllib.parse.urlencode(query), headers=headers)
results = resp.json()
print(results)
The documentation for Googio is also powering this Google Search API.
Use this guide by Moz for more advance Google Search Parameters