A simple Instagram JavaScript plugin for your website

Overview

Instafeed.js

Build Status npm version

Instafeed.js is a simple way to display your Instagram photos on your website.

Version 2 of Instafeed.js is now available, powered by the new Instagram Basic Display API.

For help upgrading from v1, see the v2 migration guide.

Hosted Alternative

When I originally wrote Instafeed.js in 2012, I wanted to create an easy way to quickly add your Instagram photos to your website. I like to think I was able to do that, in large part thanks to the public API Instagram had at the time.

Unfortunately, Facebook has made this process a lot more complex than it used to be. The largest problem is that managing API tokens now requires a server-side component, which I can’t provide through Instafeed.js alone.

If you're looking for a turnkey solution that manages tokens for you, or you need more advanced features like hashtag feeds, I recommend looking at Behold. It's a paid service, but it has a free tier that will work for smaller projects.

Check out Behold

Installation

Setting up Instafeed is pretty straight-forward - there are 3 main steps.

  1. Create a Facebook app linked to Instagram, and add yourself as a test user. See Managing User Tokens.
  2. Create an access token and provide it to an Instagram Token service
  3. Add the instafeed.js script to your web page and provide some simple options. See Basic Usage
<script type="text/javascript" src="path/to/instafeed.min.js"></script>

Note: Instafeed.js is also compatible with require.js and commonJS exports

Basic Usage

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

<script type="text/javascript">
    var feed = new Instafeed({
      accessToken: 'your-token'
    });
    feed.run();
</script>

Instafeed will automatically look for a <div id="instafeed"></div> and fill it with linked thumbnails. Of course, you can easily change this behavior using standard options. Also check out the advanced options for some advanced ways of customizing Instafeed.js.

Requirements

  • A Facebook developer account, and an Instagram account with some media posted to it.
  • A Facebook app linked to your Instagram account, and a token generated through that app.
  • A service to keep your access token fresh

Options

Here are some of the most commonly used options:

Key Default Value Valid types Description
accessToken null String, Function Required. The Instagram access token, either as a string, or a function which returns a string
debug false Boolean Set to true to display debugging information
filter null Function A function used to exclude images from your results. The function will be given the image data as an argument, and expects the function to return a boolean.
limit null Number Display a maximum of this many posts
sort null Function A custom function to sort the media, rather than the default 'most recent' sorting
target 'instafeed' String, DOM Element Either the ID or the DOM element itself where you want to add the images.
template '<a href="{{link}}"><img title="{{caption}}" src="{{image}}" /></a>' String A mustache template used to produce HTML for the document.
transform null Function A function used to transform the image data before it is rendered.

See Options in the wiki for the complete reference.

Templating

The easiest way to control the way Instafeed.js looks on your website is to use the template option. You can write your own HTML markup and it will be used for every image that Instafeed.js fetches. See Templating.

Changelog

See CHANGELOG.md.

