Rest – How to design a RESTful API with good performance

apirest

When designing RESTful APIs, one of the rules is: "URI designates exactly one resource" , but in the real world we also like good performance and one thing to kill performance is the N+1 problem.

So how exactly are we supposed to avoid the N+1 problem without making more than one URI for the same resource /api/foos/?page=1 or /api/foo/1 where /api/foos/ returns a list of foos in order to get decent performance.

Best Answer

No one said you can't make a URI for /api/foos/?page=1. A container is not the same as the things it contains; a list of foos is a different resource from the individual foos.

Related Topic