Mastering REST Architecture — REST API Details

1.) API

Application Programming Interface

2.) REST API

A REST API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.

* REST is a way for two computer systems to communicate over HTTP in a similar way to web browsers and servers.

* REST API defines a set of functions which developers can perform requests and receive responses via HTTP protocol such as GET and POST.

3.) The Anatomy Of A Request

It’s important to know that a request is made up of four things:

  1. The endpoint
  2. The method
  3. The headers
  4. The data (or body)
  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
HTTP Methods
Sending data as JSON

4.) HTTP Status Codes And Error Messages

HTTP status codes let you tell the status of the response quickly. The range from 100+ to 500+. In general, the numbers follow the following rules:

  1. 200+ means the request has succeeded.
  2. 300+ means the request is redirected to another URL
  3. 400+ means an error that originates from the client has occurred
  4. 500+ means an error that originates from the server has occurred

5.) API Versions

Developers update their APIs from time to time. Sometimes, the API can change so much that the developer decides to upgrade their API to another version. If this happens, and your application breaks, it’s usually because you’ve written code for an older API, but your request points to the newer API.

  1. Directly in the endpoint
  2. In a request header

Conclusion

  • An API is an application programming interface. It is a set of rules that allow programs to talk to each other.
  • REST determines how the API looks like. It stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API. REST uses URL to transfer the data. Each URL is called a request while the data sent back to you is called a response.
  • A request consists of 4 parts which are: The endpoint, the method, the headers, the data (or body).
  • HTTP status codes let you tell the status of the response quickly.
  • Developers update their APIs from time to time. You can request for a specific API version in two ways: directly in the endpoint, and in a request header.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ahmet Özlü

Ahmet Özlü

175 Followers

I am a big fan of Real Madrid CF and I love computer science!