Skip to content

API returns 404 "No data available" when asking for latest date #48

Open
@jtbandes

Description

@jtbandes

When I make an API call to https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY right now (Thu, 01 Oct 2020 01:30:49 GMT) I get a 404:

{
  "code": 404,
  "msg": "No data available for date: 2020-10-01",
  "service_version": "v1"
}

It’s currently Sep 30 in my time zone, not Oct 1. I understand if the server wants to give me Oct 1’s image after midnight UTC, but if so it shouldn’t give me a 404.

I suspect that's because the "current date" default sometimes changes before the image is actually made available (due to time zone differences, maybe?):

apod-api/application.py

Lines 127 to 129 in a434768

if not input_date:
# fall back to using today's date IF they didn't specify a date
input_date = datetime.strftime(datetime.today(), '%Y-%m-%d')

However it looks like there is already some code to handle this. So I guess that's not working properly:

apod-api/apod/utility.py

Lines 263 to 271 in a434768

# handle edge case where the service local time
# miss-matches with 'todays date' of the underlying APOD
# service (can happen because they are deployed in different
# timezones). Use the fallback of prior day's date
if use_default_today_date:
# try to get the day before
dt = dt - timedelta(days=1)
return _get_apod_chars(dt, thumbs)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions