Modeling your REST API responses

Nelson Parente
7 min readMay 17, 2020
Photo by Christopher Burns on Unsplash

As an Engineer, I strongly believe that standardization has lots of benefits and we should always follow the industry standards for good. One case where I believe that the standards should be followed is when modeling a REST API HTTP response codes for its endpoints.

In this blog post, I’ll talk about HTTP methods, HTTP response codes, and present a simple REST API response code modeling for the most commonly used HTTP methods.

The HTTP response code modeling in an API is like making a puzzle, you need to make be sure that in each endpoint the returned response code is explicit of what happened for the consumer to be able to rightly react to the response.

REST stands for representational state transfer, this concept was first introduced by Roy Fielding in its dissertation, the principles introduces by Fielding were used in the design of HTTP 1.1 and with it, the HTTP methods were first defined.

For the sake of simplicity, in this blog post I’ll maintain the focus on the most commonly used HTTP methods, these are:

  • GET: Transfer a current representation of the target resource.
GET /cars/1001 HTTP/1.1
HOST: https://carstand.api.tech
  • POST: Perform resource-specific processing on the request payload.

--

--