How can I get a user's media from Instagram without authenticating as a user?


I'm trying to put a user's recent Instagram media on a sidebar. I'm trying to use the Instagram API to fetch the media.

The documentation says to GET<user-id>/media/recent/, but it says to pass an OAuth access token. An access token represents the authorization to act on behalf of a user. I don't want users to log into Instagram to see this on the sidebar. They shouldn't even need to have an Instagram account.

For instance, I can go to without being logged into Instagram and see photos. I want to do that through the API.

In the Instagram API, non-user-authenticated requests pass a client_id instead of an access_token. If I try that, though, I get:

    "error_message":"\"access_token\" URL parameter missing. This OAuth request requires an \"access_token\" URL parameter."

So, is this not possible? Is there no way to fetch a user's latest (public) media without asking a user to log into an Instagram account through OAuth first?

This question is tagged with instagram-api

~ Asked on 2013-06-28 21:22:35

The Best Answer is


This is late, but worthwhile if it helps someone as I did not see it in Instagram's documentation.

To perform GET on<user-id>/media/recent/ (at present time of writing) you actually do not need OAuth access token.

You can perform[USER ID]/media/recent/?client_id=[CLIENT ID]

[CLIENT ID] would be valid client id registered in app through manage clients (not related to user whatsoever). You can get [USER ID] from username by performing GET users search request:[USERNAME]&client_id=[CLIENT ID]

~ Answered on 2013-12-11 21:03:15


var name = "smena8m";_x000D_
$.get("https://images"+~~(Math.random()*3333)+"" + name + "/", function(html) {_x000D_
if (html) {_x000D_
    var regex = /_sharedData = ({.*);<\/script>/m,_x000D_
        json = JSON.parse(regex.exec(html)[1]),_x000D_
        edges = json.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges;_x000D_
      $.each(edges, function(n, edge) {_x000D_
          var node = edge.node;_x000D_
              $('<a/>', {_x000D_
              href: ''+node.shortcode,_x000D_
              target: '_blank'_x000D_
              backgroundImage: 'url(' + node.thumbnail_src + ')'_x000D_
html, body {_x000D_
  font-size: 0;_x000D_
  line-height: 0;_x000D_
a {_x000D_
  display: inline-block;_x000D_
  width: 25%;_x000D_
  height: 0;_x000D_
  padding-bottom: 25%;_x000D_
  background: #eee 50% 50% no-repeat;_x000D_
  background-size: cover;_x000D_
<script src=""></script>

You can download any Instagram user photo feed in JSON format using ?__a=1 next to landing page address like this. No need to get user id or register an app, no tokens, no oAuth.

min_id and max_id variables can be used for pagination, here is example

YQL may not work here inside snipped iframe, so you can always check it manually in YQL Console

APRIL 2018 UPDATE: After latest instagram updates you can't do this on client side (javascript) because custom headers for signed request can't be set with javascript due to CORS Access-Control-Allow-Headers restrictions. It still possible to do this via php or any other server side method with proper signature based on rhx_gis, csrf_token and request parameters. You can read more about it here.

JANUARY 2019 UPDATE: YQL retired, so, check my latest update with Google Image Proxy as CORS proxy for Instagram page! Then only negative moment - pagination not available with this method.

PHP solution:

    $html = file_get_contents('');
    preg_match('/_sharedData = ({.*);<\/script>/', $html, $matches);
    $profile_data = json_decode($matches[1])->entry_data->ProfilePage[0]->graphql->user;

~ Answered on 2015-11-18 15:20:30

Most Viewed Questions: