×
  • Shared Hosting

    Fast reliable and affordable cPanel Web Hosting from $2.99 per month.

  • Reseller Hosting

    Multiple websites? No problem with our multi-site hosting package. From $5.99 per month.

  • Annual Hosting

    Save money on web hosting by paying annually. Starting at $29.99 per year.

  • VPS Servers

    Need more power and resources? Choose our VPS server, only $7.99 per month.

  • FREE HOSTING PLAN

    Ideal for students and unemployed.

    Register

Connect to the Accuranker Rest API and extract the rankings from multiple domains using Python

03/12/2022 | |0 comment

Accuranker is a powerful SEO tool that provides keyword rankings, traffic insights and competitive analysis. It can quickly and accurately track rankings from multiple search engines including Google, Yahoo, Bing and more. The Accuranker Rest API allows developers to programmatically access the data stored in their Accuranker accounts. It provides a simple way to extract rankings from multiple domains using Python.

In this article, we will discuss how to connect to the Accuranker Rest API and extract the rankings from multiple domains using Python.

To begin, you will need to sign up for an Accuranker account and generate an API key. Once you have the API key, you will need to install the requests library in Python. This library provides a way to make HTTP requests to the Accuranker API.

Next, you will need to construct a URL for the API request. The URL should include the API key, the domain you want to track, and the search engine you want to track rankings for. For example, if you want to track rankings for the domains example.com, example2.com an example3.com, on Google, the URL might look something like:

#importing the necessary libraries
import requests
import json

#Defining the function to connect to Accuranker API v4
def connect_api(url, auth_key):
    # defining the API endpoint, authentication key and headers
    endpoint = "https://api.accuranker.com/v4"
    headers = {
        'Authorization': 'Bearer ' + auth_key
    }

    # making the request by sending a GET request with the endpoint URL
    api_response = requests.get(endpoint + url, headers=headers)

    # checking the response code
    if api_response.status_code == 200:
        # returning the response in json format
        return json.loads(api_response.content)

#Defining the function to extract rankings from multiple domains
def extract_rankings(domains):
    # defining the API endpoint
    url = '/rankings'

    # defining the authentication key
    auth_key = '<Your API Key>'

    # defining the payload
    payload = {
        'domains': domains
    }

 

Chris

Freelance Technical SEO with - https://sitebee.co.uk