Instagram user feed PHP

Build Status Packagist Coverage Status

Minimum PHP Version Last version Total Downloads Visitor badge

All Contributors


Easily fetch any Instagram feed and more without OAuth for PHP.

If you like or use this package, please share your love by starring this repository, follow @pgrimaud or become a sponsor. πŸ™πŸ’“


  • Fetch profile data of user
  • Fetch medias of user
  • Fetch stories of user
  • Fetch highlights stories of user
  • Fetch detailed post of user
  • Fetch feed of followers
  • Fetch feed of followings
  • Follow or unfollow users
  • Like or unlike posts
  • Fetch posts of hashtag
  • Fetch comments of a post
  • NEW : Fetch live-streaming info
  • NEW : Fetch Reels πŸŽ‰
  • NEW : Fetch IGTV πŸŽ‰
  • NEW : Fetch medias where a user has been tagged on πŸŽ‰
  • NEW : Fetch HD profile picture πŸŽ‰
  • NEW : Post a message to a media πŸŽ‰

This version can retrieve ANY Instagram feed using web scrapping.

⚠️ Version ^5.0 is no more maintained. ⚠️


composer require pgrimaud/instagram-user-feed


v6.12 - 2021-09-20:

  • Add method to post message on a media (example here) πŸŽ‰.
  • Add method to get HD profile picture (example here) πŸŽ‰.

v6.11 - 2021-09-13:

  • Add method to fetch medias where a user has been tagged on (example here) πŸŽ‰.

v6.10 - 2021-09-03:

  • Add method to fetch IGTV (example here) πŸŽ‰.
  • Add method to fetch Reels (example here) πŸŽ‰.
  • Split dirty tests in multiple files.

v6.9 - 2021-09-02:

  • Add method to fetch Instagram live-streaming info. Thanks to David-Kurniawan
  • Minor fixes.

v6.8 - 2021-07-08:

v6.7 - 2021-01-31:

  • New feature: get post of hashtag.
  • New feature: get comments of post.
  • Add support for PHP 8.
  • Minor changes and improvements.

v6.6 - 2020-10-06:

  • New feature: like and unlike posts.
  • Retrieval #hashtags and @mentions from stories.
  • Minor changes and improvements.

v6.5 - 2020-09-14:

  • New feature: follow and unfollow users. Thanks to @David-Kurniawan)
  • Minor fixes.

v6.4 - 2020-08-30:

  • New feature: fetch followers and followings feeds. Thanks to @David-Kurniawan)
  • Minor improvements.

v6.3 -2020-07-03:

  • Add checkpoint challenge bypass using IMAP configuration.

v6.2 - 2020-06-01:

  • Improve medias crawling && cache constraints.

v6.1 - 2020-05-21:

  • New feature: Fetch stories and highlights stories.

v6.0 - 2020-05-20

  • Please upgrade from ^5.0 for cookies session stability.

Version ^6.8: strict-origin-when-cross-origin

Facebook added a new CORS policy, and you can't display the data directly.

You can now download media on your storage or server to serve it directly on your website. You can find an example here.



// include vendor & classes

// random picture from instagram
$url = ''

// define directory
$downloadDir = __DIR__ . '/../assets'; // change it

$fileName = MediaDownloadHelper::downloadMedia($url, $downloadDir);
// file was downloaded here : __DIR__ . '/../assets/v-t51.2885-19-s150x150-156309873_1632221153646196_1273891214497323498_n.jpg

Version ^6.3: Checkpoint challenge bypass

Some people may have trouble to login with this library. It happens for "old" Instagram accounts or if you're using it on some shared hosting (not all, I don't know why...).

You can now automatically bypass the checkpoint challenge. (email verification with code). You can find an example here.

Tips: you should create a dummy instagram account using a dummy e-mailbox to use this feature.

How it works?

  1. The lib will try to login
  2. Got 400 error "checkpoint_required"
  3. Trigger email verification
  4. Connect to your email inbox using IMAP credentials
  5. Wait for Instagram verification email
  6. Parse verification code from email
  7. Make a request to instagram with this code to complete verification
  8. Verification is done, then *save session automatically**

*Saving session with cache driver is very important here. The Instagram session is valid for... 1 YEAR. So in theory, using a cache driver and one account will trigger only one real login to Instagram then reusing session for a long time.

Thanks to @ibnux and @eldark for help πŸŽ‰

Version ^6.0: Login

