#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
HTTP

Characteristics of REST

REST (Representational State Transfer) is an architectural style for designing web APIs. It is not a library or a protocol but a set of constraints that, when followed, make an API predictable, scalable and easy for any client to use. When people call an API "RESTful", they mean it follows these characteristics, usually over HTTP with JSON.

Everything is a resource with an address

In REST, the things your API exposes, such as users, products or orders, are resources. Each resource or collection has its own URL, written as nouns rather than actions: /products for the collection and /products/42 for one item. The verb comes from the HTTP method, not from the URL, so you avoid paths like /getProduct or /deleteUser.

MethodURLMeaning
GET/productsList products
GET/products/42Read one product
POST/productsCreate a product
PUT / PATCH/products/42Replace or partly update it
DELETE/products/42Remove it

The six constraints

  1. Client-server: the user interface and the data storage are separated, so each side can change independently. A React app and a mobile app can share the same API.
  2. Stateless: each request carries everything needed to understand it, such as the auth token. The server does not remember previous requests from that client.
  3. Cacheable: responses state whether they can be cached, using headers like Cache-Control, so clients and proxies can reuse them and reduce load.
  4. Uniform interface: resources are identified by URLs, manipulated through representations like JSON, and responses describe themselves through headers and status codes.
  5. Layered system: the client cannot tell whether it is talking to the real server or to a load balancer, cache or gateway in between.
  6. Code on demand (optional): the server may send executable code to the client. It is the only optional constraint and rarely used in APIs.

Representations, not the resource itself

The "representational" part of the name means the client never receives the actual database row. It receives a representation of the resource, most often JSON. The same product could be represented as JSON for an app or HTML for a browser. The Content-Type header tells the client which format it got, and the Accept header lets the client ask for one.

GET /products/42 HTTP/1.1
Host: api.example.com
Accept: application/json
Authorization: Bearer eyJhbGciOi...

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=60

{ "id": 42, "name": "Desk lamp", "price": 899, "inStock": true }

Status codes carry meaning

A RESTful API uses HTTP status codes to describe the outcome: 200 for success, 201 for a created resource, 204 when there is no body, 400 for bad input, 401 when authentication is missing, 403 when it is not allowed, 404 when the resource does not exist, and 500 for server errors.

A design mistake to avoid

A very common anti-pattern is returning status 200 for everything and putting the real result inside the body, like { "success": false, "error": "Not found" }. Clients, caches and monitoring tools then believe every request worked. Use the correct status code and add a helpful message in the body as well. Another frequent slip is breaking statelessness by storing "current page" or "selected item" on the server between calls; send that information in each request instead.

Takeaway: model data as noun-based resources, let HTTP methods supply the action, keep every request self-contained, and use status codes and headers to describe what happened.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course