Instagram is widely used, with literally millions of people constantly uploading pictures.

It makes sense, with such a large user base, to create an API. Today we’ll be looking into how to use it.


The first thing you need to do is to register as a developer with Instagram.

You’ll need to register your application name, a description, your website and a redirect URL.

After you’ve done this you’ll receive your Client ID and Client Secret, but this is where it gets a little tricky; you’ll also need an access token.

To get your access token, you need to go to this URL using your data:

You’ll be redirected to a URL that looks something like this:

In this case, your access token would be:



When it comes to the actual JavaScript, we just need a simple AJAX call, because the Instagram API returns a JSON response.

Let’s start with the HTML we’ll need:

<h1>Popular Pictures</h1>
<ul class="popular">

Now the fun part. To retrieve the most popular pictures we need a GET request to a URL that looks like this (but uses your access token):

So, our code looks like this:

      type: "GET",
      dataType: "jsonp",
      cache: false,
      url: "",
      success: function(data) {
        // placing the images on the page

As you can see, it’s a standard AJAX call, we first set the type as GET, the dataType is jsonp because we’re loading cross domain, the set the cache to false, and finally add the URL.

Now we just need to populate the success function with the necessary code to display the images on our site:

    for (var i = 0; i < 6; i++) {
          $(".popular").append("<li><a target='_blank' href='" +[i].link + "'><img src='" +[i].images.low_resolution.url + "'></img></a></li>");

In order to do this, I’m using a for loop that will stop after 6 images, then inside the loop appending a list item and image.


Getting the most popular images is easy, but more commonly we need to get a specific user’s, usually our own.

To get a user’s images, the URL for our GET statement changes slightly:

Then we need the user’s ID.

Now we need to write the ajax call that will handle this:

  type: "GET",
  dataType: "jsonp",
  url: "",
  success: function(data) {

As you can see, all we changed here was removing the no cache instruction.


Once you get past the rather convoluted authentication process, the Instagram API is incredibly simple to use.

If you have an Instagram account yourself, this is a great way of keeping images on your personal site up to date.

Related posts

  1. Restylane乃一系列用於美顏的長效透明質酸產品。 Restylane療程能有效撫平皺紋、美化臉型輪廓及唇部,並可改善膚質及肌膚的彈性。Restylane透明質酸作用原理 Restylane透明質酸均以非動物來源的透明質酸作為原料,獨有的NASHA™專利技術研製而成。微量Restylane透明質酸凝膠到皮膚中,可以讓您的面部肌膚恢復豐盈飽滿。 Restylane透明質酸中的透明質酸與人體內的天然透明質酸十分相似,使用前無需進行皮膚測試,引起過敏反應的機率亦極低。真空激光脫毛

  2. 加強優化面部輪廓,可被身體完全吸引,能自然地修飾面部輪廓 功效可長達24個月以上 JUVEDERM的特點: 效果立即可見 非永久性 非手術性 安全有效 效果自然 JUVEDERM獲歐盟(CE)及美國及藥物管理局(FDA)認證 首先及唯一獲得FDA認證在首次療程後能維持長達一年2-4功效 新世代專員Hylacross科技為產品帶來獨特的物理特質,包括凝聚力、支撐力及柔順度 8點提升 這是一套由全球著名醫學美容醫生Dr. Maurício de Maio,以JUVÉDERM®系列透明質酸產品為基礎而研發的面部優化療程,藉著簡單程序便達致面部優化效果,不需進行手術,減低風險。 此療程會根據病人的個別情況,重點針對面部8個最常因流失膠原蛋白及彈性纖維而凹陷的位置,再依據特定的順序,從顴骨至下巴位置配合JUVÉDERM®系列的透明質酸產品進行療程,從而改善這些位置的豐盈度及滑溜度,全面性優化面部輪廓。激光脫癦

  3. A lot of thanks for all your hard work on this web page. My mum really loves carrying out investigations and it’s easy to understand why. My partner and i hear all about the dynamic mode you convey both interesting and useful thoughts via the web blog and in addition attract response from other ones on the concept plus our own princess is being taught so much. Enjoy the remaining portion of the new year. You are always doing a brilliant job.

  4. I intended to draft you the tiny remark in order to give thanks the moment again considering the pretty thoughts you’ve featured in this article. This is really surprisingly open-handed of people like you in giving extensively just what many individuals could possibly have offered for an e book to help with making some dough for themselves, especially considering the fact that you could have tried it in the event you desired. These guidelines in addition worked like a good way to comprehend other people online have the same passion similar to my personal own to find out many more when it comes to this condition. Certainly there are some more pleasurable moments up front for folks who discover your blog.

  5. I would like to show thanks to the writer for bailing me out of this particular difficulty. Because of checking throughout the world-wide-web and coming across things that were not helpful, I thought my life was well over. Being alive devoid of the answers to the issues you’ve resolved all through your website is a serious case, as well as the kind which might have in a negative way affected my career if I had not come across the blog. Your good talents and kindness in maneuvering all areas was tremendous. I am not sure what I would’ve done if I hadn’t come across such a point like this. I’m able to at this point look ahead to my future. Thank you so much for your reliable and result oriented guide. I will not be reluctant to propose your web site to anyone who would like care on this topic.

  6. Thank you so much for providing individuals with a very memorable possiblity to read in detail from this website. It is often so good and as well , jam-packed with a great time for me and my office friends to visit your site a minimum of thrice per week to learn the new things you will have. Of course, I am just always satisfied considering the incredible tricks served by you. Selected two facts on this page are completely the most effective we have all ever had.

  7. I simply wished to thank you so much once again. I do not know the things I would’ve sorted out without these ideas contributed by you on this situation. It absolutely was an absolute fearsome dilemma for me personally, however , seeing the specialised manner you solved it made me to cry with delight. I’m happy for your information and even have high hopes you really know what a powerful job you happen to be getting into educating some other people all through your site. Most probably you have never come across all of us.

  8. Thanks a lot for providing individuals with an exceptionally splendid chance to check tips from this blog. It really is very useful plus packed with amusement for me personally and my office mates to search the blog nearly three times every week to find out the latest guidance you will have. And of course, we are at all times fulfilled for the very good tactics you serve. Selected 3 ideas in this posting are undoubtedly the very best I have ever had.

  9. I in addition to my friends happened to be taking note of the good ideas on your web page and so the sudden developed an awful suspicion I never expressed respect to the web site owner for them. These young men were definitely certainly very interested to read through all of them and already have very much been taking pleasure in these things. We appreciate you actually being well thoughtful and then for having certain wonderful tips millions of individuals are really wanting to be aware of. Our own honest regret for not expressing gratitude to sooner.

  10. A lot of thanks for all of the efforts on this website. Kate really likes doing investigation and it’s really obvious why. A lot of people know all about the dynamic way you convey simple suggestions on the web site and therefore invigorate contribution from people on the topic and our own girl is in fact becoming educated a whole lot. Take advantage of the rest of the year. You’re conducting a pretty cool job.

  11. I really wanted to develop a comment so as to thank you for these splendid information you are sharing at this website. My extended internet research has now been recognized with good suggestions to talk about with my family and friends. I would state that that most of us site visitors are undoubtedly lucky to live in a fine website with many wonderful individuals with beneficial suggestions. I feel really grateful to have discovered your entire web page and look forward to so many more entertaining minutes reading here. Thanks a lot once more for all the details.

Leave a Reply