I'm thinking about a REST API design. There are several tables in my database. For example Customer and Order.
Of course - each Order has its Customer (and every customer can have many Orders).
I've decided to provide such an interface
/api/v1/Customers/ -- get list of Customers, add new Customer /api/v1/Customers/:id: -- get Customer with id=:id: /api/v1/Orders/ -- get list of Orders, add new Order /api/v1/Orders/:id: -- get Order with id=:id: It works flawlessly. But my frontend has to display a list of orders with customer names. With this interface, I will have to make a single call to /api/v1/Orders/ and then another call to /api/v1/Customer/:id: for each record from the previous call. Or perform two calls to /api/v1/Orders/ and /api/v1/Customers/ and combine them on the frontend side.
It looks like overkill, this kind of operation should be done at the database level. But how can/should I provide an appropriate interface?
/api/v1/OrdersWithCustomers /api/v1/OrdersWithCustomers/:id: Seems weir. Is it a right way to go
/api/v1/Orders/should return objects with customer fields already resolved, if you need them.