Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cloughax's avatar

Designing Restful Api

Ok, I having some design issues with building a resful api, and I can't seem to find any result for my question without getting unrelated results.

Im building a resful api using Laravel and AngularJS and im having some issues with designing the api structure (what each route returns). Im used to having laravel generating my view and getting all my data for the page through the controller. But now with a api Im not sure if its the same. Should one route return all that information for say the home page such as the current user data, nav bar data, any any list box data, etc. Or should each one of those data be collected separately in its own route?

0 likes
3 replies
rikh's avatar

I'd have a resource for each type of data. One to get the nav data, one for the user etc. They are all separate resources.

If you design your API right, you'll be able to request multiple things in a single request, if performance is a concern.

cloughax's avatar

@rikh Thanks for your response. Yes i was concerned about the performance issue, cause wouldn't those individual request would add up in the amount before you can generate your page on the client side. Or is that difference in time negligible.

You mentioned that the there is a way to request multiple things in a single request. How would you do something like that? If you don't have time pointing me to the correct direction would also be nice.

Please or to participate in this conversation.