What are APIs? This is what you need to know to take advantage of them.

An API (Application Programming Interface) is an interface that allows apps and software programs to communicate and share data. APIs can be public or private. Basically, it means enriching your app by taking advantage of other businesses’ development.

Let’s explain this better with an example…

Let’s suppose we want to develop a transport app, like Google, that tracks the car’s location in the city. In that case, we would need maps and geolocation.

To make maps, we would need a great deal of money to develop maps from scratch. So, the best thing to do is to connect to Google Maps and use its maps, taking advantage of the fact that they have already spent a lot of money in satellite images, cameras, etc. to create them. We can benefit from this entire development for an app.

Another example could be if we want to develop an e-commerce project and we need to include means of payment. For this, we can connect to a payment gateway (depending on the one used in your country).

Connecting your app to others gives it much more power than if it were a simple isolated app, since we can include as many functionalities as we can imagine.
To better understand what APIs are, we need to understand the following concepts:

  • Interface: It’s an abstraction layer for two systems to communicate. A layer allows us to interact with a system without the need to know what’s going on underneath. A clear example of this are login forms, where we can interact fast with a website without knowing the mechanics of what’s behind.
  • Software Architecture: It’s the way in which a system is designed, how its components are organized, how they communicate with each other, what roles they play, etc.
  • Web Service: It’s a system that allows communication between devices that are in a network. They have to follow certain standards (use HTTP protocol). It’s the basis of remote APIs, of communication between programs that are in different places.
  • REST: It’s an architecture that means that data can be stored in cache, that the state isn’t sent in requests and that you can define which data you allow other apps to access, review or manipulate from your app. There are several types of APIs. One type is REST API, which is a representational state transfer (REST) where permits are defined. This type is the most widely used.
  • XML: It’s the traditional format generally used to send data, though the format that is most widely used nowadays to transfer information is JSON.
  • TOKEN: To authenticate in an app, the server returns a token, that is nothing more than an object that contains all data of this authentication.

Types of APIs

  • Local: They run within the same environment, everything that takes place is local.
  • Remote: You consume data from an app that is in another place. They can use web services utilizing Service-Oriented Architecture (SOA), which isn’t so widely used, or REST architecture.

 

Good practices for developing an API

  • HATEOAS (Hypermedia as the Engine of Application State): The API describes itself. Each resource has information about which is the next resource or about the number of total resources.
  • SECURITY: APIs must be protected; otherwise, somebody could gain access to your information, obtain private or users’ data bases or even manipulate them.
  • TEST: To check that everything works properly so that people who consume the API can find the information they need.
  • DOCUMENT: If you create an API, you do it for somebody to consume it, so you have to document it.

Thank you very much for getting here. We hope this material has been useful! If so, don’t forget to share the blog with your colleagues, like the post on social media or comment on your return.