What is an API?
- IAM Glossary
- What is an API?
API stands for Application Programming Interface, which is a set of protocols and routines that enable different systems and applications to communicate with each other, without requiring developers or end users to know how they’re implemented. This enables developers to create reusable software components.
Developers often use APIs to access functionality provided by an existing service or application. For example, an API could allow a weather app to access the latest weather data from a weather service provider. The API specifies the request format the app must use to retrieve the data, as well as the format of the data that will be returned by the weather service.
How do APIs work?
APIs work by specifying a set of rules and protocols for communication between software components. They typically include specifications for routines, data structures, object classes and variables. Here's a high-level overview of how APIs work:
A client makes a request. The client (meaning the system or application) sends a request to the API server that specifies the desired operation, such as "retrieve data" or "create a new resource." The request includes any necessary parameters and authentication information.
The API server processes the request. The API server receives the request and processes it, using the underlying application and data to perform the specified operation.
The API server returns a response. The API server sends a response back to the client, indicating whether the operation was successful, and if so, providing the relevant data. The response will be formatted according to the API's specifications.
The client processes the response. The client receives the response from the API and processes the data as needed, for example, by displaying it to the user.
In this way, APIs allow software components to communicate with each other and exchange data and functionality. The API defines the rules and protocols for communication, so different systems and applications can interact with each other, even if they were developed by different organisations or individuals, on different platforms, using different programming languages.
What are the different types of APIs?
Here are the most common types of APIs:
Open APIs, also known as external or public APIs, are available to developers and other users with minimal restrictions. Public APIs may require registration, app approval or an API key to prevent abuse.
Internal APIs, also known as private APIs, are used to share resources and data within a company or between different systems or applications owned by the same organisation. Internal APIs are only accessible to users within a particular organisation and are hidden from external users.
Partner APIs are similar to open APIs, but they are intended for use by a specific set of trusted partners. Access to these APIs is generally restricted and requires pre-approval.
Composite APIs combine different API types to tackle particularly complex use cases. They enable developers to retrieve data from multiple sources through a single API call, simplifying the data access process.
REST APIs (Representational State Transfer APIs) use HTTP requests to get, put, post and delete data. REST is an architectural style that uses simple, lightweight and flexible mechanisms to exchange data between different systems. REST APIs are typically used for web-based applications and services.
SOAP APIs (Simple Object Access Protocol APIs) are a standards-based web services approach that allows different systems to communicate over the internet. SOAP uses XML for its message format and relies on other web standards for transport, including HTTP and SMTP.
XML-RPC and JSON-RPC are both Remote Procedure Call (RPC) APIs that use XML and JSON, respectively, as data formats. These APIs allow systems to communicate and invoke procedures on remote systems, typically over HTTP.
GraphQL API, which was developed by Facebook, is a new API standard for building and consuming APIs. It provides a more efficient, powerful and flexible alternative to traditional REST APIs. GraphQL APIs allow client applications to specify the structure of the data they need, and the server to return only the requested data.
Each type of API has its own strengths and weaknesses and is better suited for different use cases. Choosing the right type of API for a particular project depends on factors such as the size and complexity of the project, the intended audience and the type of data being accessed.
What is an example of an API?
APIs are everywhere! Here are just a few examples.
The Google Maps API allows developers to add Google Maps functionality to their own websites and applications. Retail stores often use the Google Maps API to retrieve data for their online store directories.
Retailers use the PayPal API to enable their customers to checkout using PayPal.
Another example is the Twitter API, which allows developers to access Twitter data and functionality in their own applications. The Twitter API enables developers to retrieve tweets, post tweets and perform other actions, such as searching for tweets and following users.
Travel sites make heavy use of APIs to allow visitors to search for and book flights, lodging and other travel-related services.