O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Nouns as paths

Have you ever seen some API endpoints that contain a full sentence to access a resource? Some examples might be the following:

http://myshop.com/createNewProducthttp://myshop.com/deleteProducthttp://myshop.com/updateProducthttp://myshop.com/getProductDetail/P01http://myshop.com/getProductComments/P01

The first thing to keep in mind is that you should never use verbs in your endpoints. Instead, use nouns in plural to refer to a resource into your API Endpoint. For example, the preceding example can be refactored to this:

The Rest way - Not recommended

The RESTful way - Recommended

http://myshop.com/createNewProduct

http://myshop.com/deleteProduct

http://myshop.com/updateProduct

http://myshop.com/products
http://myshop.com/getProductDetail/P01 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required