Home > Back-end >  REST API URL naming convention
REST API URL naming convention

Time:08-03

I would like to check if an order is active with retrieving the order details. I have an enpoint designed similar to what is listed below

/order/{order-id}

However I was to check if the order is active without retreiving the details of the order. Which of the below is a better approach to do this or are there any other alernatives?

/order/{order-id}/is-active

or

/order/is-active/{order-id}

CodePudding user response:

Django Rest Framework, a widely used REST API framework, uses the second form /order/{order-id}/is-active.

See Routing for extra actions and Reversing action URLs for examples of this in their documentation.

  • Related