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.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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?
Some great references to look at when you're thinking about building an API....
http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api https://leanpub.com/build-apis-you-wont-hate
This is also a great package to help with building APIs http://fractal.thephpleague.com/
Please or to participate in this conversation.