(Python/Node API) Photo access possible?

Hi all,

this is a rather technical question, not sure if this is the right channel… sorry if not.

As a toy project both to learn kivy (a very portable python gui framework) and to get better in identifying butterflies, I decided to write a python program which shows random butterfly images and a couple of suggestions for their species to choose from. However, it seems I get only URLs to the small thumbnail images as a request response. What I do is:

from pyinaturalist.node_api import get_observation
obs = get_observation(37311466) # one of mine
print(obs[‘photos’][0][‘url’]) # yields https://static.inaturalist.org/photos/59125544/square.jpeg?1578255703, which is the thumbnail image.

Is there a way in the API to get the original or at least a larger version? Do I miss something, maybe I have get a login token to access images, or search for certain license types? I have spent an hour or two searching through the api documentation, but have neither found a statement that ‘url’ is the thumbnail URL nor a way to access the original. Of course it could also be a bug in the pyinaturalist interface, but I doubt it changes the json response…

If there is no solution for that, I have to change the app from butterflies to pokemon. My son would love that :)

Best regards
Chriss

1 Like

I’m unsure if there is a more elegant solution, but if you replace “square.jpeg” with “original.jpeg” after you pull the image URL then it will be for the full sized image:

imgurl = “https://static.inaturalist.org/photos/59125544/square.jpeg?1578255703
print(imgurl.replace(“square”, “original”))

yields:
https://static.inaturalist.org/photos/59125544/original.jpeg?1578255703

that you could add as a step in the program for each image pulled.

5 Likes

This is usually what I do.
You can also replace with large.jpeg, which can be helpful if the image size is rather small to start

1 Like

https://www.inaturalist.org/photos/59125544
https://www.inaturalist.org/photos/59125544?size=small
https://www.inaturalist.org/photos/59125544?size=medium
https://www.inaturalist.org/photos/59125544?size=large
https://www.inaturalist.org/photos/59125544?size=original

https://static.inaturalist.org/photos/59125544/small.jpeg
https://static.inaturalist.org/photos/59125544/medium.jpeg
https://static.inaturalist.org/photos/59125544/large.jpeg
https://static.inaturalist.org/photos/59125544/original.jpeg

https://static.inaturalist.org/photos/59125544/square.jpeg
https://static.inaturalist.org/photos/59125544/thumb.jpeg

it’s best to pull the smallest version of the photo that you need for your use case.

EDIT: it may also be worth noting that:

  1. the best way to get better at identifying is probably to identify (https://forum.inaturalist.org/t/recruiting-more-identifiers/2388, https://www.inaturalist.org/blog/35758-we-ve-reached-1-000-000-observers)
  2. folks have made other quiz type things (https://forum.inaturalist.org/t/how-well-do-you-know-your-local-wildlife-now-you-can-test-yourself/10711), but as far as i know, no one has made anything to display a photo slideshow (https://forum.inaturalist.org/t/presentation-mode-as-a-full-screen-slideshow-of-observation-images/8316), nor a more modern way to share observations on social media (https://forum.inaturalist.org/t/share-observations-with-one-click-to-other-social-media/1214).
  3. if you know Python or want to learn Python (beyond kivy), there’s this project, which i believe is done in Python: https://forum.inaturalist.org/t/seeking-discord-bot-development-collaborators/7137.

welcome to the forum.

5 Likes

Thanks for the plug for Dronefly. Yes, it’s Python, and we’re still seeking collaborators.

1 Like

Thank you all for the answers - that should get me going.
Special thanks for the above remarks and links. I will read through them the next few days as I find time for that.

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.