Introduction to APIs for SEO software

Introduction to APIs for SEO software

APIs for SEO software


Every developer has their own dreadful stories about dealing with other people’s code. Misunderstanding of functions output, managing huge data flows between various systems, unstructured data challenges – building sufficient interoperability while struggling to get significant volumes of data from point A to point B is such a complex problem sometimes.

At this point, a consistent application programming interface can make things a lot easier. Simply put, APIs build a convenient “bridge” between non-compatible applications, which may have different programming architecture. It doesn’t matter how different the applications are – APIs will form a connection between the parts of the software that need to exchange data with each other.

Different solutions are designed to serve different software apps. Nevertheless, APIs are commonly understood to be connected with web apps (they are often called REST APIs or RESTful APIs). Data requests to such APIs are made via HTTP(S). At the same time, structured data is normally returned either in XML or JSON formats.

In the framework of SEO tools development, APIs are used to integrate search results, keyword data, information about on-page errors, and so on and so forth. In simple terms, you get the data you need straight to the application. Moreover, that data is typically structured, readable and can be accessed only by authorized users.

In this article, we’ll take a look at different APIs and try to provide a basic understanding of how they operate. We’ll also go through a few API solutions and show how you can use application programming interfaces in your SEO software.

However, this is not a manual for those of you who plan to build an SEO tool. So, you need to have some basic understanding of data structures and programming. You can check out the interview with the CTO of RankActive to learn more about SEO software development.

How do APIs work?

Even though APIs are widely used in software development, their primary working principles are still aspects to be clarified. First of all, one should understand that a typical REST API and an ordinary website are not that different. Both use the same HTTP(S) protocol to communicate data and fetch files. On the other hand, though, the main difference between them lies in the presentation of data (REST APIs usually use JSON and XML, while web pages have an HTML source code).

There are hundreds if not thousands of different API solutions that one can use for different purposes. Need a repository of engaging content? YouTube API will help you to search for videos, retrieve standard feeds, see related content and even upload videos.

Interested in weather forecasts? AccuWeather API provides extended daily forecasts for the desired location, satellite images, info on tropical cyclones and more.

Although some APIs are free and don’t use any form of authentication to make calls, the majority of SEO-software APIs require this information before they can be used.

Authentication is normally done with a so-called “token,” which can be either retrieved from a server (using a username+password combination) or provided after the registration is completed.  A lot of API providers also use OAuth protocol to allow the connection via Internet service functions, such as those provided by Facebook or Google.

You may try to send a simple API request by typing in the following URL in your browser: http://freegeoip.net/json/188.252.255.255

This request will return the following response:

{"ip":"188.252.255.255","country_code":"HR","country_name":"Croatia","region_code":"13","region_name":"Zadarska Zupanija","city":"Zadar","zip_code":"23000","time_zone":"Europe/Zagreb","latitude":44.1361,"longitude":15.2906,"metro_code":0}

As you see, the response is provided in plain JSON. You can try out sending a similar request with your IP address.

That kind of request method is called GET, which is by far the simplest way to retrieve information via the REST API. Apart from GET, there are other methods to request data from a web server: POST, PUT and DELETE.

  • POST method is used to store some information in a database. For example, you make POST requests to a backend script on a server whenever you log into a website.
  • PUT request is used when you want to update some information in a database. However, this request normally typically goes hand-in-hand with the POST because you need to store a new piece of info in order to rewrite the old one.
  • DELETE has an obvious purpose – it removes an object from a database.

There are other HTTP(S) methods defined under HTTP(S) specifications, but these four are used across all REST APIs you would ever encounter.

Now let’s take a look at how APIs function. Note that in this article we are talking only about REST APIs.

