API to retrieve photo metadata

I’d like to do some computer vision development using my iNaturalist observations and have a request to make this easier. Ultimately, the specific problem is that I’d like to be able to link iNaturalist observations to the raw photos that I have on my computer. The only way I can imagine doing this retrospectively (and relatively efficiently for my 6000+ observations) is by scanning through the photo metadata and matching the timestamps and dimensions. However, the only method I’ve found to do this is by using the API to retrieve observations, then individually scraping the html from each photo page using a logged-in browser profile. This makes me a bit nervous because I’m accessing the site programmatically so frequently without the API - will that get me blocked if I let it run for all my photos??

In theory this should be a one-time use to link the photos with their respective observations, since in the future I can imagine a workflow where I post the observations using the API and store the observation IDs as I upload photos. But for now…

Also, there may be a tangential connection to this bug: https://forum.inaturalist.org/t/ios-photos-no-longer-sync-metadata-to-observation/7540/8. Photos uploaded through the iPhone app do not appear to have timestamp metadata attached to them in the first place? This would be nice to add.

Thanks!

(moved this from feature requests to general because it’s more of a question)

You’ll get blocked if you go over the recommended amount of requests per minute. Check out https://www.inaturalist.org/pages/api+recommended+practices for more info.

5 Likes

Ok, I read that page but I wasn’t sure if the requests-per-minute recommendations applied to general page access the same as direct API requests. Also, I suppose I did have a number of questions mixed in and could write a more isolated request, but my intent was to request that the API provide direct access to the photo metadata. Thanks for the reply!

The only way I can imagine doing this retrospectively (and relatively efficiently for my 6000+ observations) is by scanning through the photo metadata and matching the timestamps and dimensions. However, the only method I’ve found to do this is by using the API to retrieve observations, then individually scraping the html from each photo page using a logged-in browser profile

It doesn’t help you if the metadata is missing, but the photo dimensions are available from the API, e.g. GET https://api.inaturalist.org/v1/observations/56923604:

	"photos": [{
		"id": 90751872,
		"license_code": "cc-by",
		"url": "https://static.inaturalist.org/photos/90751872/square.jpg?1597836103",
		"attribution": "(c) Ryan McMinds, some rights reserved (CC BY)",
		"original_dimensions": {
			"width": 1536,
			"height": 2048
		},
		"flags": []
	}, {
		"id": 90751972,
		"license_code": "cc-by",
		"url": "https://static.inaturalist.org/photos/90751972/square.jpg?1597836182",
		"attribution": "(c) Ryan McMinds, some rights reserved (CC BY)",
		"original_dimensions": {
			"width": 1536,
			"height": 2048
		},
		"flags": []
	}]
1 Like

Good point; thanks! I was starting with the timestamps since the dimensions are mostly redundant, but I had forgotten that that part was in the observation json.

Relevant discussion here: https://github.com/inaturalist/iNaturalistAPI/issues/188

2 Likes

Thanks for this link. I thought I had searched the github issues too, but I missed that one. I’ll add my use-case to that discussion.