0

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?

2
  • I don't get what do you mean by empty records. Could you add an example of the 2 options that you are considering? Commented Feb 18, 2022 at 4:05
  • Records are recorded each hour, however sometimes an hour is missed. say 1am, 2am, 4am records are in the data base and the request is for all hours between 1am and 4am. Should the 3am record be returned in the API just with NULL values or should the API only return 1am, 2am and 4am only (missing out on 3am - because it is empty) Commented Feb 18, 2022 at 5:00

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. That's a really helpful explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.