gurbaninow/api-public

Let user decide what fields shall be present in the response

bogas04 opened this issue · 7 comments

This will improve response time of the API as the responses would be tailored to user's requirement.

Only the :query is required, if you need to specifiy something specific then you use the additional options.

I think you misunderstood the point.

Say I only want lineno & Gurmukhi for any route, then API could accept some more params to trim response based on the fields asked by the user. This will help small and large applications to spend less time on HTTP requests.

Something like

/shabad/123?only=lineno,gurmukhi
this gives only gurmukhi and lineno in response

/shabad/123?ignore=shabadid,gurmukhi
this gives everything except shabadid & gurmukhi

In the modern world, reducing that much data wont do much. My API is behind cloudflare which caches the results in its CDNs all over the world.

It does matter when you have a lot of requests, in cases like search or angs with a lot of lines.

For example search results page would only want to show gurmukhi and english translation.

Do remember that third world countries still have 2G as their average speed and it too is flaky at times.

My API is behind cloudflare which caches the results in its CDNs all over the world. The requests don't directly come from my server in New York City.

That only solves the load on server and not on client.

Note that data is one part (might not be an issue for west), but processing that data is also an issue. Cheap-ass android phones with slow browsers still need to deal with arrays of huge strings.

I insist to re-consider only & ignore params, not to be implemented immediately but at least in future.

Continued on #19