Home > database >  API Returning empty data
API Returning empty data

Time:02-19

I have designed an API to query multiple rows in a data base between dates in epoch time:

&fromDate=1644192000000&toDate=1744364800000&responseType=JSON 

The records are usually generated every hour. However, sometimes there are no records for the first period just after the fromDate or in the middle of the date range. Should my API return return empty records for the missing or only return the ones with valid data?

CodePudding user response:

If there's no significant information in the empty records, you can discard them and only return valid values until unless you have some clients who need this information. On an ideal case, it should return the valid values only. The reason is, there is no as such resource exist in the data, you might be just creating some empty records while generating response. Which intern adds complexity on server side for generating empty records, which will slow down server. And also the interpreting the response or transformation of the information should happen at client or at middle tier if one exists.

  • Related