A programmer’s craft is impossible without tools for building application software. We’re talking about API. Some of you have a rather vague or incorrect idea about what this fairly common term means. And what its role in modern software development. To make everything clear, Syndicode will explain you the topic of what is API in details.
In this article, you will find some theory about what is API, what types of APIs exist, its use cases and more.
What is API?
Application programming interface (API) is a set of functions and procedures that allow creating applications which access the features or data of an operating system, application, or other services. But how it will sound in simple words? Plain English, please. API is what allows software programs to communicate with one another.
To understand this you can imagine a cafe, where you make an order. Your order is the analogy for the information you request on a server (a cafe kitchen, let’s say). API in this example will be represented by a waiter, who serves you your order.
In other words, an API is a list of commands as well as the format of those commands that one program can send to another. API declares an interface for you to interact with its logic without needing to know what happens under the hood. It is used so that individual programs can communicate with one another directly and use each other’s functions.
API’s are provided by any program that allows interaction with other programs. People who write programs but wishes to use the functionality that already exists in other programs can simply look at the API documentation to find the list of commands available to them.
Also, thanks to Maxime LaBoissonniere, we’d like to set an understanding of what API is NOT:
- An API is not necessarily an external service. For instance, you can include libraries directly in your solution OR use them through an API
- An API is not just an interface. It’s both the specification/format and the implementation
- An API is not a GUI (graphical user interface). An API doesn’t do interactions on the graphical level. It solely operates on the programmatic layer. This can be either through a programming language, or a communication protocol.
In the context of the web, the API’s generally allow you to send commands to programs running on the servers that you connected to from your browser or with the browser itself. This allows you to access resources only available on the server (for instance, logins and passwords). An API isn’t the same as the remote server — rather it is the part of the server that receives requests and sends responses.
We will set an example provided by Petr Gazarov in his article:
If your small business’s website has a form used to sign clients up for appointments and you want to give your clients the ability to automatically create a Google calendar event with the details of that appointment.
- With API
Your website’s server talks directly to Google’s server with a request to create an event with the given details. Your server would then receive Google’s response, process it, and send back relevant information to the browser, such as a confirmation message to the user.
- Direct request without API
Your browser can send an API request directly to Google’s server bypassing your server.
The difference between these two ways is the format of the request and the response. To render the whole web page, your browser expects a response in HTML, which contains presentational code, while Google Calendar’s API call would just return the data. API allows you to complete the action without leaving the website.
Apart from what we’ve mentioned above, an API brings you more important benefits:
- Best practices
It allows you to leverage pre-existing logic you don’t have to write. Even super complicated things you might just not be able to code yourself (or your developers, if you a business owner). API’s landscape will bring you the best practices you can use.
- Saving time
Many development problems you’ll encounter have already been solved by someone before you. These existing solutions could be FaaS, libraries, web services, SDKs, content APIs. Whatever shape they take, you’ll most likely need an API to interact with them.
Types of APIs
There are many types of APIs, so we are unable to count all of them. But the most common types of APIs are
- Web APIs (known as Web Services). They provide an interface for web applications or applications that need to connect to each other via the Internet.
There are tens of thousands of public APIs that can be used to do everything from checking traffic and weather to updating your social media status or making payments.
There are also hundreds of thousands private Web APIs. These APIs are not available to be consumed by the general public; rather, they are used by companies to extend their services and capabilities across a broad range of use cases.
- SOAP (Simple Object Access Protocol) API is a messaging protocol that allows programs that run on disparate operating systems (such as Windows and Linux) to communicate using Hypertext Transfer Protocol (HTTP) and its Extensible Markup Language (XML)
- RPC (Remote Procedure Call) API. Most RPC variants commonly in usage for web APIs do not use HTTP to its full capabilities
- And the most popular—at least in name— Representational State Transfer (REST) API. REST leverages less bandwidth, making it more suitable for internet usage.
We don’t want to dive into official explanations of terms. You can find it yourself. But we will make an analogy for you to get the context of:
- API reference
- API call
- API endpoints
We will come back to the cafe again. You are at a cafe and you want to eat something specific (or a specific combination of a couple of things). You have in front of you a menu that the restaurant provides (an API reference). You can only order what is on the menu and nothing else. Also, you aren’t allowed to enter the kitchen and make your own food or ask the chefs to make whatever you want the way you like it. You’re only allowed to talk to the waiter and ask him for what you want (a thing or a combination of things from the menu) – the API call. Also, when you order for something, you can specify how you’d like to have it (for e.g. if you’re ordering a steak, you could have it rare, medium or well done) (analogous to the arguments you pass). The waiter will hear your language and write down (in his notebook) your order (API endpoints).If you spoke a different language, or he would not have a notebook, your order would be impossible. What happens in the kitchen is hidden from your view.
The Google Maps API is often used to build better user experiences with data based on real-time mapping and traffic signals.
The Twitter API can be used to filter and display targeted Tweets in real-time.
The Telegram API allows you to connect bots to our system.
An API is a treasure chest! By using APIs you can accelerate your velocity and widen your development scope whatever project you do. APIs are not necessarily bound to the web ecosystem. By searching for existing tools and checking the documentation of the API you want to use, you can benefit by reducing development time and adding more neat functionality to your product.
Remember that Syndicode is always ready to help your software development! Contact us if you have any questions.
Subscribe to our weekly newsletter to get more interesting information.