Domanda

I'm building an external restfull api. The goal of this api is to expose objects and computed statistics.

For exemple, we expose the list of orders and the total amount of orders.

I hesitate between several patterns :

  • /orders/totalamount
  • /orders/stats/totalamount
  • /stats/orders/totalamount

Or may be you have a better idea ?

Of course, there are several objects and several other statistics. This is just one example

Thank you for your help !

È stato utile?

Soluzione

I will prefer /orders/stats or /stats/orders, and have totalamount as one of the attribute of the JSON result.

The reason is totalamount is just a simple value and it is really just part of the stats result.

/orders/totalmount will not make much sense, unless you have many aspects to represent this values.

Altri suggerimenti

There is no one right answer to this - it all depends on the rest of your API. For example...

/stats/orders/totalamount - makes sense if your API provides lots of stats, stats are important, and you provide stats on more than just orders

/orders/stats/totalamount - makes sense if you provide different stats on orders, and don't provide stats on other things

/orders/totalamount - makes sense if this is the only such item.

Think about what the important entities in your API are, from the point of view of your users. I would imagine orders will be the most important entity.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top