Raghav Thakur
Raghav Thakur

Reputation: 321

Instagram API -Get the userId

We had integrated instagram api (with {userId}/media/recent) to get media feeds based on userId. It was working fine until June 1 2016 . Now on how do I get userId for new instagram pages which we need to include as with the new release of instagram it seems difficult. This is the error messsage we get from a site from where we used to get instagram userId. "This service is no longer available as of 01. June, due to changes in Instagram's API rules" from http://www.otzberg.net/iguserid/

Regards Raghav

Upvotes: 7

Views: 28451

Answers (6)

Sr.PEDRO
Sr.PEDRO

Reputation: 2067

I'm currently using https://codeofaninja.com/tools/find-instagram-user-id for that.

If you would like to use it as an api, you can use https://codeofaninja.com/tools/find-instagram-id-answer.php?instagram_username={username} and then parse the html response to get the user id

Upvotes: 1

Simon Bruder
Simon Bruder

Reputation: 366

Definitely not the most elegant way, but without involving a running browser or an approved application, is to use the (undocumented?) search API:

https://www.instagram.com/web/search/topsearch/?context=user&count=0&query={username}

This returns matching users (as count is set to 0 it should not return more than one user).

After validating the results (checking if user includes one item), you can get the userid e.g. in javascript with

response.users[0].user.pk

where response is an object with the parsed response.

Upvotes: 13

BenEgan1991
BenEgan1991

Reputation: 637

You can use this website - http://www.instaid.co.uk

Or you can do the following replacing {username} with your Instagram username

https://www.instagram.com/{username}/?__a=1

Or you can login to your Instagram account and use google dev tools and look at the cookies that have been stored. 'ds_user_id' is your user ID

enter image description here

Upvotes: 5

Sujay Menasinakai
Sujay Menasinakai

Reputation: 102

When you generate the access token.. there will be id in the json response

{"access_token": "", "user": {"username": "abcdef", "bio": "", "website": "", "profile_picture":", "full_name": "ABCEDEFE", "id": "000000000"}}

We can get userid by using this link. https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN

Upvotes: 0

Claus Wolf
Claus Wolf

Reputation: 161

The mentioned website otzberg.net/iguserid is my personal site and I shut it down, based on the API announcement, which was correctly mentioned by Daniel Storm. The type of tool would never be approved by Instagram. However there are a few easy steps to get your Instagram User-ID, use Google Chrome and the Developer Tools (F12 or ⌥ + ⌘ + i)

In the console view of the profile page (e.g. https://www.instagram.com/lufthansa/) type:

    window._sharedData.entry_data.ProfilePage[0].user.id

Here a screenshot:

enter image description here

Upvotes: 10

Daniel Storm
Daniel Storm

Reputation: 18878

From Instagram:

On November 17, 2015, we announced a new permissions review process for new and existing apps on the Instagram for Developers blog. All existing apps have until June 1, 2016 to submit for review before being transitioned to sandbox mode. Please submit for review only if you are in compliance with one of our approved use cases.

You need to get your API usage approved.

Check Instagram's Platform Policy for use cases that are not allowed.

Upvotes: 2

Related Questions