Welcome back. In our last lesson, we mastered the "verbs" of RESTful communication—the HTTP methods and the crucial concept of idempotency. We established how methods like GET, POST, PUT, and DELETE define the actions performed on data. Now, it's time to design the "nouns" these verbs act upon.
Today's lesson addresses the learning outcome: Design RESTful API endpoints following resource naming and URI conventions. We will explore how to structure clean, predictable, and intuitive Uniform Resource Identifiers (URIs). For backend interviews, a well-designed set of endpoints demonstrates clarity of thought and adherence to industry-standard practices, signaling that you can build systems that are easy for other developers to understand and consume.
The Foundation: Resources as Nouns
In the world of REST, everything revolves around the concept of a resource. A resource is simply a representation of any "thing" or entity your system manages—a user, a product, an order, or a blog post. The URI is the unique identifier for that resource.
The single most important rule in RESTful URI design is: URIs identify resources (nouns), not actions (verbs). The action is communicated by the HTTP method we covered previously.
Let's look at the anatomy of a typical endpoint URI.

Our focus today is on the resource and parameter parts of this URI.
The following article from restfulapi.net provides an excellent foundation for thinking about resources.
REST API URI Naming Conventions and Best Practices
This article clearly defines what a resource is in REST and introduces the important distinction between singleton, collection, and sub-collection resources. It then lays out the fundamental principle of using nouns.
Start by reading the section What is a Resource? to understand the different types of resources. Then, read the first part of the best practices section, Use nouns to represent resources, which explains how to categorize resources and name them consistently.
As the article states, a resource can be a collection (e.g., /customers) or a singleton (e.g., /customers/{id}). This is a core concept. A common convention, and one you should follow in interviews, is to always use plural nouns for your resource collections. This keeps your API paths consistent and predictable.
For a great interview-centric perspective on this, the following video by a Meta Staff Engineer is invaluable.
API Design in System Design Interviews w/ Meta Staff Engineer
This video frames API design specifically for system design interviews. It emphasizes using REST as the default and clearly explains how resources, represented by plural nouns, map to the core entities of your system.
Watch from the introduction to REST. Pay close attention to the explanation of what a resource is (starting at 4:29) and the rule about using plural nouns. Notice the example of what not to do (POST /events/create).
To summarize the key rule:
- DON'T:
POST /createUser - DO:
POST /users
The URI identifies the collection of users, and the POST method clearly signals the intent to create a new one within that collection.
Structuring URIs: Hierarchy and Readability
Once you've identified your noun-based resources, you need to structure them in a clear, hierarchical way. The principles for this are straightforward and focus on predictability and ease of use.

