I\'m am looking for the MediaID
of an Instagram image which has been uploaded. It should look like
1234567894561231236_33215652
You can actually derive the MediaId from the last segment of the link algorithmically using a method I wrote about here: http://carrot.is/coding/instagram-ids. It works by mapping the URL segment by character codes & converting the id into a base 64 number.
For example, given the link you mentioned (http://instagram.com/p/Y7GF-5vftL), we get the last segment (Y7GF-5vftL
) then we map it into character codes using the base64 url-safe alphabet (24:59:6:5:62:57:47:31:45:11_64
). Next, we convert this base64 number into base10 (448979387270691659
).
If you append your userId after an _
you get the full id in the form you specified, but since the MediaId is unique without the userId you can actually omit the userId from most requests.
Finally, I made a Node.js module called instagram-id-to-url-segment to automate this conversion:
convert = require('instagram-id-to-url-segment');
instagramIdToUrlSegment = convert.instagramIdToUrlSegment;
urlSegmentToInstagramId = convert.urlSegmentToInstagramId;
instagramIdToUrlSegment('448979387270691659'); // Y7GF-5vftL
urlSegmentToInstagramId('Y7GF-5vftL'); // 448979387270691659