APIs for SEO software

    1. Data gets stored in the database of the API provider.
    2. You request data by setting a task to an API endpoint using your credentials.
    3. API reaches out to a database and extracts requested data.
    4. You set a task to an API endpoint to get the extracted data.

    As you see, it’s not rocket science. Or at least, it is so from a user perspective.

    APIs for SEO software

    Although there are lots of APIs one can use to develop SEO tools, almost all of them are based on a list of common principles that we’ve already described above: you authorize within a system, make a call, and get your results.

    However, only a handful of APIs is applicable to the needs of SEO software development. Let’s go through the most widespread solutions to see what APIs can be used to devise SEO tools.

    Twitter API

    Social Media and SEO has been a trendy topic for a very long time now. Everybody’s talking about the importance of Twitter, Facebook, LinkedIn and other networks in the SEO framework.

    You may use Twitter API to get search results, create and manage ads campaigns, check out engagement metrics, send direct messages, etc. Nevertheless, only a handful of these features is used in SEO software.

    First things first, Twitter’s Search API is handy when it comes to analyzing trends and topics. Secondly, Twitter’s Engagement API can provide some valuable insights into what people would or wouldn’t like to see in their feeds; there are currently seventeen kinds of engagement metrics you can use to empower your tool.

    Google AdWords API

    Unless you’re new to the basics of search engine optimization, there’s no need to explain what Google AdWords is. However, the AdWords API seems to be the uncharted waters for many SEO enthusiasts.

    Google AdWords API allows integrating data from the AdWords platform directly into applications. It not only helps to manage various AdWords accounts and campaigns more efficiently, but also provides tremendous opportunities to developers of third-party software including automated generation of keywords and destination URLs, key marketing metrics (Search Volume, CPC, Competition), location targeting, customizable reports, and so on and so forth. What’s more, the SOAP interface of AdWords API is supported by six popular programming languages, comprising PHP, Java, Python, .NET, Ruby, and Perl.

    If the process of authorization weren’t too complicated, AdWords API would make an excellent tool for SEO software development. The point is that one needs to get a developer token in order to use pretty much all Google’s APIs. Although this process itself is not that difficult, the so-called “token review team” rejects all applications that don’t comply with the Terms & Conditions and the Required Minimum Functionality. In fact, 99% of SEO software providers don’t pass token review (any SEO software is considered to be a third-party tool). The good news is that you can apply multiple times: who knows, maybe eventually you will succeed.

    Google Analytics API

    Analytics API would be useful for those who need to generate detailed ranking reports for keywords and websites’ landing pages. Simply put, it gives a possibility to display the data from Google Analytics and generate reports. What’s more, Google allows returning numerous dimensions, including operating system, country, city, landing page, keyword, and device.

    Unlike AdWords API, Google Analytics is free and doesn’t require high-level technical expertise. Nevertheless, it works only with websites that you own (or have access to their Google Analytics profile).

    Google Custom Search

    Google Custom Search allows creating custom search engines that search across particular websites or web pages. On the other hand, it cannot give a precise image of how Google SERP looks like for a specific query. Hence, it doesn’t represent any value for SEO tools.

    You can use Google Ad Preview Tool to check results pages for a certain keyword, but it involves a lot of manual work (specifying the search term, location, language, etc.) and it does not provide any opportunity for integration with automation solutions.

    It’s worth noting that Google used to have SOAP Search API. It allowed accessing Google index data with vast volumes of queries, which could be used for further analysis and processing, but Google removed it a long time ago.

    As you see, one could build a simple SEO tool on top of Google APIs, but the result would probably fall off expectations. Google doesn’t encourage the practice of exploiting its data with a clear commercial purpose, but fortunately, there’s another way around.

    Making your first API call with DataForSEO

    DataForSEO uses REST APIs for interchanging data, meaning that data exchange is done via the HTTPS protocol.

    Let’s make keyword research based on the dogtime.com domain, select its most popular keyword (e.g., keyword with the biggest search volume) and get SERP results for it.

    We’ll be using Postman. For those of you who aren’t familiar with it, Postman is an easy-to-use HTTP(S) client explicitly developed for testing web applications.

    1Log in to your DataForSEO account dashboard, or create an account if you don’t have one (it’s free). You will be using your account’s credentials to make your first request.

    APIs for SEO software

    2 Download Postman Examples from DataForSEO Docs.

    DataForSEO Docs v3

    3 Launch Postman and import DataForSEO collection (JSON file you downloaded at the previous step).

    4 Open DataForSEO collection and launch ‘task_post’ from the ‘keywords_for_site’ folder under Keywords Data API.

    5 Specify your DataForSEO credentials in the “Authorization” section.

    6 Head to the “Body section” and adjust the necessary parameters. In our case, we’ll be looking for keywords that are ranked for the dogtime.com domain in Great Britain.

    Keywords Data API v3 POST

    7 Click Send to request data. Once you receive the response from our server, don’t forget to copy the id of the task. You’ll need it later to retrieve the results.

    Keywords Data API v3 POST response

    8 Now launch the ‘task_get’.

    9 Append the id of the task to the GET URL line after task_get/. Note that you need to repeat the authorization process before hitting ‘send’.

    10 Now we have a list of keywords ranked for the dogtime.com. Let’s pick the one with the highest search volume. In our case, it’s “pitbull dog.”

    Keywords Data v3 Results

    11 Let’s get SERP data for the selected keyword “pitbull dog.” In order to do that with Postman, launch the task_post under SERP API ‘standard’ folder.

    12 Head to the “Body” section and adjust the parameters. In our case, we’ll be looking for SERP data on the “pitbull dog” query. We can also narrow down the search by specifying the exact location; we’ve chosen Brighton, U.K., but you can try it with any other place. You can receive the full list of locations supported by this API through a GET request to the List of Google Locations for SERP.

    SERP API v3 Postman POST

    13 Once you have sent the request and copied the id of the task, add a new tab and get back to the DataForSEO collection. Find the task_get_regular in the ‘standard’ folder of SERP API and launch it. Then modify the GET URL line with the id of the task after ‘regular/’ and hit the send button.

    14 Here’s how a simple response of SERP API looks like.

    Request Sample
    
    https://api.dataforseo.com/v3/serp/google/organic/task_get/regular/$id
    
    Response Sample 
    
    {
        "version": "0.1.20200312",
        "status_code": 20000,
        "status_message": "Ok.",
        "time": "0.1645 sec.",
        "cost": 0,
        "tasks_count": 1,
        "tasks_error": 0,
        "tasks": [
            {
                "id": "03121421-1535-0066-0000-7c60b700a01e",
                "status_code": 20000,
                "status_message": "Ok.",
                "time": "0.0682 sec.",
                "cost": 0,
                "result_count": 1,
                "path": [
                    "v3",
                    "serp",
                    "google",
                    "organic",
                    "task_get",
                    "regular",
                    "03121421-1535-0066-0000-7c60b700a01e"
                ],
                "data": {
                    "api": "serp",
                    "function": "task_get",
                    "se": "google",
                    "se_type": "organic",
                    "language_code": "en",
                    "location_name": "Brighton,England,United Kingdom",
                    "keyword": "pitbull dog",
                    "device": "desktop",
                    "os": "windows"
                },
                "result": [
                    {
                        "keyword": "pitbull dog",
                        "type": "organic",
                        "se_domain": "google.co.uk",
                        "location_code": 1006565,
                        "language_code": "en",
                        "check_url": "https://www.google.co.uk/search?q=pitbull%20dog&num=100&hl=en&gl=GB&gws_rd=cr&ie=UTF-8&oe=UTF-8&uule=w+CAIQIFISCWdBKfYJhXVIEfkOfXJ6r8ac",
                        "datetime": "2020-03-12 12:21:55 +00:00",
                        "spell": null,
                        "item_types": [
                            "video",
                            "people_also_ask",
                            "organic",
                            "related_searches",
                            "knowledge_graph",
                            "people_also_search"
                        ],
                        "se_results_count": 117000000,
                        "items_count": 97,
                        "items": [
                            {
                                "type": "organic",
                                "rank_group": 1,
                                "rank_absolute": 3,
                                "domain": "en.wikipedia.org",
                                "title": "Pit bull - Wikipedia",
                                "description": "For other uses, see Pitbull (disambiguation). Dog breed. Pit bull. Pit bull sampler.jpg. A selection of pit bull-type dogs.",
                                "url": "https://en.wikipedia.org/wiki/Pit_bull",
                                "breadcrumb": "en.wikipedia.org › wiki › Pit_bull"
                            },
                            {
                                "type": "organic",
                                "rank_group": 2,
                                "rank_absolute": 4,
                                "domain": "dogtime.com",
                                "title": "American Pit Bull Terrier Dog Breed Information, Pictures ...",
                                "description": "The American Pit Bull Terrier is a companion and family dog breed. Originally bred to “bait” bulls, the breed evolved into all-around farm dogs, and later moved into the house to become “nanny dogs” because they were so gentle around children.",
                                "url": "https://dogtime.com/dog-breeds/american-pit-bull-terrier",
                                "breadcrumb": "dogtime.com › dog-breeds › american-pit-bull-terrier"
                            },
                            {
                                "type": "organic",
                                "rank_group": 3,
                                "rank_absolute": 5,
                                "domain": "www.vrcpitbull.com",
                                "title": "Pit Bull Facts - Villalobos Rescue Center",
                                "description": "This page discusses the most notable traits of Pit Bull type dogs, including the potential for dog aggression. You will learn here that while Pit Bulls make great ...",
                                "url": "https://www.vrcpitbull.com/pit-bull-facts/",
                                "breadcrumb": "www.vrcpitbull.com › pit-bull-facts"
                            },
    

    As you can see, the “items” array contains data on the SERP elements found for the specified keyword. With the Regular function, we get ranked domains from SERP with the related URLs, titles, and descriptions of each result. The second one shows rankings of the “dogtime.com” domain for the “pitbull dog” query in Brighton. If you need to obtain a full overview of SERP with all featured elements, you can use the Advanced function.

    This is just an example of what DataForSEO APIs can provide you with. In fact, we offer well-rounded solutions for streamlining the process of SEO software creation.

    Check out what else we can do for your business >>

    Let’s wrap it up

    In this blog post, we’ve looked at how modern APIs work and how they can help you access data. We hope that it gave you a better understanding of the application programming interface basics and its role in devising an efficient SEO software.

    If you need more information on this topic, we recommend checking out “RESTful Web APIs: Services for a Changing World” by Leonard Richardson, Mike Amundsen, and Sam Ruby. The book provides everything you need to know about the theory and practice of using APIs.

    What’s more, you can translate this knowledge into reality for free. Create an account with DataForSEO, and start leveraging API integration to jump over the steeplechase barriers of data retrieval.
    TRY FOR FREE

George Svash

George is the Director of Content Marketing at DataForSEO, an API suite designed to help SEO software companies and agencies gather the SEO data they need for their projects. George is a tech and marketing geek with a deep passion for Big Data and SEO. Having a broad experience in content marketing and a degree in engineering, he is particularly good at explaining complex concepts.

2 Comments

Sorry, the comment form is closed at this time.