Provide number of results on response
rennerocha opened this issue · 0 comments
rennerocha commented
Result of API calls are a list of the returned gazettes. However, as the total number of items returned are not avaliable (because of page_size
parameter), we don't have any clue about the number of pages that we will have to process.
The options to solve that with current implementation is:
- Define a very large
page_size
(for example 1000000) so we can get all items. This is not ideal because we will have to get all data at once increasing the amount of data transferred in one request that would make the API response to be slow; - Increase the
page
value until we get a404
error (so we don't have more pages). Also not ideal if we want to have an idea about the total number of items returned.
In my opinion, both solutions are not good for an user of this API. My suggestion is to change the endpoints to provide some extra information about the results, so we can use a more smart procedure to use pagination reducing the amount of data transferred, making the requests faster and providing more useful information to the user (the total number of items returned);
Suggested response:
{
"results": [
{
"territory_id": "string",
"date": "2020-12-28",
"url": "string"
},
...
],
"num_items": <total_number_of_items>,
"current_page": <current_page>",
}