Let's break down these principles.
1. Use Forward Slashes for Hierarchy
The / character indicates a hierarchical relationship. You can use this to navigate from a collection to a specific instance or to a related sub-collection.
GET /users— Retrieves a list of all users.GET /users/123— Retrieves a single user with ID 123.GET /users/123/orders— Retrieves a list of all orders belonging to user 123.GET /users/123/orders/456— Retrieves a single order with ID 456 belonging to user 123.
While nesting is powerful, it's wise to follow the principle from the image above: Keep hierarchy shallow. Generally, nesting more than two or three levels deep (/resource/id/sub-resource) can lead to long, unwieldy URIs and may indicate that your resource model is too complex.
2. Use Hyphens for Readability
When a resource name contains multiple words, use hyphens (-) to separate them. Avoid underscores (_) as they can be less visible, and avoid camelCase (multiWord) as it's inconsistent with the DNS host naming convention.
- DON'T:
/blog_postsor/blogPosts - DO:
/blog-posts
3. Use Lowercase Letters
RFC 3986 specifies that URI paths are case-sensitive. To avoid confusion and potential errors, the established convention is to use only lowercase letters in your URI paths.
- DON'T:
/Users/123/Orders - DO:
/users/123/orders
4. Avoid Trailing Slashes and File Extensions
A trailing slash (/) adds no semantic value. Is /users/ a different resource from /users? To avoid ambiguity, the convention is to omit it.
Similarly, don't include file extensions like .json or .xml in your URIs. The format of the data should be determined through content negotiation using HTTP headers (e.g., the Accept header). The URI should represent the resource itself, not its format.
- DON'T:
/users/123.json - DO:
GET /users/123(with anAccept: application/jsonheader)
The following short video provides a great summary of these formatting best practices, framing them for an interview context.
REST API Interview Questions (Beginner Level)
This video from Exponent quickly lists five best practices for URI design in a direct, easy-to-remember format.
Watch the very concise section on best practices from 3:02 to 3:28. This will reinforce the rules we've just discussed.
For a more detailed written reference on these conventions, you can consult the following article.
REST API URI Naming Conventions and Best Practices
This article dives deeper into the formatting rules we've covered, providing clear examples and justifications for each.
Read through the sections on formatting conventions, avoiding CRUD names, and using query parameters for filtering. This will solidify your understanding of these practical rules.
Path Parameters vs. Query Parameters: A Critical Distinction
A common point of confusion—and thus a great interview topic—is when to put a parameter in the URI path versus in the query string. The rule is simple and logical.
API Design in System Design Interviews w/ Meta Staff Engineer
The same video from the Meta engineer provides an excellent, clear distinction between path parameters, query parameters, and the request body.
Watch the segment explaining API inputs. Focus on the rationale for when to use a path parameter versus a query parameter.
As the video explains:
-
Path Parameters are used to identify a specific resource or resources. They are not optional and form a core part of the resource's identity.
- Example:
GET /users/{userId}— TheuserIdis required to identify the user. - Example:
GET /users/{userId}/orders/{orderId}— Both IDs are required.
- Example:
-
Query Parameters are used for optional filtering, sorting, or paginating a collection of resources. They refine the request but don't change the fundamental resource being accessed.
- Example:
GET /orders?status=shipped&sort=date_desc— Here, we are still accessing theorderscollection, but we are filtering and sorting the results. - Example:
GET /products?category=electronics— This filters theproductscollection.
- Example:
Think of it this way: the path gets you to the "aisle" in the store (the resource collection), while the query parameters help you find specific items on the shelves in that aisle.
Putting It All Together
Let's combine everything we've learned in this lesson and the previous one. Imagine you're in an interview and asked to design the API endpoints for managing articles in a blogging platform.
Here is what a well-designed set of RESTful endpoints would look like:
| HTTP Method | URI Path | Action |
|---|---|---|
POST |
/articles |
Create a new article. |
GET |
/articles |
Retrieve a list of all articles. |
GET |
/articles?author-id=123&tag=go |
Retrieve articles by author 123, tagged with "go". |
GET |
/articles/{articleId} |
Retrieve a single article by its ID. |
PUT |
/articles/{articleId} |
Completely replace an existing article. |
PATCH |
/articles/{articleId} |
Partially update an existing article. |
DELETE |
/articles/{articleId} |
Delete an article. |
GET |
/articles/{articleId}/comments |
Retrieve all comments for a specific article. |
POST |
/articles/{articleId}/comments |
Create a new comment for a specific article. |
Notice how all these endpoints adhere to the principles:
- Nouns:
articles,comments. - Plural: All collections are plural.
- Hierarchy:
/articles/{articleId}/commentsshows a clear relationship. - Formatting: Lowercase, no verbs, no file extensions.
- Parameters: Path parameters for IDs (
{articleId}), query parameters for filtering (?author-id=123).
Conclusion
In this lesson, we've built upon our knowledge of HTTP methods to design the structure of RESTful URIs. You now have a complete framework for defining the "what" (resources) and the "how" (HTTP methods) of an API. A developer who sees an endpoint like GET /users/123/orders should immediately understand its purpose without needing extensive documentation, and that is the hallmark of a great API design.
Key Takeaways:
- Resources are Nouns: URIs should represent entities (
/users), not actions (/getUsers). - Use Plural Nouns: Conventionally, collections are named with plural nouns for consistency (e.g.,
/articles, not/article). - Hierarchy with Slashes: Use
/to show relationships, but keep nesting shallow (2-3 levels max). - Consistent Formatting: Use lowercase letters and hyphens for multi-word resources. Avoid trailing slashes and file extensions.
- Path vs. Query Parameters: Use path parameters for required identifiers (
/articles/{id}) and query parameters for optional filtering, sorting, or pagination (/articles?status=published).
In our next lesson, we will complete the request-response cycle by learning how to select appropriate HTTP status codes for success, client error, and server error scenarios. This will enable you to design APIs that communicate their results clearly and effectively to clients.