In version ^6.0, login is now mandatory, it will save cookies (session) to simulate "real" requests to Instagram.

They improve their bot detection and without real session data in the headers requests, your IP could be easily soft-ban by Instagram.

Then, you can't fetch a lot of data without login.

Tips: you just have to create or use a dummy account to use easily this package.


New in 6.0 Cache : This library implements PSR-6 for greatest interoperability.


use Instagram\Api;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');

$api = new Api($cachePool);
$api->login('username', 'password'); // mandatory
$profile = $api->getProfile('robertdowneyjr');

echo $profile->getUserName(); // robertdowneyjr

echo $profile->getFullName(); // Robert Downey Jr. Official

Basic usage :


$api = new Api($cachePool);
$api->login('username', 'password');

$profile = $api->getProfile('robertdowneyjr');

Instagram\Hydrator\Component\Feed Object
    [id] => 1518284433
    [userName] => robertdowneyjr
    [fullName] => Robert Downey Jr. Official
    [biography] => @officialfootprintcoalition @coreresponse
    [followers] => 46382057
    [following] => 50
    [profilePicture] =>
    [externalUrl] =>
    [private] => 
    [verified] => 1
    [mediaCount] => 453
            [0] => Instagram\Model\InstagramMedia Object
                    [id] => 2307655221969878423
                    [typeName] => GraphImage
                    [height] => 1350
                    [width] => 1080
                    [thumbnailSrc] =>
                    [link] =>
                    [date] => DateTime Object
                            [date] => 2020-05-12 22:06:01.000000
                            [timezone_type] => 3
                            [timezone] => Europe/Paris

                    [displaySrc] =>
                    [caption] => The sweetest things are worth waiting for…Susan and I are producing a @Netflix original series, Sweet Tooth, based on the comic by @Jefflemire. Can’t wait to share it with you all. 🦌 πŸ‘¦ @NXonNetflix @warnerbrostv #SweetTooth
                    [comments] => 3308
                    [likes] => 687988
                    [thumbnails] => Array
                            [0] => stdClass Object
                                    [src] =>
                                    [config_width] => 150
                                    [config_height] => 150

                            [1] => stdClass Object
                                    [src] =>
                                    [config_width] => 240
                                    [config_height] => 240

                            [2] => stdClass Object
                                    [src] =>
                                    [config_width] => 320
                                    [config_height] => 320

                            [3] => stdClass Object
                                    [src] =>
                                    [config_width] => 480
                                    [config_height] => 480

                            [4] => stdClass Object
                                    [src] =>
                                    [config_width] => 640
                                    [config_height] => 640


                    [location] => 
                    [video] => 
                    [videoViewCount] => 0
    [endCursor:Instagram\Model\InstagramProfile:private] => QVFEblBGclVyOEtCMmRLZkVxUUdVbmhsYXNMZmMmplNWtZRkJnRnZOSUdMM1BDRmt3ZA==


If you want to use paginate on medias, just call getMoreMedias method.


$api = new Api($cachePool);
$api->login($credentials->getLogin(), $credentials->getPassword());

$profile = $api->getProfile('twhiddleston');

print_r($profile->getMedias()); // 12 first medias

do {
    $profile = $api->getMoreMedias($profile);
    print_r($profile->getMedias()); // 12 more medias

    // avoid 429 Rate limit from Instagram
} while ($profile->hasMoreMedias());



use Instagram\Api;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');

$api = new Api($cachePool);
$api->login('username', 'password'); // mandatory

$profile = $api->getProfile('starwars'); // we need instagram username
$feedStories = $api->getStories($profile->getId());

$stories = $feedStories->getStories();



Thanks goes to these wonderful people (emoji key):

Pierre Grimaud


Jan Γ–stlund


Tim Bond










David Greminger




David Kurniawan




Chun-Sheng, Li






Georgy Gusev


Jibran Ijaz


Julien Cousin-Alliot




This project follows the all-contributors specification. Contributions of any kind welcome!


You found a bug? You need a new feature? You can create an issue if needed or contact me on Twitter.


Licensed under the terms of the MIT License.

Instagram User Feed

This is a scrapper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.

Instagram User Feed Info

⭐ Stars567
πŸ”— Source
πŸ•’ Last Update10 months ago
πŸ•’ Created5 years ago
🐞 Open Issues0
βž— Star-Issue RatioInfinity
😎 Authorpgrimaud