What is an API with Real-world Examples

Faizan AliFaizan Ali
3 min read

Have you ever wondered how companies like MakeMyTrip or Skyscanner lists the flights from different airlines on their websites and allow to book? The answer lies in APIs. In this guide i will walk you through what are APIs and how it makes our life easier.

API stands for Application Programming Interface. It acts as a middleman between client and server.

Problem:

There are 2 problems without API.

  1. Client and Server can not interact with each other if the programming languages are different.

    for example front end code is written in React and backend code is written in Java.

  2. Consider above example of MakeMyTrip, So the problem here is airline companies can not share their entire backend codebase just to allow MakeMyTrip to list and book the flight tickets.

To address these problems APIs came into picture.

How APIs solve these problems?

  1. APIs solve these problems because APIs are representation of data and it is independent of the language. So if the client and server are using different language still they can talk to each other using APIs.

  2. In this case, airline companies can expose an API and travel companies like MakeMyTrip can use that API to list/book the flight. Using this API they can sent the data to book the flight directly to airline company’s backend.

How do APIs work?

APIs work in a simple step-by-step process:

  • Request: A client (user) sends a request through the API's URI (Uniform Resource Identifier).

  • Processing: The API forwards the request to the server.

  • Response: The server processes the request and sends the response back to the API.

  • Delivery: The API returns the server's response to the client.

Types of API Architectures:

There are two types of API architectures.

  1. SOAP(Simple Object Access Protocol) : XML based communication to exchange data between applications.

  2. REST(Representational State Transfer) : A simple, flexible API architecture that uses HTTP methods (GET, POST, PUT, DELETE) for communication. REST supports XML as well as JSON.

What are REST APIs?

REST follows the constraints of REST architecture allowing interaction with RESTful web services. It defines a set of methods (GET, PUT, POST, DELETE) that clients use to access server data. The methods used are:

  • GET (retrieve a record)

  • PUT (update a record)

  • POST (create a record)

  • DELETE (delete the record)

Conclusion

By now, you must have an idea of What is an API, its working, types and what problems it solves. After understanding these concepts you can try to practice this on a tool called Postman so that you will have practical knowledge which you can use in your project or work.

0
Subscribe to my newsletter

Read articles from Faizan Ali directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Faizan Ali
Faizan Ali

Test Automation Engineer with 4 years of IT experience in Automation Testing and Manual Testing, specializing in Selenium WebDriver with Java and Rest Assured for API testing. Experienced in designing automation frameworks, executing regression and API test suites, and developing comprehensive test plans to ensure end-to-end test coverage. Contributed to a web application used by over 90,000 users and led key automation initiatives that reduced regression execution time by 60% and increased payment injection capacity from 20 to 6,000 per day. Skilled in defect management using Azure DevOps and mentoring new QA team members. Recognized with the Bravo Award for two consecutive years for outstanding contributions. Seeking opportunities to leverage my expertise in test automation, API testing, and framework development to deliver high-quality software solutions.