REST APIs

REST is an architectural style that models functionality as resources addressed by URIs and manipulated with standard HTTP verbs; correct use of idempotent methods and status codes makes APIs predictable and cacheable.

Key formulas & points

Skim these first — then read the full notes below.

  • Status codes: 200 OK, 201 Created, 404 Not Found
  • Versioning via URL path or the Accept header
  • Rate limiting protects the backend from abuse

Topic details

Introduction

This topic covers designing web APIs. You map operations onto HTTP verbs, choose appropriate status codes, understand idempotency and statelessness, and handle cross-cutting concerns like versioning and rate limiting.

Key relations & formulas

Formulas (Indian textbook notation)

  • aRESTresourceisidentifiedbyaURI,representedinJSONorXMLa REST resource is identified by a URI, represented in JSON or XML

Formulas (Indian textbook notation)

  • idempotentmethods:GET,PUT,DELETE;POSTisnotidempotentidempotent methods: GET, PUT, DELETE; POST is not idempotent

Formulas (Indian textbook notation)

  • HATEOAS:responsesincludelinkstorelatedactionsHATEOAS: responses include links to related actions

Notation and sign conventions

Relation 1 —
aRESTresourceisidentifiedbyaURI,representedinJSONorXMLa REST resource is identified by a URI, represented in JSON or XML

Formulas (Indian textbook notation)

  • aRESTresourceisidentifiedbyaURI,representedinJSONorXMLa REST resource is identified by a URI, represented in JSON or XML
Write this relation with symbols exactly as in Deitel Web Dev — Standard reference before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
idempotentmethods:GET,PUT,DELETE;POSTisnotidempotentidempotent methods: GET, PUT, DELETE; POST is not idempotent

Formulas (Indian textbook notation)

  • idempotentmethods:GET,PUT,DELETE;POSTisnotidempotentidempotent methods: GET, PUT, DELETE; POST is not idempotent
Write this relation with symbols exactly as in Deitel Web Dev — Standard reference before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
HATEOAS:responsesincludelinkstorelatedactionsHATEOAS: responses include links to related actions

Formulas (Indian textbook notation)

  • HATEOAS:responsesincludelinkstorelatedactionsHATEOAS: responses include links to related actions
Write this relation with symbols exactly as in Deitel Web Dev — Standard reference before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.

Concept in depth

REST leans on HTTP’s existing semantics rather than inventing new ones: each resource has a URI, and the verb expresses the action — GET reads, POST creates, PUT replaces, DELETE removes. The idempotency distinction matters for reliability: a client can safely retry an idempotent GET, PUT or DELETE after a network failure because repeating it has no additional effect, whereas repeating a POST may create duplicates. Statelessness means each request is self-contained, which makes REST APIs easy to scale and cache. Meaningful status codes let clients react correctly (201 for a created resource, 404 for a missing one), and rate limiting guards shared backends.

Assumptions and validity limits

State assumptions explicitly before using any relation for rest apis — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Web Technologies viva and GATE descriptive questions, listing valid assumptions often earns separate marks.

Step-by-step problem approach

1. Read the question and list given data with SI units (common in Web Technologies papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to rest apis.
4. Use equation 1:
aRESTresourceisidentifiedbyaURI,representedinJSONorXMLa REST resource is identified by a URI, represented in JSON or XML
.
5. Use equation 2:
idempotentmethods:GET,PUT,DELETE;POSTisnotidempotentidempotent methods: GET, PUT, DELETE; POST is not idempotent
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.

Applications & exam relevance

REST APIs appears in web apps and REST APIs. In Indian it software curricula this topic is tested because it connects theory to front-end and back-end web stack.
GATE and semester exams often combine rest apis with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use rest apis?" — answer with a lab, mini-project, or plant visit example if possible.

Common mistakes in exams

Students misclassify POST as idempotent, use the wrong verb (GET to modify data), and return 200 for every response regardless of outcome. Making an API stateful (server-side session between calls) contradicts REST principles.

Quick revision checklist

Before attempting rest apis problems, confirm you can:
1. Status codes: 200 OK, 201 Created, 404 Not Found
2. Versioning via URL path or the Accept header
3. Rate limiting protects the backend from abuse
Revise the solved examples in Deitel Web Dev — Standard reference and one previous-year GATE or university paper for this unit.

Worked examples

Try the problem first — open the solution when you are ready to check.

Choosing an idempotent method

Problem

A flaky network may cause a client to retry a request that sets a user’s profile to a fixed value. Which HTTP method avoids duplicate side effects?

Solution

Use PUT: it is idempotent, so repeating the same profile update yields the same final state. POST could create duplicates on retry and is the wrong choice here.

Conceptual check — REST APIs

Problem

In a Web Technologies semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of rest apis." What should a complete answer include?

📖 Standard books (India)

  • Deitel Web DevStandard reference

    Read: Syllabus unit

    Referenced in Indian B.Tech syllabus