Build a Python SERP checker with a free API
Hey, so this one is a nifty script, with which you can use a free SEO API to check the rankings of any given Google search result page (SERP) in any given country and language.
This is a perfect use-case for a repl since you may rather want to use this as your own personal tool, accesible from anywhere. You can build the Python SERP checker with Google Colab as well, if you are used to a Jupyter kind of workflow too. The code is almost the same.
What do we need?
- Serpstack.com account with the free tier, which gives us 100 requests every month
- A keyword to search for
- A domain that we want to find in the SERPs
- The country code and language code we want to use for the search
Let's get started
- First we copy and paste the API key from the Serpstat dashboard, after we created a free account:
- Fork below repl to edit it.
- Paste the key into the value for the
api_key
variable: - Let's say we are interested in the Google results for "ranking checker" in New Zealand and want to know how Ahrefs free serp checker performs in the results. Fill the remaining variables accordingly:
- The
query
is ranking checker target_domain
is just ahrefsgoogle_domain
is google.co.nz in New Zealand- The
country_code
of New Zeland is nz and their language code is en - Finally, we just have to tell the API how many
results
it should scrape. We can add any number between 10 and 100 here. Maybe 50 is enough. - Finally we specify
device
as either tablet, mobile, or desktop
After a few seconds, we should get a result printed into the terminal that looks something like this:
Result
Now that you have a custom Python Serp checker which you can run 100 times a month, you can verify the rankings of your own website to see how your Google rankings change over time.