API Design — HTTP Status Code cheat sheet

Eden Avital
2 min readJan 28, 2023

--

HTTP response status codes indicate whether a specific HTTP request has been successfully completed — by MDN Web

As a web developer, you will probably need to deal with consuming or creating an API. (Application Programming Interface)
API usage is very common, you can fetch data for displaying content on your website, to automate tasks and processes, to allow other developers to access your data sources, to create complex ETL (Extract, Load and Transform) process and etc.

After an API request has ended, it will retrieve a response to the consumer, including a HTTP status code.

HTTP (Hypertext Transfer Protocol) codes are standardized status codes that indicate the result of an HTTP request. These codes help web developers understand the outcome of their requests and troubleshoot any issues.

Here are some of the most common HTTP codes:

  • 200 OK: Indicates that the request was successful and the requested information has been returned.
  • 201 Created: Signifies that the request has been fulfilled and a new resource has been created.
  • 204 No Content: Returned when the request has been successfully processed, but there is no information to return.
  • 301 Moved Permanently: Indicates that the resource the client requested from the server has permanently moved to a new location.
    The response should also include the new location, and the client should use this new URL the next time it tries to fetch the same resource.
  • 400 Bad Request: Indicates that the request was invalid or could not be understood by the server.
  • 401 Unauthorized: Returned when the user lacks the necessary credentials to access the requested resource.
  • 403 Forbidden: Returned when the server understands the request, but refuses to fulfill it due to insufficient permissions.
  • 404 Not Found: Returned when the requested resource could not be located on the server.
  • 409 Conflict: A client error that is returned by the server to indicate that the request can not be satisfied because the current state is incompatible with what is required.
    The response from the server may contain information in the message body that the client can use to resolve the conflict.
  • 500 Internal Server Error: Returned when the server encounters an error while processing the request.
  • 503 Service Unavailable: Indicates that the server is temporarily unavailable and unable to handle the request.

These are just a few examples of the many HTTP codes available. It’s important for web developers to understand the meaning of each code and how they can respond appropriately.

In conclusion, HTTP codes play a crucial role in the communication between client and server in web development. They provide valuable information about the success or failure of requests and allow developers to troubleshoot and optimize their applications.

--

--

Eden Avital

Hello there, my name is Eden, and I'm a Full Stack Developer at Palo Alto Networks. I build web applications with various types of technologies.