[API v4] Getting metadata from image key

Hi everyone,

I’d like to get geometry/coordinate data from Mapillary published datasets, and stuck in trying to get image_id from image_key that are available as the image filenames in the dataset.

example image_key: MJC_Wgy-JDHySEKzexoiOQ

If i request directly to graph.mapillary.com/MJC_Wgy-JDHySEKzexoiOQ i will get an error that the image does not exist.

But if i try to see it on the web through https://www.mapillary.com/map/im/MJC_Wgy-JDHySEKzexoiOQ, it is successful and reveals that the image_id is 203491838251994. I inspected the request and the Mapillary app backend redirects from image_key to image_id.

Is it possible to get the image_id in bulk, or to get the metadata directly using the image_key?

Thanks,
Raihan

You can get the image ids from vector tiles. Relevant topic here: Download Mapilarry images with API v4

Thank you for your guidance, but I’m afraid it’s about a different topic. I don’t have vector tiles, I have images from the Mapillary Traffic Sign Dataset, in which there are images with image_key as their filename. I want to get the geographic metadata of where the image is captured through the Mapillary API, but I need to get an image_id from the image_key.

Seems like this has been unsolved since last year: Retrieve images by old image keys

While this is quite late, hopefully this will help anyone else with a similar issue. The image_id needed for v4 of the API can be obtained using the image_key from v3 by replacing the pKey of an app URL. For example, given the image_key jts2GFO_3uyaEm5voOO5ug we can get the image_id by going to Mapillary
When going to that URL, you will be redirected to the same URL but pKey will be 195789302375444 which is the image_id. In a Python script, something like urllib can be used to open the URL. The returned URL can then be parsed to get the image id. Below is the Python code that implements this:
import urllib

image_key = ‘jts2GFO_3uyaEm5voOO5ug’

mapillary_URL = urllib.request.urlopen(‘Mapillary’ + image_key)
mapillary_url_as_string = str(mapillary_site.url)

image_id = mapillary_url_as_string.split(“&pKey=”)[1]

print(image_id)

There is probably a much better way to do this but this was the path I found.

I understand that programmers must make a living and they like the short mapillary key.
Which means that every program in the world that needs a mapillary picture must program it.

That is a problem for ordinary people like me.
To convert a url to the mapillary short key if needed =
if the key is numeric, then ok, els look for the 12 characters after “pkey =”
or something like

Iff(isnum(mapillary,
Mapillary,
mid(mapillary,
(Instr(1,mapillary,”pkey=”)+5),
14
)
)
)