title: How Does Instagram's GET/tags/<tag>/media/recent Pagination Actually Work?
body: <p>I'm trying to use the <a href="http://instagram.com/developer/realtime/" rel="noreferrer">Real-time Photo Updates</a> API to get all pictures with a specific tag as they come in.  Since updates from this API really only tell you <em>that</em> new content exists (but not <em>what</em> it is), I am querying for recent media with my tag whenever I get the notification that something has changed.</p>
  
  <p>The problem I am having is that I'm constantly getting duplicate media returned by that query.  The documentation says this API does pagination, but I can't get it to work at all.</p>
  
  <p>The documentation <a href="http://instagram.com/developer/endpoints/tags/#get_tags_media_recent" rel="noreferrer">here</a> says to use <code>min_id</code> and <code>max_id</code> in your query string to control pagination, however it says:</p>
  
  <ul>
  <li><p>MIN_ID - Return media before this min_id.</p></li>
  <li><p>MAX_ID - Return media after this max_id.</p></li>
  </ul>
  
  <p>This seems backwards (normally min should return items above the minimum and max should return items below the maximum so that when you specify both you get a bounded range).</p>
  
  <p>The actual JSON I get back from my queries includes a pagination object like this:</p>
  
  <pre><code>"pagination":  {
      "next_max_tag_id": "1387272337517",
      "deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
      "next_max_id": "1387272337517",
      "next_min_id": "1387272345517",
      "min_tag_id": "1387272345517",
      "next_url": "https://api.instagram.com/v1/tags/cats/media/recent?access_token=xxx&amp;max_tag_id=1387272337517"
  }
  </code></pre>
  
  <p>The parameter specified in the <code>next_url</code> property is <code>max_tag_id</code>, not <code>max_id</code> like the documentation says.</p>
  
  <p>There is also a deprecation warning that states that <code>next_max_id</code> and <code>min_id</code> are deprecated, but since there are properties in the pagination object with names like that, I don't know whether the query parameters or the object properties the ones that are deprecated..</p>
  
  <p>I would think it means the properties, because the query string never used a parameter of <code>next_max_id</code>, but then the deprecation message says to use <code>min_tag_id</code> and <code>max_tag_id</code> and there is no <code>max_tag_id</code> property on the pagination object (just a <code>next_max_tag_id</code>).</p>
  
  <p>Regardless of all of this conflicting documentation, it doesn't seem to matter what I pass in my query string - I continue to get repeat media in subsequent queries.  Can someone help me make sense of this API?  All I really want is to get tagged media that is new since my last query.</p>