skip to Main Content

I cannot find an Instagram Reels related API. Does anyone know if there is one or if there will be one?

Currently the Facebook developer documentation does not mention anything about Instagram Reels.
https://developers.facebook.com/docs/instagram-api/overview/

10

Answers


  1. Not sure, but I did some digging around an Instagram .ipa file and found these url scheme parameters.

    instagram://reels_home
    instagram://reels_share
    

    Both of which if clicked on ios will take you to the reels feed. My intentions are to open the reels camera (or the story camera with the mode set to reels), but i guess currently we can only access the reels feed.

    Login or Signup to reply.
  2. Reels it is IG Media with type "VIDEO".
    And you can fetch single "Reels" if you know his Facebook Media ID (It is not Media ID from instagram)

    If reels published like stories you can get media’s list from stories endpoint(GET graph.facebook.com/{ig-user-id}/stories). You will get array of medias’ ids.

      "data": [
        {
          "id": "{ig-media-id}"
        },
      ...
      ]
    }
    

    Then you can fetch information from single media object endpoint (GET /{ig-media-id})

    So at current moment you can get reels by api only if they published like story.

    Anyway reels is not supported in some countries and you can see reels only from stories in this countries.

    UPDATE

    Reels also available when you fetch user media from business-discovery(GET {ig-user-id}?fields=business_discovery.username(instagramm_user_name){media{id,permalink,media_type,media_url}}
    ) or user media (GET /{ig-user-id}/media).

    If media’s permalink look likes https://www.instagram.com/reel/... and media_type VIDEO then is it reels.

    Login or Signup to reply.
  3. UPDATED ANSWER:

    Reels are now supported via the API; it became generally available on July 6, 2022. Please see https://developers.facebook.com/blog/post/2022/06/27/introducing-reels-apis-to-instagram-platform/.


    ORIGINAL ANSWER:

    In the Instagram API docs, under Limitations, it currently says "Reels are not supported."

    Login or Signup to reply.
  4. It seems they were included in the GET /{ig-user-id}/media and the GET {ig-user-id}?fields=business_discovery.username(instagramm_user_name) endpoints at the beginning but they removed them later. According to the docs they are not supported at the moment. Further confirmed in this bug report. It seems it is not the first time they include nodes that are not supposed to be included (IGTV and now reels).

    Login or Signup to reply.
  5. Naa,

    Instagram doesn’t provide any API for Reels yet, since the reel feature is still not available in many countries but this going to be available soon.

    So the question arises here, how we can get the reels data via API?

    Well, the answer is you can’t But! if you are in favour to do so some scraping thing then the answer is definitely Yes!

    But How?

    We all know scraping has lots of efforts, due to things get changed very frequent. and if you don’t care about those below are sample PHP script to fetch reels data in JSON.

    <?php
    
    //!IMPORTANT
    $sessionid = ["Cookie: sessionid=YOUR SESSION ID HERE"];
    
    // REELS SHORT CODE FROM URL
    $shortcode = null;
    
    $response = [];
    
    /**
     * Get a web file (HTML, XHTML, XML, image, etc.) from a URL.  Return an
     * array containing the HTTP server response header fields and content.
     */
    function get_web_page($url)
    {
        $user_agent = 'Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0';
        $options    = array(
            CURLOPT_CUSTOMREQUEST  => "GET",        //set request type post or get                            
            CURLOPT_POST           => false,        //set to GET    
            CURLOPT_USERAGENT      => $user_agent,  //set user agent                                    
            # CURLOPT_COOKIEFILE   => "cookie.txt", //set cookie file                                     
            # CURLOPT_COOKIEJAR    => "cookie.txt", //set cookie jar                                     
            CURLOPT_HTTPHEADER     => $sessionid,   // sending manually set cookie                                   
            CURLOPT_RETURNTRANSFER => true,         // return web page                                
            CURLOPT_HEADER         => false,        // don't return headers                                
            CURLOPT_FOLLOWLOCATION => true,         // follow redirects                                
            CURLOPT_ENCODING       => "",           // handle all encodings                            
            CURLOPT_AUTOREFERER    => true,         // set referer on redirect                                
            CURLOPT_CONNECTTIMEOUT => 120,          // timeout on connect                            
            CURLOPT_TIMEOUT        => 120,          // timeout on response                            
            CURLOPT_MAXREDIRS      => 10,           // stop after 10 redirects                            
        );
        $ch = curl_init($url);
        curl_setopt_array($ch, $options);
        $content = curl_exec($ch);
        $err     = curl_errno($ch);
        $errmsg  = curl_error($ch);
        $header  = curl_getinfo($ch);
        curl_close($ch);
        $header['errno']   = $err;
        $header['errmsg']  = $errmsg;
        $header['content'] = $content;
        return $header;
    }
    
    if ((isset($_GET['q'])) && !empty($_GET['q'])) {
    
        $shortcode = $_GET['q'];
        $reels_url = "https://www.instagram.com/p/$shortcode/?__a=1";
    
        // read a web page and check for errors:
        $result = get_web_page($reels_url);
    
        if ($result['errno'] != 0) {
            $response = json_encode(['error' => "bad url, timeout, redirect loop"]);
        }
    
        if ($result['http_code'] != 200) {
            $response = json_encode(['error' => "no page, no permissions, no service"]);
        }
        
        if ($result['http_code'] === 200) {
            $response = $result['content'];
        }
    
    }
    
    // JSON OUTPUT OR ERROR HERE
    header('Content-Type: application/json');
    echo $response;
    
    

    How to use this PHP script?

    Save the above script in a PHP file e.g. fetch-reels.php and run it like
    http://localhost/fetch-reels.php?q={SHORT-CODE}

    Reels URL e.g.

    1. https://www.instagram.com/p/COlKxQLAM11
    2. https://www.instagram.com/reel/COlKxQLAM11/?igshid=12f6j9a1dfx2x
    Login or Signup to reply.
  6. As mentioned earlier Instagram doesn’t provide direct apis but you can take help of Instagrapi its really awesome and easy to use. Note : This Instagram Private API wrapper is in python.
    Here’s how to use it –
    Install the lib :

    python -m pip install instagrapi
    

    Code

        from instagrapi import Client 
        cl = Client()
        #enter your username and password
        cl.login('username', 'password')
        #you can replace 10 with whatever amount of reels you want to fetch
        reel = cl.explore_reels(amount = 10)
        print(reel)
    

    That’s it !!!

    Login or Signup to reply.
  7. Instagram just released reels support (Available to everyone from July 7th 2022).

    More here
    https://developers.facebook.com/docs/instagram-api/guides/content-publishing/

    Login or Signup to reply.
  8. Instagram Reels API is now generally available:

    https://developers.facebook.com/blog/post/2022/06/27/introducing-reels-apis-to-instagram-platform/

    You can make a scheduled post. For example using JavaScript and uploading a video to the Reels API[1]:

    const access_token = "Js82ks92jald"; // The access token given from FB
    const instagram_user_id = "12345";   // The IG user's ID
    const reelUrl = "https://www.website.com/reel.mp4";
    const caption = "This is the best real ever #Reels4Real";
    
    const postUrl = `https://graph.facebook.com/${instagram_user_id}/media?video_url=${encodeURIComponent(reelUrl)}&caption=${encodeURIComponent(caption)}&access_token=${access_token}&media_type=REELS&share_to_feed=true&thumb_offset=2000`;
    
    const postOptions = {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
    };
    
    fetch(postUrl, postOptions)
          .then((res) => res.json())
          .then(json => console.log(json))
          .catch(console.error);
    

    Note the key fields of media_type=REELS, video_url, and caption.

    [1] https://www.ayrshare.com/instagram-reels-api-how-to-post-videos-to-reels-using-a-social-media-api/

    Login or Signup to reply.
  9. Update (14-July-2022): Meta (Facebook) launched support for Reels via their official Graph API. Read more about it here: https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#reel-specifications

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search