top of page
Search

What is an API?

It is inevitable that, regardless of the tech career you choose to pursue, you will hear about APIs. Knowing well the concept of API, how they work, the types and possibilities of application can help you a lot on several occasions. It's APIs we're going to talk about today!



What is a API?


An API, often also called a microservice, is a piece of code that performs some task and that connects to other computers over the internet. To make this concept clearer, let's look at an example:


Think of a code snippet that performs the calculation of a quadratic equation. The point that defines that a code with this function is an API is: this code is capable of receiving data through the web (in which case it could, for example, receive the values ​​of each variable in the equation) and after processing, it returns the result from the equation to the applicant also via the web.


If a code is able to carry out this "conversation" between a machine that makes a request and another that returns a value from that, we can define that code as an API.


In fact, the moment when you start working with APIs is often a very euphoric moment in the life of those who like software development, especially in the backend part. The possibility of connecting with APIs from all over the world, which perform the most different operations and are available to your access in a relatively easy way, is something that hardly goes unnoticed. The first successful request we never forget!



Practical example of an API application:


API for the Brazilian CRM consultation (Regional Council of Medicine).


CRM is nothing more than a registration that all doctors in Brazil need to have in order to legally act in their office. This API is officially maintained by the Federal Council of Medicine and from two simple attributes it is possible to receive a return on the validity of the registration of any doctor in Brazil.


For this, a query must be made to this API sending the following data: UF and CRM number (The CRM registration number is unique within the UFs). And the return of this API is the data referring to the doctor corresponding to this search. Data such as: registration status, FUs in which it has a record, date of registration, among other relevant information, for example when it is necessary to validate medical records many times.

Imagine a large company with 10,000 employees in its various units. Imagine how many different certificates have to be validated during a year and how much time it takes to make this consultation manually on the CFM website, where it is necessary to manually enter the doctor's record, name, state, city, etc.


Through this API, it is possible for this verification to be done automatically, saving a lot of time and also reducing the possibility of typing errors, among others. In other words, value is added by saving time.


How is this conversation between different computers over the web done?


The idea in this post is to give a more conceptual view of this process. So you have the following structure:


1 - A code hosted on some server that expects to receive a data request. In the case of the CRM query API, the code expects the CRM registration and the UF. But we can have code that waits only for the request, without any parameters: think of an API that returns the dollar price in real time, it does not depend on any data you send to work, so it is possible to make a request without passing attributes.


2 - A code that makes the request. As well as timing APIs that expect some parameter to be passed when a request is made and others that don't. Code times that make requests sending parameters and others that don't, depending on the API being consulted.


So you might ask yourself:

"Wow, but that's not a problem? How does one computer request things and the other understands? Just send the variables that the computer where the API is hosted waits as I want and it will return everything right?"

In fact, there are a few ways to ensure that these two codes understand each other. One of them is JSON.


JSON or JavaScript Object Notation is nothing more than a way of writing the data. In the case of using JSON, we will have a code expecting data in JSON and, therefore, the code that will make a request must also send the parameters in JSON. After all, it is JSON that is being expected.


There is not just JSON on the market. There are other different ways to communicate via the web between two machines such as XML and YAML, however, JSON is one of the most used along with XML, both for the practicality of the notation and because of performance issues.



But is this available in any programming language?


I don't guarantee that in 100% of the world's programming languages. But if this language already has more than 50 people coding in it, most likely it already has a library that allows this type of operation. All kidding aside, yes, Java, Python, PHP, and every other major language on the market. It is through web requests that the connection of an application with the world is made, in this way, it is something more than fundamental.


That way, there's probably little to stop you from venturing out making requests to APIs and connecting your code with the world.


I hope I have helped you to understand the API concept a little better. Share your experiences with us on our social media! See you soon!

Commenti


Como está o seu currículo?

Ter um bom currículo é uma fator chave para você ter seu trabalho reconhecido perante o mercado de trabalho.

 

Sabemos que elaborar um bom currículo que descreva bem suas habilidade e suas expectativas pode ser uma tarefa muito complicada.

Clique no botão abaixo para ter todo o suporte necessário na elaboração de um currículo nota 10.

Como está o seu currículo?

Ter um bom currículo é uma fator chave para você ter seu trabalho reconhecido perante o mercado de trabalho.

 

Sabemos que elaborar um bom currículo que descreva bem suas habilidade e suas expectativas pode ser uma tarefa muito complicada.

Clique no botão abaixo para ter todo o suporte necessário na elaboração de um currículo nota 10.

Sobre o Autor

"Olá meu nome é Tiago Stasaitis, sou formado

Técnico em Informática e bacharel em Sistemas de Informação.

   

Fundei o Acadêmico Tech no intuito de compartilhar conteúdo que pode ajudar pessoas a se desenvolverem pessoal e profissionalmente. "

1633903387510.jpg
  • LinkedIn - Black Circle
  • Instagram
bottom of page