top of page

REST APIs naming conventions

REST APIs naming conventions

  1. Don’t use CRUD / SOAP function names

Never use CRUD or SOAP function names in URIs to indicate that this kind of function is to be performed by accesing the resource. URIs should be used to uniquely identify resources and not any action upon them. Instead of using the name of the resource to indicate the kind of function to be performed HTTP Verbs must be used to describe this behaviour.

HTTP GET http://developers.example.com/users //Get all users

HTTP POST http://developers.example.com/users //Create new users

HTTP GET http://developers.example.com/users/{id} //Get user for given Id

HTTP PUT http://developers.example.com/users/{id} //Update user for given Id

HTTP DELETE http://developers.example.com/users/{id} //Delete user for given Id

b) Use lowercase letters

Lowercase is preferred in the resource naming and the URI path definition.

Is preferred this approach:

HTTP GET http://developers.example.com/users //Get all users

HTTP POST http://developers.example.com/users //Create new users

To this other approach:

HTTP GET http://developers.example.com/Users //Get all users

HTTP POST http://developers.example.com/Users //Create new users

c) Don’t use underscore (_), use hyphens (-)

To improve readability is preferred using hyphens to underscores, as these might be somehow obscured by browsers or screens.

Is preferred this approach:

HTTP GET http://developers.example.com/users/{userid}/assigned-roles //Get all assigned roles

HTTP POST http://developers.example.com/users/{userid}/assigned-roles //Create new assigned roles

To this other approach:

HTTP GET http://developers.example.com/users/{userid}/assigned_roles //Get all assigned roles

HTTP POST http://developers.example.com/users/{userid}/assigned_roles //Create new assigned roles

bottom of page