разработка сайтов
оптимизация сайта
продвижение сайтов
.NET Core
Always will be ready notify the world about expectations as easy as possible: job change page

REST API Naming Conventions and Best Practices

Created: 14 Nov 2022
Author: Nadin Pethiyagoda
Views: 78

The main data representation in REST is referred to as a resource. A properly named resource makes an API simple to use and intuitive. That same API, when implemented incorrectly, may feel complicated and be challenging to use and comprehend. The following article will assist you in getting started when constructing the resource URIs for your new API.

Use Nouns to represent resources / Not Verbs

Always make sure that your URIs are named with nouns to specify the resource instead of using verbs. The URIs shouldn’t indicate any CRUD (Create, Read, Update, Delete) operations. Additionally avoid verb-noun combinations: hyphenated, snake_case, camelCase.

Bad examples:{item-id}❌{emp-id}❌{price-id}❌{order-id}❌

Good examples:{item-id}✅{emp-id}✅{price-id}✅{order-id}✅

Use Pluralized Nouns for resources

Use plural when possible unless they are singleton resources.

Bad examples (Typical and Singleton resources):{item-id}❌{emp-id}/address❌

Good examples (Typical and Singleton resources):{item-id}✅{emp-id}/address✅

Use hyphens (-) to improve the readability of URIs

Do not use underscores. Separating words with hyphens will be easy for you and others to interpret. It is more user-friendly when it comes to long-path segmented URIs.

Bad examples:{vendor-id}❌{item-id}/producttype❌❌

Good examples:{vendor-id}✅{item-id}/product-type✅✅

Use forward slashes (/) for hierarchy but not trailing forward slash (/)

Forward slashes are used to show the hierarchy between individual resources and collections.

Bad example:❌

Good examples:✅

Avoid using file extensions

They are unnecessary and add length and complexity to URIs.

Bad examples:❌❌

Good examples:✅✅

Version your APIs

Always attempt to version your APIs. You can provide an upgrade path without making any fundamental changes to the existing APIs by versioning your APIs. You can also let users know that updated versions of the API are accessible at the following fully-qualified URIs.{emp-id}

Introduction in any major breaking update can be avoided with the following /v2.{item-id}{emp-id}/address

Use query component to filter URI collection

You will frequently come into requirements that call for you to sort, filter, or limit a group of resources depending on a particular resource attribute. Instead of creating additional APIs, enable sorting, filtering, and pagination in the resource collection API and give the input parameters as query parameters to meet this requirement.


GET — Read employee with employee id 8345

POST — Create an employee

PUT — Update employee with employee id 8345

DELETE — Delete employee with employee id 8345

9 Aug 2021
If you’re anything like me, you’ve looked for ways of making your applications faster. In this article, I’ll show you a somewhat unknown class in the .NET framework that makes lazy creation of objects easy to do and thread safe.The...
17 Nov 2020
RSS stands for "Really Simple Syndication". It is a web feed mechanism, which helps applications or clients get updated content from websites in a timely fashion and empower applications to get content from more than one website regularly without having...
23 Aug 2022
Author: Luis Rodrigues
Suppose we are building a web api that contains a route to send notification messages to other systems.For security matters, before sending any notification message, we need to provide some credentials to these systems to they accept our messages.However, these...
7 Feb 2021
Author: Manikanta Pattigulla
OverviewIn this article, I'll explain about the best possible ways to implement the web API, designing of great web API and finally, the things to remember while implementing API.How to design or build great Web API Applications?Basically we’re building applications...
Send message
Your name

© 1999–2022 WebDynamics
1980–... Sergey Drozdov
Area of interests: .NET | .NET Core | C# | ASP.NET | Windows Forms | WPF | Windows Phone | HTML5 | CSS3 | jQuery | AJAX | MS SQL Server | Transact-SQL | ADO.NET | Entity Framework | IIS | OOP | OOA | OOD | WCF | WPF | MSMQ | MVC | MVP | MVVM | Design Patterns | Enterprise Architecture | Scrum | Kanban