What is a REST API and Best Practices for REST API Design

Danushka Malinga
2 min readMay 15, 2022

--

REST API

What is REST API? 🤨

Sounds like the rest we all know 😆. No, REST in here stands for the REpresentational State Transfer .

Still don’t quite understand, do you? 😂That's totally ok.

Enough of geek words and lets see what is REST, RESTful API and how can we design a REST API with best practices in plain English. 😀

Ok, if you read this you need to have the basic understand of what web service and what API is.

A web service is a set of open protocols and standards that allow data to be exchanged between different applications or systems.

API stands for Application programming Interface. 👀

API is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software.

So you have a question whether the APIs and the Web Services are the same?

The key distinction is that web services are a type of API: All web services are APIs, but not all APIs are web services.

So REST is a architectural style that use to build web services.

Web service is a type of API

And the API build with REST architecture known as RESTful API.

REST means Representational State Transfer .

REST is an architectural style for building distributed systems based on hypermedia. REST is independent of any underlying protocol and is not necessarily tied to HTTP. However, most common REST API implementations use HTTP as the application protocol

Rest APIs are designed around resources . which refers to any object, data, or service that the client can access.

Every resource has an identifier and they are uniquely identifies by URIs.

Client interact with RST API by exchanging the representation of the resource.

REST aims to improve scalability, simplicity, modifiability, visibility, portability, and dependability. This is accomplished by adhering to the REST principles.

Below is the complete diagram to understand REST API created by Sharma.

REST API Design

The Six Principles / Constraints

  1. Client-Server
  2. Stateless
  3. Cacheable
  4. Layered System
  5. Code-on-Demand
  6. Uniform Interface

Best Practices

  1. Keep it Simple and Fine-Grained
  2. Filtering & Ordering
  3. Versioning
  4. Cache
  5. Pagination
  6. Resource-Naming
  7. Security

References

--

--

Responses (1)