Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pull Instagram Images via JavaScript

Get Instagram Images via JavaScript

Get API Info

You will need the user_id from the user. This is difficult to discover at Instagram but easy from this site

I used for the next few steps

You will also need an access token which ends up being difficult to obtain. Log into the account and go to their Developer Page.

Create a new "Client"

  • Application Name: Just enter "website"
  • Description: Enter whatever
  • Website: Enter your domain name. I don't think it has to exist already. But I know your requests aren't limmited to only this domain - at least as of now.
  • OAuth_redirect_uri: Enter the same website URL
  • Uncheck the "Disable Implicite OAuth"

Doing these steps should result in a Client ID

Go to this URL in the browser:[CLIENT_ID_HERE]&redirect_uri=[OAuth_Redirect_URI]&response_type=token

and substitute your Client ID/OAuth_Redirect_URI. If you get an error, chances are you didn't uncheck that box in the last step. You can always "edit" the client and uncheck the box to do this step over

Going to the URL will reveal your access_token. You may need any combination of client id, access token, or user id depending on how you want to access data. Do not delete the "Client" you made at Instagram.


Get a specific user, and filter on criteria (a specific hash tag in this case)

var feed = new Instafeed({
  get: 'user',
  userId: [user_id],
  accessToken: '[accessToken]',
  resolution: 'low_resolution',
  filter: function(image) {
    return image.tags.indexOf('somehashtag') >= 0;

Search all of Instagram for a certain hash tag

var feed = new Instafeed({
  clientId: '[client_id]',
  get: 'tagged',
  tagName: 'newyears',
  resolution: 'low_resolution'


You provide:

<div id="instafeed"></div>

And InstaFeed will create:

<div id="instafeed">
  <a href="..."><img src="..."></a>
  <a href="..."><img src="..."></a>
  <a href="..."><img src="..."></a>
  <a href="..."><img src="..."></a>

But this can very easily be changed in terms of what template InstaFeed will use


This comment has been minimized.

Copy link

@nickmeagher nickmeagher commented Sep 28, 2017

Great guide!

I am having trouble accessing a specific location though, I am getting a "Uncaught Error: Error from Instagram: This client has not been approved to access this resource." and I believe this is because you now need the public_content permission on the Instagram account.

The problem now being Instagram doesn't give this permission away on one-off client projects stated here under "Invalid use cases":

Is there another way to achieve this?


This comment has been minimized.

Copy link

@kims554 kims554 commented Oct 20, 2017

Hey Nick I ran into the same issue but I tried the link without the parenthesis [ ] around the client ID and Redirect URL and it worked


This comment has been minimized.

Copy link

@mdunbavan mdunbavan commented Nov 23, 2017

If anyone else runs into the same issue.

When adding a user in the sandbox area of the client app you need to add the username and click save to add it to the list, then click save again to send it to the user to authenticate the app to test it in sandbox mode for that user id and account.

Also full url for getting access token needs to be this:[CLIENT_ID_HERE]&redirect_uri=[OAuth_Redirect_URI]&response_type=token&scope=[YOUR_SCOPE]


This comment has been minimized.

Copy link

@venits venits commented Feb 12, 2018

For getting Instagram access_token in easy way you can use this library:
Right now it is the simplest and fastest way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.