API documentation and examples

11 Sep, 2018 07:52

I have tried to simply get todays Image Of The Day.

This request (keys are hidden):
 Gives this response (keys are hidden):
      "limit": 1,
      "next": "/api/v1/imageoftheday/?api_secret={HIDDEN}&api_key={HIDDEN}&limit=1&offset=1&format=json",
      "offset": 0,
      "previous": null,
      "total_count": 2043
   "objects": [
         "date": "2018-09-11",
         "image": "/api/v1/image/365051/",
         "resource_uri": "/api/v1/imageoftheday/2232/",
         "runnerup_1": null,
         "runnerup_2": null
But how do I get from that to an URL to the Image Of The Day?

Here: https://www.astrobin.com/help/api/
The documentation says:
If you get an Image object using the APIs, it will have a filename and original_ext field. To display the image, you must append them to https://cdn.astrobin.com/

But no filename nor original_ext field are returned?

What am I doing wrong?
Are there a more comprehensive guide for the API available for dummies like me smile
11 Sep, 2018 10:28
Sorry, the documentation is wrong (pull request welcome!)

You need to do an additionally API call to fetch the image resource (in your example it's "/api/v1/image/365051/" ) and that will return an object with several URLs in it for multiple sizes.
Edited 11 Sep, 2018 10:29
11 Sep, 2018 12:55
Thanks for the quick response, will try that.
Register or login to create to post a reply.