What exactly is an API? What does an API Do?

An API stands for?Application Programming Interface, is a set of definitions and protocols that allow technology products and services to communicate with each other via the internet.

An API (Application Programming Interface) allows your application to interact with an external service using a simple set of commands. To break down the name, the “Interface” is where different software components can interact.

What is APIs Used For?

Essentially, an API allows two software programs to communicate with each other. One program can call another program’s API to get access to data or functionality of the other program.

To understand exactly how an API works, consider this non-technical example.

When you go to a restaurant, a waiter will take your order and report it to the kitchen. The kitchen makes your food, and the waiter brings it back to your table.

In this example, one program is you (the person ordering food), and one program is the kitchen. The waiter represents the API, that is used to receive requests and return something. In this case, the waiter returns your order, but an actual API would return data or other functionality.

What are Some Examples of APIs? API Examples and Use Case

Now that we have a basic understanding of APIs, it should be easier to see why APIs are so essential in programming. For a slightly more technical example, consider how APIs might play out using a ride-share app as an example. First, you sign up for the ride-share application. Then, you can map your route, find your driver, and pay for the ride all without ever leaving the app.

The ride-sharing app is likely using APIs to make all of this work. For example, an API like Telesign could verify that you own the phone number you provided at sign up. Calculating the time and distance of the ride is probably done with a maps API. An SMS API like Nexmo could notify you that the driver has arrived at the pickup location. When it’s time to pay, your payment is likely processed with an API like Stripe. Finally, when you get a receipt for your ride, an API like SendGrid sends it to your email.

Different Types of APIs

There are four main types of APIs:

  1. Open APIs:?Also known as Public APIs. These APIs are publicly available and there are no restrictions to access them.
  2. Partner APIs:?These APIs are not publicly available, so you need specific rights or licenses to access them.
  3. Internal APIs:?Also known as Private APIs. These APIs are usually meant for use within a company and are only exposed by internal systems. A company can use this type of API across different internal teams to be able to improve its products and services.
  4. Composite APIs:?These APIs combine different data and service APIs. It is a sequence of tasks that runs synchronously as a result of the execution and not at the request of a task. The main purpose of this type of API is to speed up the process of execution and improve the performance of the listeners in the web interfaces.

Web Service APIs

Apart from the main web APIs, there are also web service APIs. A web service is a system or software the uses an address (ex: the URL on the World Wide Web) to provide access to its services. The most common types of web service APIs include:

  1. SOAP (Simple Object Access Protocol):?This is a protocol that uses XML as a format to transfer data. Its main function is to define the structure of the messages and method of communication. It also uses WSDL (Web Service Definition Language) in a machine-readable document to publish a definition of its interface.
  2. XML-RPC: This is a protocol that uses a specific XML format to transfer data, compared to SOAP that uses a proprietary XML format. It is also older than SOAP. XML-RPX uses minimum bandwidth and is much simpler than SOAP.
  3. JSON-RPC:?This protocol is similar to XML-RPC, but instead of using an XML format to transfer the data it uses JSON.
  4. REST (Representational State Transfer):?REST is not a protocol like the other web services. Instead, it is a set of architectural principles. The REST service needs to have certain characteristics, including simple interfaces, which are resources identified easily within the request and manipulation of resources using the interface.









要查看或添加评论,请登录

Sahu Testing Expert的更多文章