Good Practices for endpoints

Separate Words with Hyphens

When a REST API endpoint contains multiple words (e.g. https://api.example.com/users/123/first-name), you should separate the words with hyphens. It’s a good way to make the URI easier to read and is a universal method that everyone can understand.

It’s generally accepted that a hyphen is clearer and more user-friendly than using underscores (e.g. first_name) or camel case (e.g. firstName), which is discouraged due to its use of capital letters (see below). The hyphen is easy to type, and with all developers on the same page, it can streamline the URIs to ensure everyone has access.

Why should we use plural nouns in REST API endpoint naming?

Using plural nouns is a common convention in REST API design. It helps ensure consistency and better reflects the possibility of the endpoint returning multiple resources. For example, /users could represent one user or many, while /user might imply it only represents a single user.