skyman
skyman

Reputation: 2335

API Returning empty data

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?

Upvotes: 0

Views: 521

Answers (1)

Kiran Kumar
Kiran Kumar

Reputation: 1051

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 database, 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 interpreting the response or transformation of the information should happen at client or at middle tier if one exists.

Upvotes: 2

Related Questions