April 6, 2020
Estimated Post Reading Time ~

Naming REST API's

Guidelines for naming your REST APIs.
  • Use nouns to represent resources. Example – /books/{id}
  • Use plural to represent a collection of resources – /books
  • Use a verb to represent an executable action on a resource – /users/{id}/cart/check-out
  • Use HTTP methods for CRUD on the resource represented by URIs.
  • Use query strings for operations such as filtering, sorting, and pagination.
  • Use - to improve readability.
  • Do not end the URI with /
  • Use lowercase letters.
  • Do not add file extensions in URI.
  • It may not be a great practice to force the version number in URI. It could be used for debugging purposes. URI without version number should point to the latest version.
  • JSON is the right output format.
  • Use hyperlinks within response for better navigation (HATEOAS)
  • Use HTTP status code to handle errors.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.