Using total VS sum for API responses when querying lists of data #2692
Replies: 5 comments 2 replies
|
This is a welcome suggestion. Backwards compatibility shouldn't be a problem since we have |
|
I like Brandon's suggestion. People were asking about "sum" many times, their main concern was the difference between |
|
Seems like the term |
|
Sum suggests some kind of arithmetic was performed, total suggests some type of headcount. I think |
|
I have created PR to address this issue. If anyone is interested in the topic, feedback and review would be highly appreciated 💖 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
For the REST API responses, when retrieving data from APIs, I'm used to getting some value for the "total number of records" returned in addition to a property that holds an array of the records.
For documents, the response returned currently is:
{ "documents": [{}, {}. {}], "sum": 3 }Traditionally, I've seen
totalused instead ofsumto denote the total number of records returned by the query for the list. I think its worth considering changingsumtototalor a name that includestotalto align more with how other APIs return the count of records alongside the array of records.AFTER:
{ "documents": [{}, {}. {}], "total": 3 }This would be a breaking change, but could possibly provide some sort of backward compatibility for existing users depending on the
sumproperty.The goal here is to reduce the number of things that diverge away from what other developers consuming REST APIs are used to seeing.
Some examples for reference
https://developers.google.com/youtube/v3/docs/activities/list#response
https://dev.twitch.tv/docs/v5/reference/users#get-users
Also interested in hearing what others think about this.
All reactions