An API, or Application Programming Interface, is a way of communication between various software components. It is a method in which applications give access to their data in a structured way, without the need of interacting with the user interface.
Basically, someone creates a software and gives you access to parts of it via an API.
What is an API?
An Application Programming Interface (acronym of API) is a mechanism that allows two software components to communicate with each other.
For instance, when you search something on Google, a series of APIs are used by Google to get search results, images, videos and any other search result types.
Types of Application Programming Interfaces
The word API often refers to Web APIs, which allow the communication of softwares connected to the Internet.
There are, however, other types of APIs:
- APIs for Programming Languages
- APIs for Software Libraries
- APIs for Operating Systems
- APIs for Computer Hardware
Different types of Web APIs
A Web API is an API (Application Programming Interface) for the Web.
There are different categories of APIs depending on the level of privacy, or security, needed to access the API:
- Open APIs
- Internal APIs
- Composite APIs
- Partner APIs
Open APIs
Open APIs are APIs that are publicly available to any user.
It is also called public APIs which are available to any other users. Open APIs help external users to access the data and services. It is an open-source application programming interface in which we access with HTTP protocols.
Examples: Wikipedia API, Wikidata API, Reddit API, Teleport API
Internal APIs
Internal APIs are private APIs used by companies to let applications communicate with each other.
Examples of internal APIs: Google Apps interacting with Knowledge Graph
Composite APIs
Composite APIs is a collection of service APIs. They are APIs that combine multiple web APIs into one and allow web developers to call multiple endpoints in single call.
Examples of composite APIs: shopping cart requiring multiple APIs for each feature
Partner APIs
Partners APIs are APIs requiring the developer to have specific rights or licenses in order to access. Partner APIs are not available to the public.
Examples of partner APIs: LinkedIn API, Google Search Console API, Twitter API, Reddit API, Facebook API, Slack API, Google Analytics API, Google Ads API, Google My Business API
API Protocol Types
An API protocol defines the rules necessary to perform an API call (types, commands, etc.).
Different API architecture require different protocols.
There are four main categories of API protocols that allow communication between client and servers (in order of creation):
- RPC APIs
- SOAP APIs
- REST APIs
- GraphQL
RPC
RPC APIs, also known as Remote Procedure Call, APIs are the earliest and simplest types of API.
RPC started with XML-RPC and later incorporated JSON-RPC versions. Later Google incorporated the general purpose RPC (or gRPC).
- XML-RPC: Remote procedure call encoded in XML
- JSON-RPC: Remote procedure call encoded in JSON
- gRPC: Remote procedure call that can run in any environment
In the world of micro-services, gRPC has seen adoption from Facebook’s Apache Thrift and Twitch’s Twirp.
The simplicity of RPC makes a lightweight solution to improve the performance of APIs that face large amount of network requests.
SOAP
SOAP APIs is an API format created by Microsoft to overcome some of the challenges of the XML-RPC API type.
SOAP APIs, also known as Simple Object Access Protocol APIs, use the XML format to define the structure of the communication.
SOAP APIs is a verbose way to communicate with XML. It has an advantage over XML-PRC as it can distinguish between data types.
SOAP is still used by applications like Salesforce as it allows encryption using security tokens within the SOAP envelope.
It is also useful as SOAP can chain messages so that the server “remembers” previous requests. This is interesting for booking and commerce applications that want to keep track of user requests to improve purchase funnel. This can however bring additional load on the servers.
REST
REST APIs, also known as Restful APIs, are web APIs that conform to the requirements of REST architectural style and allow for interaction with RESTful web services.
REST APIs quickly became more popular than SOAP APIs.
It uses HTTP technologies found in web browsers and servers to make data available as resources.
- Uniform interface regardless of device or application type
- Each request is treated as new (stateless). No need to store anything about the session
- Allows server to return executable code
- Uses HTTP caching to reduce the load on the server
- Layered system that allows scalability on the server-side
REST stands for REpresentational State Transfer.
GraphQL
GraphQL is a data query language created by Facebook that uses a schema to reduce the number of endpoints and allow the client (instead of the server) to decide how the data is returned.
With REST APIs, you call and endpoint and get back the entire response from the server that you then need to parse to get the data you need. With GraphQL, you define the schema of what you want to get and receive only the specific data that you request for, no more, no less.
GraphQl makes requests more complex, but optimizes the payload.
Here is a simple reminder table of the 4 types of application programming interface types.
Web API Type | Format |
---|---|
RPC APIs | JSON, XML, Thrift |
SOAP APIs | XML |
REST APIs | XML, JSON, HTML, Text |
GraphQL | JSON |
Example of APIs
There are so many APIs out there to count. The APIs I use the most are:
- Google APIs (Search Console API, Analytics API, YouTube API, Sheets API, Google Maps API, Knowledge Graph API, Pagespeed API, Indexing API, URL Inspection tool API)
- Social Media APIs (Reddit API, Facebook API, LinkedIn API, Twitter API)
- Business Sharing APIs: Slack API, Gmail API
- Content APIs: Wikipedia API, News API, Jobs API, Exchange rate API
- Other Marketing APIs: SEMRush API, Ahrefs API, Archive.org API, Yoast SEO API
How to Use APIs in Python
You can use Python to interact with various APIs. Here are a few tutorials that we’ve built for you.
Google Search Console API
- Authenticate Google Search Console API With OAuth2 (Python example)
- Authorise Requests to GSC API Using OAuth 2.0
- Extract Query by Page Using the Searchconsole API wrapper (Python)
- Get All Your Search traffic With Google Search Console API (With Code Sample)
- Get List of Verified Properties using Google Search Console API and Python
- Google Search Console API with Python (Video Example)
- Google Search Console API: Complete Guide (in 4 Chapters) – UPDATED 2024
- Google URL Inspection API with Python
- How to Get Google Search Console API Keys (with Example)
- How to use Google Search Console (GSC) – Complete Guide
- How to use Google Search Console API with R
- TF-IDF on Google Search Console Data (Python Examples)
- Upload Sitemaps to Google Search Console with the API (Python)
- What is Google Search Console API?
Reddit API
- Get Reddit API Credentials with PRAW (Python Example)
- Get Top Posts from Reddit API Without API Credentials (Python Example)
- How to Post on Reddit API with Python (PRAW example)
- How to use Reddit API With Python (Pushshift) with Example
- Reddit API with Python (Complete Guide)
- Reddit API’s JSON Documentation (How to Parse JSON): with and without Python
Facebook API
- Facebook Graph API: Get Access Token
- How to Post to Groups using Facebook Graph API with Python (Example)
Linkedin API
- How to Post on LinkedIn API With Python (example)
- LinkedIn API with Python (Complete Guide)
- LinkedIn API: Authenticate Using OAuth 2.0
- LinkedIn API: Get User Information
- LinkedIn API: How to Get Your OAuth Credentials (with Example)
Twitter API
- Authenticate the Twitter API with Python Example (Tweepy)
- How to Apply for a Twitter Developer Account (with Example)
- How to get Twitter API Credentials (API Keys) with Example
- Post on Twitter API using Tweepy and Python
- Tweepy Basics Functions for Twitter API (Python)
- Twitter API with Python (Complete Guide)
- Understand Tweepy’s Tweets JSON Response (Twitter API)
Slack API
- Alert Robots.txt Changes to Slack using Python
- Get the Slack API Credentials (Webhooks)
- Send Message With Slack API and Python
- Slack API with Python (Complete Guide)
Other APIs
How to use WordPress REST API with Python (external)
How to Use APIs for Machine Learning and Data Science
Applications programming interfaces are a great way to gather data for Data Science. APIs help data scientist gather data to be used to draw insights from and to train their Machine learning models. There are many APIs that give access to large amount of data usable for machine learning such as the Reddit API or the Wikipedia API. Alternatively, internal APIs can also be used in machine learning to gather data from internal data sources, such as the Google Search Console API.
APIs as an Alternative to Web Scraping
Not every website provide APIs, but when they do, using APIs instead of web scraping is the best option. Not only they are the endpoint that the company actually wants you to use, but APIs also offer structured and easier-to-process data than web scraping. Web Scraping requires more effort due to the changes in HTML structures and because lots of companies actively fight web scraping with Captchas and by blocking IP addresses.
When an API is not available for a specific website, alternatives like the wayback machine API or the commoncrawl API also facilitate data gathering by provide previously scraped data for a large portion of the Internet.
Conclusion
Don’t stop there. APIs offer a lot of opportunities and once you get the hang of it, they become quite easy to implement.
There are many interesting open APIs available out there, please share any interesting work that you have done with an API with me.
SEO Strategist at Tripadvisor, ex- Seek (Melbourne, Australia). Specialized in technical SEO. Writer in Python, Information Retrieval, SEO and machine learning. Guest author at SearchEngineJournal, SearchEngineLand and OnCrawl.