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.
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
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.
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).
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.
the response from https://www.inaturalist.org/users/api_token looks something like {"api_token":"j.w.t"}. a lot of people who’ve never used the JWT before think that the entre response is the JWT, but it’s actually just the value of api_token. (in my example, j.w.t would be the JWT, and that’s what you would need to pass to the API for authorization.)
@pisum Thanks that worked. The page is not particular helpful to those unfamiliar with authorization protocols! Maybe that’s the intention, if not then your explanation ought to be there somewhere.
i doubt it even crossed the minds of iNat staff that there might be folks trying to use JWTs who don’t understand what JWTs are. for what it’s worth, JWTs are well-documented on the broader internet, and they have a standard format. i suppose it wouldn’t hurt if iNat pointed folks to a document or page that provides more general information on JWTs, including best practices for handling and using them. you could make a feature request for that.