20 API interview questions and answers to ace the interview
Tags: career, productivity, programming, api
Published: 2022-10-10 18:44:22

During coding interviews for software engineering positions, you will most likely be tested on your knowledge of Application Programming Interfaces (APIs). Therefore, it is critical to your success to demonstrate a strong understanding of API fundamentals, including how to interact with a web API using **HTTP requests, API testing, SOAP-based APIs, and [RESTful APIs](https://www.educative.io/blog/python-fastapi-tutorial?eid=5082902844932096)**.

This article will cover the **20 most commonly asked API interview questions** and the best ways to answer them.

We'll introduce a broad range of in-depth technical questions spanning various API verticals. We will also cover how an interviewer may expect you to approach most of these questions. This article targets both beginners and experienced developers.

**Let's get started!**

We'll cover:
1. [What is an API?](#what)
2. [What is a Web API and why is it used?](#used)
3. [What are the four types of Web APIs?](#types)
4. [What tests can help with APIs?](#tests)
5. [What is REST?](#rest)
6. [What is a REST API?](#restapi)
7. [Describe some key features of REST that a RESTful API must conform to](#conform)
8. [What primary markup language is used to represent resources in a REST API?](#primary)
9. [What is CRUD?](#crud)
10. [What are some practical examples of REST APIs?](#practical)
11. [What is SOAP?](#soap)
12. [What is the difference between REST and SOAP?](#difference)
13. [What is API authentication and how does it work?](#authentication)
14. [What is API testing?](#testingapi)
15. [What are some advantages of API testing?](#advofapi)
16. [Name some API testing tools](#testingtools)
17. [What are the common bugs found via API testing?](#bugs)
18. [What is API documentation?](#doc)
19. [What is Runscope?](#runscope)
20. [How are API testing and unit testing different?](#unit)

[Next steps for mastering APIs](#steps)

<a name="what"></a> 

## 1. What is an API?

_An interviewer may ask this question to **gauge your understanding of API and software system fundamentals**. You should at the very least, give them a brief API description with an example to support your reasoning._

An application programming interface (API) is **software that acts as an intermediary between applications** to help them communicate with each other using HTTP requests. For example, you could integrate the AccuWeather API into a web application to retrieve local weather data in real-time.

<a name="used"></a> 

## 2. What is a web API and why is it used?

Web APIs are a subset of APIs that make requests to a web server accessed via an HTTP protocol to retrieve data. 

We use web APIs for the following reasons:
- They have multiple layers that help standardize communication and provide different options for handling input and output.

- Web APIs are excellent for creating resource-oriented services.

<a name="types"></a>

## 3. What are the four types of web APIs?

_An interviewer can ask this question to test your comfort level with web APIs further. Again, describe a scenario where you used a Web API to stand out from other candidates._

**The different types of web APIs are as follows:**

- **Open APIs** are freely available to software developers or other users with little to no restrictions, such as usage without registration. 

- **Closed APIs** are not publicly available and are typically restricted to usage by the company that owns the API.

- **Partner APIs** are similar to open APIs, with the only exception being that feature access is restricted and controlled via third-party API gateways. 

- **Composite APIs** allow developers to access several endpoints at once. These endpoints could belong to one or more APIs. They help in cutting down time-consuming tasks by balancing server loads. 

<a name="tests"></a>

## 4.  Why is API testing important?

_This question may be posed to dig further into your knowledge of API testing._

API testing can be done to check for return values, validate inputs, and to test the functionality of an API in general. It's important because it enables you to check an API's **performance, reliability, and security.**

<a name="rest"></a>

## 5. What is REST?

REST stands for **Representational State Transfer**, an HTTP protocol-based architectural style used to create web applications. 

The REST protocol outlines several guidelines web services must follow in order to be deemed RESTful, including HTTP standardized methods to facilitate easy and efficient communication between clients and servers. 

<a name="restapi"></a>

## 6. What is a REST API?

A REST API is simply a web **API that uses a RESTful architectural style.** In a REST API, data is handled as a resource and represented by a unique Uniform Resource Identifier (URI).

<a name="conform"></a>

## 7. Describe some key features of REST that a RESTful API must conform to

**REST adheres to the following fundamental principles:** 

- **Loose coupling:** The client and servers in REST act independently. Clients can only make requests and servers send responses. All this is done without interdependence.

- **Uniform interface:** Client and server communications must follow the same HTTP protocol. Uniform interfaces simplify data requests and transfers because each application uses the same language.

- **Stateless:** A server will not store any data regarding past requests and responses in stateless server communication, saving memory load and improving performance in the process. 

- **Layered system:** The intermediary servers between client and API servers are layered servers. These servers in REST improve server performance.

- **Caching:** Resources are cached based on server responses, leading to performance improvement.

<a name="primary"></a>

## 8. What primary markup language is used to represent resources in a REST API?

The most common languages used to represent REST APIs are **XML** (extensible markup language) and **JSON** (JavaScript Object Notation).

<a name="crud"></a> 

## 9. What is CRUD?

**CRUD** is an acronym representing the four basic operations commonly performed in a relational database. 

**REST** supports each method in CRUD via the HTTP protocol. 

CRUD stands for: 

- **Create:** `POST` method in REST for creating a new database record

- **Read:** `GET` method in REST for reading information from a database

- **Update:** `PUT` method in REST for updating an object in a database

- **Delete:** `DELETE` method in REST to remove an item from a database

<a name="practical"></a>

## 10. What are some practical examples of RESTful APIs?

- **Google Maps Platform API:** Several mapping APIs are made available to developers via Google Maps. This is useful for creating web and mobile applications that require mapping functionality.

- **Weather APIs:** Weather apps broadcast information harnessed from public APIs such as OpenWeatherMap API.

- **Social APIs:** TikTok API, for example, uses APIs to extract real-time user information instead of web interfaces. 

<a name="soap"></a>

## 11. What is SOAP?

SOAP is an acronym for **Simple Object Access Protocol** and is a messaging protocol that relies on the XML data format to request and respond to messages.
It solely depends upon the XML schema and other technologies to implement its payload functionality.

SOAP also utilizes the **Remote Procedure Call (RPC)** pattern, where functions return results only after a parameter is passed. Additionally, both SOAP and RPC use XML to exchange data.

<a name="difference"></a>

## 12. What is the difference between REST and SOAP?

_SOAP and REST are similar in many ways and comparing them gives your interviewer a glimpse into your thinking process, especially when it comes to areas like troubleshooting._

**A few key differences between SOAP and REST are:**

![SOAP vs REST](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvvyvyxwjsakqczzy6rs.png)

<a name="authentication"></a>

## 13. What is API authentication and how does it work?

API authentication is the process of verifying that an API user has permission to access the data and resources they are requesting. It works by denying or blocking access to servers for unauthorized users when an identity mismatch occurs. For example, if you were to provide the wrong username, password, or another form of credential, then the API would be unable to verify your right to access data within its server.

API authentication is an excellent **security layer** that prevents cybercriminals from launching attacks on vulnerable systems. 

<a name="apitest"></a>

## 14. What is API testing?

_Interviewers are looking to see if you can recall fundamental concepts and put them into practice when they ask  API testing interview questions. Always be brief but descriptive in your answers._

API testing is a software testing strategy that ensures APIs are **stable, functional, reliable, and secure.** 

API testing works by analyzing the business logic, security, application, and data responses. 
An API test is generally performed by sending requests to one or more API endpoints and weighing them with expected results.
Some examples include:
- Validation 
- Security testing 
- UI testing  
- Functional testing     
- Load testing  
- Penetration testing  
- Runtime/error detection testing
- Integration testing  
- Fuzz and interoperability 
- Unit testing 

<a name="advofapi"></a>

## 15. What are some advantages of API testing?

_Describing advantages can showcase your critical thinking capabilities, which are helpful on the job. Ensure your answer demonstrates an understanding of when and where to apply a certain aspect of an API in a scenario._

- **Convenient:** API testing is less time-consuming than GUI testing- which is a software procedure for testing a graphical user interface, due to less code usage. It also offers more efficient and effective test coverage because it allows you to access the application without needing the user interface. 

- **Language-independent:** Because data transfer occurs via XML or JSON, language independence allows users to have flexibility in choosing coding languages needed for automation testing. 

<a name="testingtools"></a>

## 16. Name some API testing tools.

_This question once again tests your fundamental knowledge of APIs. List the tools you're familiar with, why you use them, and describe how you've used them in the past._

**Here are a few examples of popular API testing tools:**

* **Katalon** is a test automation tool that supports SOAP and REST requests

* **Postman** is used to test REST APIs and provides an interface for making HTTP requests and viewing the response

* **SoapUI Pro** is used to test SOAP-based APIs

* **Apigee** can be used to test both SOAP-based and RESTful APIs 

<a name="bugs"></a>

## 17. What are some common bugs found during API testing?

_This question tests the depth of your knowledge of using APIs practically. You should explain your understanding of a few situations where you encountered bugs during testing._

A few common bugs found during API testing include:

 * Missing or duplicate functionality
* Inconsistent error handling and detection
* Security issues
Unexpected error codes e.g wrong HTTP status codes 

<a name="doc"></a>

## 18. What is API documentation?

_Turning to API documentation when you're working with an unfamiliar API should be one of your first steps. You can explain the steps of your process to your interviewer to demonstrate resourcefulness and independent problem-solving skills._

API documentation is technical content that describes the API in detail. It includes everything you need to know about the API, from **effective integration to updates to the API lifecycle and test design and coverage**. It also includes a collection of resources, tutorials, and reference guides that enable developers to install and use an API. 

<a name="run"></a>

## 19. What is Runscope?

_Interviewers will ask this question to test your fundamental knowledge of API concepts. Being brief and clear in your response._

Runscope is a web application used to **monitor, debug, and for performance tests on web service APIs.** It provides an accessible interface and backend services to test APIs to ensure they work optimally.

<a name="unit"></a>

## 20. How are API testing and unit testing different?

_API testing and unit testing are different functions. It's important to be able to distinguish the two_

[API and unit testing](https://www.educative.io/blog/software-testing-types-101?eid=5082902844932096) are different in the following ways:

![Unit testing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nstp252ywge5con1n7rj.png)

<a name="steps"></a>

## Next steps for mastering APIs

Congratulations! You have taken the first step toward preparing for your interview by reading this bank of questions and answers about APIs. However, we've just touched on the surface of the topic of APIs. 

Where you want to go from here depends on your specific learning goals, but gaining hands-on experience with APIs is a great next step. To help you master working with APIs, Educative has created the [**Become an API Integrator**](https://www.educative.io/path/become-an-api-integratorhttps://www.educative.io/path/become-an-api-integrator?eid=5082902844932096) learning path to help you gain knowledge and skills that will diversify your API skillset. By improving these skills, you'll deepen your understanding of APIs for future interviews.

_Happy learning!_

## Continue learning about APIs and interview prep on Educative

* [7 best API courses for 2022](https://www.educative.io/blog/best-api-courses?eid=5082902844932096)
* [13 REST API interview questions you need to know](https://www.educative.io/blog/rest-api-interview-questions?eid=5082902844932096)
* [3 Features beginner devs overlook when building APIs](https://www.educative.io/blog/three-overlooked-api-features?eid=5082902844932096)

### Start a discussion 
What else do you hope to learn about APIs next? Was this article helpful? Let us know in the comments below!