The question about REST api

I understand rest as url pointing to resources, without verbs, for example:
query a member information: get / api/users/:id
query an order information: get / api/orders/:id

question:
1. If you need to display user information and order information at the same time:
if the front end adjusts the API to spell data separately, it will send a lot of requests and degrade performance. And if there are too many connections, it will be very difficult to deal with.
if the backend provides a new interface, it seems to go against the original intention of rest (as I understand it). As the demand increases, there are many bizarre interfaces / api/users/orders , / api/users/orders/products ?

2. How are some verbs designed? Such as start tasks, kill processes?

Mar.02,2022

1 can have a name for each page, and each name corresponds to a rest api
get / api/page/home
each API and then call other APIs to assemble

2 encounters some verbs on how to design a
start task: it can be thought of as modifying an attribute of the task resource, so PUT task/:id or PATCH task/:id
kill process: it can be thought of as destroying the process resource, so DELETE process/:id


RESTful API can have more than one layer but multiple layers.

  • / api/users/orders can be understood as getting an order from a user?
/ api/user/ : id / order
  • / api/users/order/product is understood as items contained in an order of a user
/ api/user/ : id / order/ : order_id / product

as for the second one, choose it appropriately rather than force it out according to your needs.

Menu