RESTful API 10 Best Practices I follow

Following are the SILVER BULLETS when I create REST APIs. These were originally published here in the year 2014 and the credits goes to them but my true salute goes to OMAR AL ZABIR who published with sample source in C# in his blog post Build Truly RESTful API and Website using Same ASP.NET MVC Code way back in 2012 where he talked about RESTful services naming conventions and leveraged the Controllers  from ASP.NET MVC exported as REST API without using API.NET WEB API using content negotiation and http header (point # 5 below)

REST-BET-PRACTICE

 

  1. Use nouns but no verbs
  2. GET method and query parameters should not alter the state
  3. Use plural nouns
  4. Use sub-resources for relations
  5. Use HTTP headers for serialization formats
  6. Use Hypermedia as the Engine of Application State (HATEOAS)
  7. Provide filtering, sorting, field selection and paging for collections
  8. Version your API
  9. Handle Errors with HTTP status codes
  10. Allow overriding HTTP method

Do not end here but head over to the above mentioned two blog posts to gain the internals.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s