Comments
  • New Instagram API restrictions & how it affects Instafeed.js

    New Instagram API restrictions & how it affects Instafeed.js

    UPDATE (@stevenschobert): This thread has turned into a conversation about how Instafeed.js is going to work with Instagram's new API restrictions.

    Currently, new Instagram API clients are not able to fetch much of the data that Instafeed.js relied on to work, and we are evaluating options for how to handle authentication going forward. Credentials created before the API restrictions went live are not affected for now.


    Original Post: I'm working on a client project (built on Shopify platform) and am looking to pull in their Instagram posts by user. I have it all setup - but it will not pull in my client's account. When I plug in my personal Instagram account userId & clientId, everything works perfect so I know it's not an issue with how I have it set up. Are there any known security settings that will prevent instafeed from working on a specific account? To note, the account I'm looking to pull in has a very large following.. not sure if that has anything to do with it?

    Here's the set-up I have for reference (includes liquid language as used on Shopify, so just ignore that):

    {% assign instafeed_img = '{{image}}' %}
    {% assign instafeed_link = '{{link}}' %}
    {% assign instafeed_likes = '{{likes}}' %}
    {{ 'instafeed.min.js' | asset_url | script_tag }}
    <script type="text/javascript">
    
    var userFeed = new Instafeed({
        target: 'instafeed',
        get: 'user',
        userId: '260149935',
        clientId: 'xxx',
        limit: '10',
        sortBy: 'most-recent',
        resolution: 'standard_resolution',
      template: '<div class="grid__item large--one-fifth"><a href="{{ instafeed_link }}" target="_blank"><img src="{{ instafeed_img }}"><span class="likes"><span class="icon icon-heart" aria-hidden="true"></span>{{ instafeed_likes }}</span></a></div>'
    });
    userFeed.run();
    </script>
    
    Instagram API deprecation 
    opened by goldprismco 245
  • Changes to Instagram API policy has broken Instafeed

    Changes to Instagram API policy has broken Instafeed

    Instafeed is now returning the following error:

    Uncaught Error: Error from Instagram: The access_token provided does not match an approved application.

    Instagram have changed their API policy, effective as of the 1st of June: https://www.instagram.com/developer/endpoints/users/

    Instagram Platform and documentation update. Apps created on or after Nov 17, 2015 will start in Sandbox Mode and function on newly updated API rate-limits and behaviors. Prior to going Live, and being able to be used by people other than the developers of the app, these apps will have to go through a new review process. Please read the API documentation or the Change Log for more details.

    Any app created before Nov 17, 2015 will continue to function until June 1, 2016. On that date, the app will automatically be moved to Sandbox Mode if it wasn't approved through the review process. The previous version of our documentation is still available here.

    Is development for Instafeed going to continue to address these changes?

    stale 
    opened by TamaEaston 119
  • Using standard resolution and all square media stop working

    Using standard resolution and all square media stop working

    I was using resolution: 'standard_resolution' and also disabled the Non Square Media option from the instagram client to get all the pictures squares on 612x612, however, this has stopped working out of the sudden yesterday, the images are now shown in their original resolution and not squares only. For "low_resolution" or "thumbnail" they images are all shown in squares but low resolution then. I tested this with different Instagram accounts and same thing happened. Also, I checked some other sites using instafeed.js and noticed their images are also now shown in different sizes and not squares.

    stale 
    opened by jramgit 54
  • Invalid URL signature

    Invalid URL signature

    I am accessing Instagram and it was working fine till yesterday. But now I am only getting some images and not all. I am attaching a screenshot of my screen and success and failure network headers. Trying to solve this for half day but I am unable to understand the issue as it is saying Invalid URL signature. website screen shot failure network header sucess network header

    Please help.

    opened by sarthakss 37
  • limit:60 not working

    limit:60 not working

    Hey!

    So regardless of what number I put over 33, it always returns only 33 images. The user account has 143 images currently. I've added the JS part of it hiding the ID and token.

    var userFeed = new Instafeed({
        get: 'user',
        userId: ID,
        accessToken: 'token',
        resolution: 'low_resolution',
        limit: 60,
        sortBy: 'most-recent',
        template: '<div><img src="{{image}}" /><span class="caption">{{caption}}</span><span class="likes">{{likes}}<i class="icon-heart"></i></span></div>'
    });
    userFeed.run();
    

    Thanks for the help!

    bug 
    opened by ankeetguha88 36
  • Limit with filter

    Limit with filter

    Is it possible to limit the number of images while applying a filter, such that it will look through all the images in the user's feed to satisfy the limit?

        var feed = new Instafeed({
            get: 'user',
            userId: USER_ID,
            clientId: 'CLIENT_ID',
            accessToken: 'ACCESS_TOKEN',
            template: '<a href="{{link}}"><img src="{{image}}" /></a>',
            limit: 12,
            filter: function(image) {
                return image.tags.indexOf('mytag') >= 0;
            }
        });
        feed.run();
    
    question 
    opened by jaredprice 23
  • Option 'accessToken' is not needed when getting user feed

    Option 'accessToken' is not needed when getting user feed

    Instagram user's recent feed can be fetched without accessToken if clientId is provided, but your script throws an error if accessToken is not provided. I commented rows 225-227 and it works perfectly ( https://github.com/stevenschobert/instafeed.js/blob/master/instafeed.js ).

    https://api.instagram.com/v1/users/{user-id}/media/recent/?client_id=YOUR-CLIENT_ID

    opened by samisiuvatti 22
  • 🎉 Version 2 RC3 is available.

    🎉 Version 2 RC3 is available.

    This issue is to notify everyone that v2 is on its way. We're putting migration and usage instructions together now, and will have an initial version available very soon.

    Stay tuned!

    announcements 
    opened by benjamin-hull 19
  • Instagram API Announcement - how it will impact on instafeed?

    Instagram API Announcement - how it will impact on instafeed?

    I have reveived this email

    Hi Instagram Sandbox Developer,

    We have recently announced new features to the Instagram API and are upgrading it to Facebook's Graph API. We encourage you to check out the exciting announcement shown here: https://business.instagram.com/blog/new-instagram-api-features/. With these new implementations, we will only be allowing and reviewing new applications for the basic permission level of the existing Instagram API (instagram.com/developer). Starting October 1st, developers will no longer be able to apply to access any permissions other than the basic permission via the existing API. Since you are in sandbox mode, this means that you are in development so we highly encourage you to submit your API application before the end of September if you are interested in accessing more than the basic permissions.

    For more information on the new Instagram Graph API, including the new permissions and what they can offer your product, please navigate to the facebook.com/developer site.

    Thanks, The Instagram Platform Team

    Instagram API deprecation stale 
    opened by ghost 19
  • ⚠️ Updated! Instafeed v1 will stop working June 29, 2020 ⚠️

    ⚠️ Updated! Instafeed v1 will stop working June 29, 2020 ⚠️

    Updated: March 31, 2020. The legacy API shutdown will now happen on June 29, 2020. Please update instafeed.js to version 2 before then. New integrations with the legacy API are still not possible - for new integrations please start with instafeed.js v2.

    If you have problems getting instafeed.js to work, or it has stopped working on your site, please do not open an issue.

    The legacy API is in the process of being retired, which will cause instafeed.js to stop working on ~~March 31st, 2020~~ June 29, 2020. Instagram is no longer issuing access tokens for the legacy API, so you will not be able to start using instafeed.js even before this date.

    For more information, please see the project README and issue #345

    We are currently looking into ways to make instafeed.js work with Instagram's new API, but we don't know if or when that might be available. To keep up to date with that discussion, please see issue #635.

    Instagram API deprecation announcements 
    opened by benjamin-hull 17
  • Uncaught Error: Error from Instagram: The access_token provided is invalid.

    Uncaught Error: Error from Instagram: The access_token provided is invalid.

    Hi there,

    I'm new to this, so I might be doing something wrong.

    I followed the instructions at: http://instafeedjs.com, but cannot get anything to show up when I load my test html page in a browser.

    I think I successfully created a client on the Instagram site and entered the clientId in the html file, but I keep getting this error:

    Uncaught Error: Error from Instagram: The access_token provided is invalid.

    Appreciate any suggestions.

    Thanks,

    dr-f

    duplicate 
    opened by drfinklestein 16
  • Instafeed token not working

    Instafeed token not working

    I have been using Instafeed for nearly a year and from time to time I would have to generate a new token. Although after trying that yesterday Instafeed seems not to be working and doesn't pull any images. From the console I get the following errors: Failed to load resource: the server responded with a status of 400 () Error: api request error: 190 Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.

    opened by monzanifabio 0
  • Cant overwrite template with filter transform or render

    Cant overwrite template with filter transform or render

    I am trying to change the template depending if its a image or video but it doesnt seem to work, it just uses the template provided when calling the function

    <script src="https://cdn.jsdelivr.net/gh/stevenschobert/[email protected]/src/instafeed.min.js"></script>
    <div class="instagram-module" id="instafeed"></div>
    
    <script type="text/javascript">
        var feed = new Instafeed({
            get: 'user',
            target: 'instafeed',
            limit: 10,
            template: '<a class="instagram-link" href="{{link}}" target="_blank" rel="noopener"><figure class="instagram-figure"><video controls loop><source src="' + image.model.media_url + '" type="video/mp4"/></video><figcaption class="instagram-caption" >{{caption}}</figcaption></figure></a>',
            resolution: 'low_resolution',
            accessToken: 'token',
            filter: function(image) {
    
                if (image.type == 'image' ) {
                    image.template = '<img src="' + image.image + '" />';
                } else {
          
                    image.template = '<video controls loop><source src="' + image.model.media_url + '" type="video/mp4"/></video>';
                }
                return true;
            }
        });
        feed.run();
    </script>
    
    opened by kiwo12345 0
  • Bump shell-quote from 1.7.2 to 1.7.3

    Bump shell-quote from 1.7.2 to 1.7.3

    Bumps shell-quote from 1.7.2 to 1.7.3.

    Changelog

    Sourced from shell-quote's changelog.

    1.7.3

    • Fix a security issue where the regex for windows drive letters allowed some shell meta-characters to escape the quoting rules. (CVE-2021-42740)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • How to get all posts with hashtag. I am using the below code.

    How to get all posts with hashtag. I am using the below code.

    var userFeed = new Instafeed({ get: 'tagged', tagName: 'tagname', target: "instafeed-container", resolution: 'low_resolution', limit:12, userId:'3333....', template:'code here', accessToken: 'number here', transform: function(item) { item.timestamp = new Date(item.timestamp).toLocaleString('en-AU', { month: 'long', day: 'numeric' }); return item; }, filter: function(image) { return image.tags.indexOf('[tagnam]') >= 0; } }); userFeed.run();

    opened by webbipinpal 0
  • Bump minimist from 1.2.5 to 1.2.6

    Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v2.0.0)
  • v2.0.0(May 31, 2021)

  • v2.0.0-rc3(Nov 11, 2020)

    • Fixes assignment to undeclared variable match bug.
    • Adds ES module support by building a separate distributable instafeed.es.min.js.
    • Re-adds pagination support via hasNext and next methods.
    • Adds apiLimit option to override how many images are requested from the Instagram API. This option supersedes the limit option.
    • Adds pooling support when apiLimit is higher than limit.
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0-rc2(May 18, 2020)

    • Adds before callback option that was missing from 2.0.0-rc1.
    • Fixes Invalid State Error bug in Internet Explorer. Thanks @awoodford.
    • Hashtags are now parsed from the image caption, and made available as a tags array on the image data.
    • Changed default timeout options apiTimeout and accessTokenTimeout from 5000 (5 seconds) to 10000 (10 seconds)
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0rc1(Mar 30, 2020)

  • v1.4.1(Nov 10, 2015)

  • v1.4.0(Nov 2, 2015)

    • accessToken is no longer required to fetch images from user accounts!
    • New template helpers for working with the new portrait and landscape images.
    • target can now accept a DOM node directly, instead of just a string ID, thanks @juhamust!
    • Squashed the last (hopefully!) of the IE8 bugs.
    • Fixed image loading errors when using Instafeed.js on a local file protocol (file://). Thanks @spoonben!
    • Added support from AMD and CommonJS.
    • Improved error messaging when Instafeed.js can't find it's target element on the page.
    • Instafeed.js no longer complains when trying to use strings for the userId, locationId, and limit options.
    Source code(tar.gz)
    Source code(zip)
  • v1.3.2(Apr 22, 2014)

  • v1.3.1(Mar 31, 2014)

  • v1.3.0(Mar 22, 2014)

    • Image URLs are now protocol-relative by default. Use the new useHttp option to disable.
    • Added the ability to filter out images using the filter option.
    • Added pagination support using .next() and .hasNext() methods.
    • Removed the default limit of 15 images. The option is still supported, but by default no limit is sent to the API.
    Source code(tar.gz)
    Source code(zip)
Owner
Steven Schobert
Steven Schobert
Lavanstax project - Makes it easy and fun to use İnstagram. Also first userbot for İnstagram

Lavanstax Lavanstax project - Makes it easy and fun to use İnstagram. Also first userbot for İnstagram | İnstagram | Telegram Channel | Telegram Group

Berathan Yedibela 19 Oct 15, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
A simple Instagram JavaScript plugin for your website

Instafeed.js Instafeed.js is a simple way to display your Instagram photos on your website. Version 2 of Instafeed.js is now available, powered by the

Steven Schobert 3.4k Dec 20, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A simple Node.js code to get unlimited instagram public pictures by every user without api, without credentials.

Instagram Without APIs Instagram Scraping in August 2022, no credentials required This is a Node.js library, are you looking for the same in PHP? go t

Francesco Orsi 28 Dec 29, 2022
Scrap all (almost) posts from your instagram

inst scrap Scrap all (almost) posts from your instagram Дисклеймер Конечно это неопттимальный говнокод c багами) Но +- работает) Шаг 1 Залогиньтесь в

