Course contentsShow
← Software Engineering
Lesson 760 of 1,93324. REST API DesignFree lesson

Resource Identification in Requests

Resources are identified by URIs; requests manipulate resources through their representations.

Resource Identification in Requests

What you'll learn: How REST APIs use URIs to identify and manipulate resources through their representations.

The Core Idea

In RESTful systems, every resource (a piece of data or functionality your API exposes) must have a unique identifier—a URI (Uniform Resource Identifier). When clients make requests, they target specific resources using these URIs. Importantly, clients never directly manipulate the resource itself; instead, they work with representations of that resource (typically JSON or XML).

Think of it like a library system: each book has a unique call number (the URI). When you request a book, you don't handle the master catalog entry itself—you get a physical copy (a representation). You can read it, annotate your copy, or return it with changes, but you're always working through that representation, not the original catalog record.

URIs as Resource Addresses

A URI like https://api.example.com/users/42 identifies a specific user resource (user with ID 42). The URI path structure should be intuitive:

  • /users – the collection of all users
  • /users/42 – a specific user
  • /users/42/orders – orders belonging to that user

The request method (GET, POST, PUT, DELETE) combined with the URI tells the server what operation to perform on which resource. The server responds with a representation of that resource's current state (for reads) or confirmation of changes (for writes).

Why This Matters

This constraint enforces a clean separation: clients know where resources live (URIs) and how to interact with them (representations), but don't need to know internal storage details. The API can change its database structure completely without breaking clients, as long as URIs and representations stay consistent.

Key Takeaway: Resources are identified by URIs in REST; clients manipulate resources by exchanging their representations, not by directly accessing underlying data structures.