API Development Interview Questions And How To Answer Them

3 years ago

Do you know the difference between the MVC and MVVM design patterns? Can you describe what REST is in terms of HTTP? Do you know what OAuth2 is used for?

If you're a developer looking to land your next big project, then these are just some of the interview questions that await. In this post, we'll talk about some of the most important API development interview questions and how to prepare for them.

What is the MIME type for a JSON response?

This is application/json, as defined in RFC 7159. 

When does an API require authentication and which HTTP methods does it support? 

An API may require authentication for any of its resource routes, but only supports basic or digest authentication - as defined by RFC 2617 and RFC 2616 respectively.

Which HTTP method may be used to create or modify resources?

The POST method may be used to create or update resources on a server and propagate the request state by the server through a Location header, as defined by RFC 2616.

Briefly explain the different types of output observed from an API.

Answer: The API is considered the essential connecting element of this digital world. It essentially resides in the business logic layer where it performs functions such as order processing, application coordination, launching logical decisions, and more.

The main consideration is to return correct results in all types of conditions. Mainly, the output or observed results of an API are divided into three sections as follows:

Returns earnings statement values such as "Passed" or "Failed".

Result in the form of specific data or information.

An event where the call to any API function will initiate the call to another API function.

Which HTTP methods are idempotent?

The GET, HEAD, OPTIONS and TRACE methods are idempotent - as defined by RFC 7231.

Which HTTP method may be used to remove a resource?

The DELETE method may be used to remove a resource and propagate the request state by the server through a Location header, as defined by RFC 2616.

Which HTTP method is safe against cross-site request forgery?

The "OPTIONS" method is safe against cross-site request forgery. An attacker cannot cause changes in the user's data on another domain with this method, as defined by RFC 7231.

Which HTTP method is safe against cross-site scripting attacks?

The "GET" and "HEAD" methods are safe against cross-site scripting attacks. An attacker cannot cause changes in the user's data on another domain with these methods, as defined by RFC 7231.

Which HTTP methods may be used in a PUT request?

The PUT method may only be used to update resources on a server, and propagate the request state by an HTTP response code of 201 Created, as defined by RFC 7231.

Which HTTP method(s) may be used in a POST request?

The POST method may be used to create or update resources on a server and propagate the request state by an HTTP response code of 201 Created, as defined by RFC 7231.

Which HTTP method may be used in a DELETE request?

The DELETE method may only be used to remove resources from a server and propagate the request state by an HTTP response code of 200 OK, as defined by RFC 7231.

Which HTTP method is safe against denial of service attacks?

The "OPTIONS" method is safe against denial of service attacks. An attacker cannot cause changes in a user's data on another domain with this method, as defined by RFC 7231.

Which HTTP methods may be used in a PATCH request?

The "PATCH" method may only be used to change a resource's attributes, and propagate the request state by an HTTP response code of 200 OK, as defined by RFC 7231.

Which methods may be used to use HTTP to access a TLS-secured HTTPS endpoint?

The only HTTP methods supported by Automated Testing Labs that can be used for accessing HTTPS endpoints are POST, GET, PUT, DELETE, and OPTIONS.

Which HTTP methods may be used to perform an ETag?

The GET, HEAD, OPTIONS and TRACE methods are idempotent - as defined by RFC 7231.

Which HTTP method may be used to perform a conditional request?

The "GET" method may be used in a conditional request, as defined by RFC 7232.

Which HTTP methods may be used to authenticate a request with an Authorization header?

Basic Authentication and Digest Authentication - as defined by RFC 2617 and RFC 2616 respectively - may be used with the "Authorization" header.

Which HTTP methods may be used to perform a conditional response?

The 304 Not Modified and 412 Precondition Failed HTTP response codes - as defined by RFC 7232 - may be used in a conditional request.

What is the difference between SOAP and REST?

SOAP is an XML-based web service that is typically used to exchange structured information over HTTP. REST is an architectural style for applications built on the World Wide Web, that focuses on keeping those applications stateless and letting them use hypermedia controls to discover and manipulate data.

What is REST and RESTFUL?

REST is a style of web architecture derived from the ideas behind hypertext transfer protocol (HTTP). RESTful means that the interactions with the server must be based on the same principles as it's used for hypertext. It requires that a server respond to GET, PUT and DELETE requests, with an HTTP response code of 200 OK.

What is a SOAP message?

SOAP is an XML-based web service that is typically used to exchange structured information over HTTP.

What is the difference between PUT and POST?

The PUT method is idempotent, which means that the server must be able to handle a request in which any given set of input data results in identical output data. The POST method, however, is not idempotent as defined by RFC 7231.

Which protocol did the W3C use to create a concrete standard to describe RESTful web services?

The W3C used the HTTP protocol for creating a concrete standard to describe RESTful web services.

What is an idempotent Method?

A method is idempotent if and only if it has as its result the same result when given the same input.

How many methods can be used to express a request using HTTP? 

1 - the GET method, as defined by RFC 7233.

2 – The OPTIONS request, as defined by RFC 7231.

Interesting? Share it