Skip to content

Instantly share code, notes, and snippets.

View satyendra-singh-talentica's full-sized avatar

Satyendra Singh satyendra-singh-talentica

View GitHub Profile
@mayank-kansal15
mayank-kansal15 / REST best practices
Last active May 16, 2022 07:36
This gist explains about the REST best practices and how to write pragmatic REST APIs.
# WHAT IS REST?
REST stands for Representational State Transfer. It’s a software architectural style for implementing web services. Web services implemented using the REST architectural style are known as the RESTful Web services.
In REST we transfer representation of a resource in a particular state at a point in time, that's why it is called REST.
For example: GET /v1/articles/123, transfer article 123 representation in JSON format in the state when API is hit.
REST use HTTP as a communication protocol, HTTP is a stateless protocol so should be REST. It means two REST APIs should be treated completely independent on server, both APIs should be authenticated and authorized, don't store anything from the first API call in server memory to be used by further API calls.
RESTful APIs are written for consumers. The name and structure of URIs should convey meaning to those consumers. Although your internal data models may map neatly to resources, it isn't necessarily a one-to-one mapping. The key here is to no