Convert Instagram post IDs into Instagram links, algorithmically
Last updated 5 years ago by slang .
GPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install instagram-id-to-url-segment 
SYNC missed versions from official npm registry.

Instagram Id To URL Segment

Build Status NPM version NPM license

Instagram has 2 types of IDs that they use for their posts. One is used in the URLs (it looks like 5n7dDmhTr3) and the other is used internally in their undocumented API (it looks like 1038059720608660215).

I didn't think that they would maintain 2 unrelated IDs for each post, just for the purpose of a shorter URL, so I investigated whether or not they were related. It turns out you can convert between them pretty easily (especially in languages where we don't represent integers as floats - like Python).


Note: the id must be passed in as a string. If it was passed as a number then it would be severely rounded.


{instagramIdToUrlSegment, urlSegmentToInstagramId} = require 'instagram-id-to-url-segment'
console.log(instagramIdToUrlSegment('1038059720608660215')) # 5n7dDmhTr3
console.log(urlSegmentToInstagramId('5n7dDmhTr3')) # 1038059720608660215


var ref, urlSegmentToInstagramId, instagramIdToUrlSegment;
ref = require('instagram-id-to-url-segment')
instagramIdToUrlSegment = ref.instagramIdToUrlSegment
urlSegmentToInstagramId = ref.urlSegmentToInstagramId;

console.log(instagramIdToUrlSegment('1038059720608660215')); // 5n7dDmhTr3
console.log(urlSegmentToInstagramId('5n7dDmhTr3')); // 1038059720608660215

Current Tags

  • 0.0.0                                ...           latest (5 years ago)

1 Versions

  • 0.0.0                                ...           5 years ago

Copyright 2014 - 2016 © |