Search posts, tags, users, and pages
what kind of API? Do you mean a web API? Via HTTP? What languages do you use on either side?
Ah sorry.. This is not going to be external public, it's for my JavaScript components. It's mainly a 1 page website project, so I don't want to create a lot of different AJAX requests upon load.
I thought it would be smart to make something like
/api/v1/combined?with=user&something and then the different endpoints would be merged together in 1 output.
maybe GraphQL can help you here, check it out http://graphql.org/
@emilmoe GraphQL seems to be on the rise lately, so it might make for a nice protocol. However, if you only need to fetch some data at some point after load, why don't you just pack all your data into a defined structure, and then transform it on the fly into binary to save bytes? It's like sending JSON, just more optimized. There are easy to use modules available (e.g. PSON) and splitting the data on the client side is easy as pie :)
Alternatively, you could go with multiple AJAX calls and present the data as it becomes available, which results in faster responses, which might be better UX.
I wouldn't use WebSockets here. That's just overkill just for fetching data at some point....
It's going to a RESTful JSON API :-) It's an API for delivering data from backend to frontend.
Are you sure that multiple requests are good? My experience it gives a bad UX.
Actually my main concern is the strategy I should use to merge the endpoints, as it seems as a limitation if I make a buttload huge response only targeted that specific case.
@emilmoe
My experience it gives a bad UX.
If it's good or bad UX actually depends on the amount of data. If loading the data in one go requires several seconds, doing it progressively might be the better option imo.
a buttload huge response only targeted that specific case
You do need all that data at that very moment, right? So I think it is ok to push it all in one go in order to minimize overhead.
it seems as a limitation
If you think, you are limiting yourself and you would really prefer micro-calls, then let me ask you this: Have you benchmarked actual performance with that dsign, yet? Is it really that bad?
I have been researching and thinking. I think the best solution is to make:
For the Endpoints after all I found the best solution to make the output as relevant and specific and not generic.