There are some basic guidelines to follow to write an effective API—for example, your resources should use nouns in plural form. So, for example, if you had a wholesale website, then your URLs would look something like the following dummy links:
- http://wholesale-website.com/api/customers/1
- http://wholesale-website.com/api/products/20
The preceding URLs will follow the controller routes ofapi/controller/id. In terms of relationships within the business domain, these should also be reflected in URLs such as http://wholesale-website.com/api/categories/12/products—this call will return a list of products for category 12.
If you need to use a verb as a resource, then you can do so. When making an HTTP request, useGETto retrieve items,HEADto retrieve only headers,POSTto insert or save a new resource,PUTto replace a resource, andDELETEto remove a resource...