Q6 of 37 · API testing

What is REST and what makes an API RESTful?

API testingJuniorapirestarchitecturefundamentals

Short answer

Short answer: REST is an architectural style for networked APIs based on stateless requests over HTTP, resources identified by URLs, standard verbs (GET/POST/PUT/DELETE), and typically JSON. A truly 'RESTful' API also follows constraints like cacheability, layered system, and uniform interface — most APIs are REST-ish, not strictly RESTful.

Detail

REST stands for Representational State Transfer. Roy Fielding's 2000 thesis defined six architectural constraints; in practice, APIs that satisfy most of them are called REST.

The constraints worth knowing:

  1. Client-server — separation of concerns. Client UI vs server data; either can evolve independently.
  2. Stateless — every request contains all the information needed to process it. The server doesn't keep client session state. Auth tokens travel on every request.
  3. Cacheable — responses are explicitly marked cacheable or not (Cache-Control headers). GET is cacheable by default.
  4. Uniform interface — resources identified by URLs (/users/42), manipulated via standard HTTP verbs, self-descriptive messages.
  5. Layered system — clients can't tell whether they're talking to the origin server, a CDN, or a load balancer. Proxies can be inserted transparently.
  6. Code on demand (optional) — server can ship executable code (rare in practice).

The "RESTful API" pattern most teams use:

  • URLs are nouns, not verbs. POST /users not POST /createUser.
  • HTTP verbs match intent (GET = read, POST = create, …).
  • JSON request/response bodies.
  • Status codes communicate outcome.
  • Plural collection URLs (/users), singular item URLs (/users/42).

Where most "REST APIs" technically aren't strict REST:

  • They lack HATEOAS (hypermedia links in responses pointing at next actions). Almost no production API does this rigorously.
  • They make stateful POSTs (POST /users/42/activate) — fine practically, not pure REST.

For testers, the practical bar:

  • Stateless: each test sets up its own auth; nothing leaks between tests.
  • Resource-shaped URLs: predictable to test.
  • Standard verbs and status codes: predictable to assert against.

The interview-worthy nuance: REST is a guide, not a religion. Most serious API testers know "what makes an API testable" matters more than "is this strictly REST."

// WHAT INTERVIEWERS LOOK FOR

Naming 3-4 of the constraints (statelessness is the big one), distinguishing REST-as-style from strict-Fielding-REST, and translating it to what makes an API testable.

// COMMON PITFALL

Listing constraints memorised from Wikipedia without explaining why each matters for testing. Statelessness in particular has direct consequences for test design.