title: Get instagram's video media source using oembed endpoints
body: <h2>THE CONTEXT</h2>
  
  <p>I have a piece of (jQuery) ajax code that has been happily working for about 9 months until the last couple of weeks or so. </p>
  
  <p>This code uses Instagram's <a href="http://instagram.com/developer/embedding/" rel="nofollow">embedding endpoints</a> that allows me to get the media source (image or video) out of a normal Instagram link like <code>http://instagram.com/p/BUG/</code> regardless the user and <strong>without</strong> needing an <code>access_token</code>.</p>
  
  <p>Simplified example :</p>
  
  <pre><code>var URL = "http://api.instagram.com/oembed?url=http://instagram.com/p/BUG/";
  $(document).ready(function () {
      $.ajax({
          url: URL,
          dataType: "jsonp",
          cache: false,
          success: function (response) {
              console.log(response.url);
          },
          error: function () {
              console.log("couldn't process the instagram url");
          }
      });
  });
  </code></pre>
  
  <p>In the code above, <code>response.url</code> would return the full media URL source like :</p>
  
  <pre><code>http://photos-a.ak.instagram.com/xxxx/1234_123456123_123456_n.jpg // image or
  http://distilleryvesper3-15.ak.instagram.com/b0c957463548362858_101.mp4 // video
  </code></pre>
  
  <p>Then I could use the returned URL to embed the media file in my webpage.</p>
  
  <p><strong>NOTE</strong> : </p>
  
  <p>Since the idea is to get the URL source of any Instagram link regardless the user, using <a href="http://instagram.com/developer/endpoints/media/#" rel="nofollow">media endpoints</a> is not an option.</p>
  
  <hr>
  
  <h2>THE ISSUE</h2>
  
  <p>Instagram's oembed endpoints allows you to GET a <code>json</code> response, which until the last couple of weeks had this structure :</p>
  
  <pre><code>{
      "provider_url" : "http:\/\/instagram.com\/",
      "media_id" : "123456789_123456789",
      "title" : "the title",
      "url" : "http:\/\/photos-a.ak.instagram.com\/hphotos-ak-xfp1\/12345678_123456789012345_1234567890_n.jpg",
      "author_name" : "{the user name}",
      "height" : 640,
      "width" : 640,
      "version" : "1.0",
      "author_url" : "http:\/\/instagram.com\/{the user name}",
      "author_id" : 123456789,
      "type" : "photo",
      "provider_name" : "Instagram"
  }
  </code></pre>
  
  <p>As you may noticed, my ajax code was particularly interested in the property name <code>url</code>, which contains the full media's URL. </p>
  
  <p><strong>Notice</strong> that this <code>json</code> response (as today) is still valid for Instagram images, <strong>however</strong>, if the original Instagram's link is a video, let's use a real example : <a href="http://instagram.com/p/mOFsFhAp4f/" rel="nofollow">http://instagram.com/p/mOFsFhAp4f/</a> (CocaCola(c)) the <code>json</code> response doesn't return any <code>url</code> key anymore.</p>
  
  <p>It seems that after the introduction of <a href="http://blog.instagram.com/post/55095847329/introducing-instagram-web-embeds" rel="nofollow">web embeds</a> Instagram has decided to replace the key <code>url</code> by a <code>html</code> property in their (oembed) json response for videos only, which contains the iframe to embed like :</p>
  
  <pre><code>{
      ...
  
      "html" : "\u003ciframe src=\"http:\/\/instagram.com\/p\/BUG\/embed\" width=\"616\" height=\"716\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\"\u003e\u003c\/iframe\u003e",
  
      ...
  }
  </code></pre>
  
  <p>... and of course, that breaks my code since <code>response.url</code> is undefined.</p>
  
  <hr>
  
  <h2>THE QUESTION</h2>
  
  <p><strong>How do I get the full video's URL after the changes in the Instagram json response?</strong></p>
  
  <p>Unfortunately I couldn't find any proper documentation or a change log in Instagram's developers site (they have a great API but poor documentation.)</p>
  
  <p>Please <strong>notice</strong> that the question is about Instagram API (v1) embedding endpoints rather than a jQuery or ajax question.</p>
  
  <p>I am looking for (an undocumented perhaps) Instagram's API option, endpoint, oembed or else (that doesn't require <code>access_token</code>) that allows me to retrieve the direct link to the media video (after a json response preferably) out of a normal Instagram link regardless the user ...or willing to consider a not too hacky workaround.</p>