API return original filename when fetching photos or sounds

I’d like to propose extending the API to return the original filename for photos and sounds when the requester is authenticated as the user who uploaded the asset.

This has been discussed in the past with @tiwane:

My use case is a tool that automatically syncs my eBird observations to iNaturalist: github.com/Sajmani/birdsync . At least one other person is also using this tool, and I expect more eBirders will over time. I would like to extend the tool to accurately detect when the set of media assets on eBird has changed relative to those on iNaturalist so that can properly update the set on iNaturalist. To do this I need a mapping between each media asset and the Macauley Library Asset ID (ML ID) in eBird. I have arranged that mapping by using the ML ID as the original filename when uploading the asset, for example in https://www.inaturalist.org/observations/308307110 , the first photo is https://www.inaturalist.org/photos/556216628 and has original filename “ML640650792.jpe”. This corresponds to the original asset ID https://macaulaylibrary.org/asset/640650792. In order to sync the assets on future runs, I need to be able to read the original filename back via the API, which is currently unsupported.

I have prepared an initial PR here, but it doesn’t do the auth check yet: https://github.com/inaturalist/iNaturalistAPI/pull/534. I could use guidance from someone familiar with the codebase on this, for example, a pointer to similar logic in other API calls. CC @pleary who has been very helpful in the past :folded_hands:

Thanks all,
S

1 Like

This would be a real godsend for me. I keep the image archive on my PC synchronised with iNaturalist and the ability to, for example, download a csv that includes my original filename would be great.

there’s been some previous discussion here: https://forum.inaturalist.org/t/way-to-get-uploaded-picture-original-file-name-via-api/50645/4

Thanks! Indeed there are several more useful discussions linked from https://forum.inaturalist.org/t/way-to-get-uploaded-picture-original-file-name-via-api/50645/4 :

It looks like this is mainly blocked on someone to implement the change, which I’m willing to do as long as there’s someone who can review the PRs and advise (as I’m unfamiliar with this tech stack).

S

My PR is now updated to return the original photo or sound filename only when the user is logged in with the ID that uploaded the photo or sound: https://github.com/inaturalist/iNaturalistAPI/pull/534

At this point I’m waiting on a reviewer. WDYT @pleary ?

Kudos @pleary for reviewing my PR, merging it, and deploying it!

Commit: https://github.com/inaturalist/iNaturalistAPI/commit/7cef9b62d5d1546ade9388094d2e550a1a720570

I just tested the new behavior, and it’s working as intended. Important note for users: you must be logged in to retrieve the original_filename field for your photos and sounds. Specify photos.original_filename or photos.all (ditto for sounds) to request the new field.

Thanks again, Patrick!
S

2 Likes