Dmitry Khorkin 4 Mar 13, 2022
✨ Bot that can check your Friendship on Instagram

Instagram Friendship Checker Bot that can check your friendship on Instagram. It can told you who are your mutual, your following who don't follow you

Gading Nasution 12 Dec 21, 2022
This Repository create for download things from instagram via telegram. write with javascript

Instagram-Downloader This Repository create for download things from instagram via telegram This bot is free to use. You can change as you like and yo

RioProjectX 7 Dec 23, 2022
Follows Instagram @iamfadlyid_

Requirements • Installation • Fature Test • Bug Report • Features • Thanks to Requirements Node.js Git FFmpeg (for sticker command) Libwebp (for stick

Fadly ID 3 Sep 10, 2022
Scrape data from Instagram without applying for the authenticated API 🎯

scraper-instagram Scrape data from Instagram without applying for the authenticated API. Getting started Prerequisites NodeJS NPM or Yarn Install From

fabi.stehle 11 Jan 5, 2023
Get follower count for Instagram, Twitter, TikTok, Youtube accounts

?? You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. follower-count Install npm i follower-count Example

EGOIST 96 Dec 16, 2022
Lightweight library service that can dynamically make periodic updates to an Instagram profile.

instagram-dynamic-profile library This library uses the instagram-private-api to automate dynamic updates to an Instagram profile such as cycling thro

null 1 Sep 21, 2022
A social network app cloned from Instagram built with Next.Js, Socket.IO and a lots of other new stuff.

Instagram Noob ⚡ A social network app cloned from Instagram built with Next.Js, Socket.IO and a lots of other new stuff. Live Demo: https://instagram-

Hung Minh 20 Oct 19, 2022
CSS library for Instagram filters

CSSgram CSSGram is an Instagram filter library written in Sass and CSS. What is This? Simply put, CSSgram is a library for editing your images with In

Una Kravets 5.3k Jan 4, 2023
Derste birlikte geliştirdiğimiz instagram clonu - henüz bitmedi -

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Tayfun Erbilen 73 Jan 5, 2023
This is a clone of Instagram built with NextJS, TailwindCSS, NextAuthJS and Firebase

Instagram This is a clone of instagram built with: This application is completely functional and responsive. Users can Sign in straightaway with Googl

Nutifafa Afi Attor 13 Sep 2, 2022
Instagram clone based on Demon slayer characters ⚔️

Instagram clone based on Demon slayer characters ?? - About this project You must sign in with google to be able to like and comment on the demon slay

miraya 6 Nov 8, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022