Instagram Reels API: How to Post Videos to Reels Using a Social Media API

Instagram Reels are finally here! It is been a long time coming, but Instagram has updated their API to support Reels video posting. This means that you can use the Facebook Graph API, which is technically how you access the Instagram API, to share videos, carousels, and now Reels on behalf of your users.

With the success of short videos on TikTok, Instagram has leaned more into Reels, their TikTok competitor.

Reels content is rapidly growing in popularity on Instagram. According to Meta, Reels now makes up for more than 20% of the time that people spent on Instagram. So to continue to expand Reels, Instagram now allows 3rd party apps to share video to the Reels tab.

If you’re looking for how to post a short form video to Facebook, see our Facebook Reels API article.

What are Instagram Reels?

As Instagram states:

Reels are entertaining, immersive videos where you can creatively express your brand story, educate your audience, and get discovered by people who may love your business.

Essentially, Reels are like TikTok videos where you can share a 60-second, now 90-seconds, video and do some cool creative adds, such as stitch together and edit video clips, add music, apply filters, write captions, insert interactive backgrounds, and add stickers.

Instagram has dedicated an entire tab in the mobile app to Reels.

In this Reels tab, you can see all Reels and not just for the accounts you follow.

Instagram has tried to make Reels fun and interactive, with opportunities for creators to go viral.

Using the Instagram API with Reels

The Instagram API has been expanded to support Reels. The endpoint POST/{ig-user-id}/media has been update to accept media_type REELS. If you’re familiar with posting a video to IG, it is almost exactly the same:

POST https://graph.facebook.com/{api-version}/{ig-user-id}/media
?media_type=REELS               // New
&video_url={reel-url}
&caption={caption}
&location_id={location-id}
&thumb_offset={thumb-offset}    // Available for Reels
&share_to_feed={share-to-feed}  // New
&access_token={access-token}

Of note are two key differences:

  • media_type set to REELS. This allows the video to be marked as a reel in Instagram.
  • share_to_feed set to true if you want the reel to appear in both the Feed and Reels tabs. This requires the reel meet the requirements on duration, length, and encoding.

Also available, like videos, is the thumb_offset field. This allows you to specify a location (milliseconds) frame in the video to use as the thumbnail.

As an Instagram developer, you can really choose any programming language to code in…they are just REST API calls after all. Let’s start with an example in JavaScript using fetch to post the reel to Instagram. I suggest running server-side in Node.js given the sensitive data, such as the access token.

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);

This JavaScript code makes a fetch call to the Facebook Graph media endpoint on behalf of an Instagram user (instagram_user_id). The key fields are the URL to the Reels MP4 file (video_url), the media_type as REELS, and the access_token. It is that simple!

If you need help with the Instagram access token, see the Instagram Graph API overview.

How Long Can A Reel Be via The API?

In the Instagram API docs it states that Reels can be 90 seconds long. However, we’ve found that the 60 seconds maximum video length is still in effect. This perhaps is a bug with the new Reels implementation. We’ll update this article if the accepted duration is expanded to 90 seconds.

Using Ayrshare’s Social Media API

One other option to post IG Reels is using Ayrshare’s social media API. Specifically, you can use the Reels options to post video to Instagram, YouTube, Facebook, TikTok, and more.

{
    "instagramOptions": {
        "reels": true,
        "shareReelsFeed": true
    }
}

For example, here is a fully example in Python of posting to Instagram using the social API:

import requests

payload = {'post': 'Today is a great day!', 
        'platforms': ['instagram'],
        'mediaUrls': ['https://img.ayrshare.com/012/reel.mp4'],
        'instagramOptions': {
           'reels': true,
           'shareReelsFeed': true
        }},
headers = {'Content-Type': 'application/json', 
        'Authorization': 'Bearer API_KEY'}

r = requests.post('https://app.ayrshare.com/api/post', 
    json=payload, 
    headers=headers)
    
print(r.json())

And the same Instagram API post in JavaScript:

const fetch = require("node-fetch");
const API_KEY = "API_KEY";

fetch("https://app.ayrshare.com/api/post", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${API_KEY}`
      },
      body: JSON.stringify({
        post: "Today is a great day!",
        platforms: ["instagram"],
        mediaUrls: ["https://img.ayrshare.com/012/reel.mp4"],
        "instagramOptions": {
           "reels": true,
           "shareReelsFeed": true
        }
      }),
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);

You can also post Facebook Reels with the API.

As an Instagram developer we are always wanting more features. Thankfully IG has been enhancing their API regularly with recent additions such as Product Tagging, Carousels, and Comments.

Fingers cross Instagram Stories posting will be next! UPDATE: Instagram now offers Stories publishing with the Instagram Stories API.