Facebook Reels API: How to Post Facebook Reels Using a Social Media API

In case you have been a social recluse, short-form videos are hot right now – videos typically 3 seconds to 60 seconds long that are show vertically on your phone. Ever since TikTok kicked off the short-form video trend, every social media competitor has created their own version. Instagram with Instagram Reels, YouTube with YouTube Shorts, and recently Facebook Reels. Not only that, the networks have also been busy updating their API integrations with short-form videos: Instagram API, TikTok API, and YouTube API. All except Facebook, i.e. Meta…until now with the new Facebook Reels API.

What are Facebook Reels

Launched in September 2021, Facebook Reels are the answer to TikTok’s short form videos. As Facebook says:

Reels on Facebook can consist of music, audio, effects and more. You can find them in News Feed or in Groups, and when viewing a reel on Facebook, you can easily follow the creator directly from the video, like and comment on it, or share it with friends.

Reels have unique video requirements:

  • Duration: Up to 60 seconds and more than 3 seconds.
  • Format: MP4 (.mp4) video.
  • Minimum 1080P, and 4K if available (note: video will be capped at 720p after upload)
  • Upload aspect ratio: 9:16.

Creating Facebook Reels is as simple as recording a video on your mobile phone. In the Reels example below the format is 9:16, i.e. recorded on a mobile phone.

Facebook has also focused on helping creators generate revenue with their Facebook Reels Play Bonus program. How much money can you make? Basically if you have over 100K views over the course of 30-days, you will start earning up to $4,000 per month. Additionally, there are “challenges” to earn additional revenue.

Facebook Social Media APIs

The Facebook Graph API recently introduced the ability to directly share Reels videos via their Reels Publishing API. Previously you could only share to the Facebook platform via an iOS or Android app, but now you can post directly to their Reels API endpoint.

There are two steps you must complete before using the FB Reels API:

  1. The Facebook APIs use typical OAuth endpoints with tokens for posting permissions. OAuth allows users to authenticate and grant permissions to your app. These tokens are short lived, but can be exchanged for long-lived Page tokens. While we won’t dive deep, it is important to note you can only post Reels to Facebook Pages. Posting Reels to personal accounts or Group pages are not allowed by Facebook.
  2. Facebook requires you to request approval and go through a review process for API and permission access (pages_show_listpages_read_engagement, and pages_manage_posts permissions), which can take a few days to a few weeks. You’ll need to first create your app/integration, record a video of the usage, and write a justification for permissions via the Facebook developers portal. Expect to be rejected the first few times.

Facebook Reels API

Ok, now for the fun stuff…let’s try using the FB Reels API to post a video.

There are three Facebook API integration steps to post a short form video Reel. Here is an example video we’ll post.

Example Facebook Reel to Post

Reels Posting API Step 1

Initialize the upload of the video by calling the video_reels endpoint. The response is a video ID and upload URL.

GET https://graph.facebook.com/{page-id}/video_reels

The required query parameters are:

  • upload_phase=start
  • access_token={access_token}

The {page-id} and the {access_token} is the id of the Facebook Page and the Access Token granted retrieved during OAuth, respectively.

Here is an example in JavaScript:

const uploadStartUri = `https://graph.facebook.com/${page_id}/video_reels?upload_phase=start&access_token=${access_token}`;

const initiateUploadResponse = await fetch(uploadStartUri, { method: "POST" })
    .then((res) => res.json())
    .catch((err) =>
      console.log("Error initiating upload for FB Reels:", uploadStartUri, err)
    );

const { video_id, upload_url } = initiateUploadResponse;

The response in initiateUploadResponse, which will be used in Step 2:

{
 "video_id": "{video-id}",
 "upload_url": "https://rupload.facebook.com/video-upload/v13.0/{video-id}",
}  

Reels Posting Step 2

The next step is to upload the actual video. There are two ways: upload a local file as an application/octet-stream or provide an externally accessible video URL. We’ll focus on the externally accessing URL method.

Using the response from Step 1, make a request to the upload URL with the video id, your URL, and access token.

 POST https://rupload.facebook.com/video-upload/{video-id}

Note the different subdomain of rupload instead of the typical graph subdomain.

The require POST parameters are:

  • Header Authorization: "Oauth {access_token}"
  • Header file_url: {url}

Where the access_token is the same Access Token from above and the url is your externally accessible video URL.

Here is an example in JavaScript:

const options = {
    method: "POST",
    maxBodyLength: Infinity,
    headers: {
      Authorization: `OAuth ${access_token}`,
      file_url: url,
    },
  };

const uploadResponse = await fetch(upload_url, options)
    .then((res) => res.json())
    .catch((err) =>
      console.error(
        "Error uploading binary for Facebook Reels",
        upload_url,
        options,
        err
      )
    );

The response is unspectacular if everything was successful:

{"success": true}

Reels Posting Step 3

We’re almost done. Now the video needs to be published, which requires one final call.

POST https://graph.facebook.com/{page-id}/video_reels

The required POST parameters are:

  • access_token={access_token}
  • video_id={video_id}
  • upload_phase="finish"
  • video_state="PUBLISHED"
  • description="The video description text"
  • title="Video title" (optional)

Let’s see and example again in JavaScript:

const title = "Super Title";
const description = "Best Reel ever";
const basePublishReelsURI = `https://graph.facebook.com/${
    auth.id
  }/video_reels?upload_phase=finish&video_id=${video_id}title=${title}&description=${description}&video_state=PUBLISHED&access_token=${access_token}`;

const publishReelsResponse = await fetch(basePublishReelsURI, {
    method: "POST",
  })
    .then((res) => res.json())
    .catch((err) =>
      console.error("Error publishing for Facebook Reels:", basePublishReelsURI, err)
    );

Again, if everything is successful the response is unspectacular:

{"success": true}

Your Reel is now published!

Bonus API Call

If you want to check the status of the Reel – did it error, still processing, or fully published – you can call the status endpoint:

GET https://graph.facebook.com/{video-id}?fields=status

Alternative to the Facebook API

An alternative option to directly integrating with the Facebook API is Ayrshare’s social media API, which includes the Facebook Reels API integration. You no longer need approval or worry about the details of Facebook’s evolving API.

For example, to post a new Facebook Reels video use the following Javascript code with the /post endpoint. Be sure to replace API_KEY with your key from the dashboard:

const data = {
    "post": "The description of the video",
    "platforms": ["facebook"],
    "mediaUrls": "https://img.ayrshare.com/012/reel.mp4",
    "faceBookOptions": {
        "reels": true,
        "title": "Super title for the Reel" // optional
    }
};

const requestOptions = {
  method: 'POST',
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify(data)
};

fetch("https://app.ayrshare.com/api/post", requestOptions)
  .then(res => res.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

or if you prefer in Python:

import requests

payload = {'post': 'Today is a great day!', 
        'platforms': ['facebook'],
        'mediaUrls': ['https://img.ayrshare.com/012/reel.mp4']},
        'faceBookOptions': {
           'reels': true,
           'title': 'Super title for the Reel'
        }
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())

It is that easy using Ayrshare.

Facebook Analytics API

In addition to posting short form video Reels to Facebook, you also might want Facebook analytics about the user’s account or individual post, such as how many views, shares, or likes. These insights into user behavior, engagement, and reach can help build your social media strategy.

For example, to get the user level analytics across all their Facebook videos call the Ayrshare /analytics API endpoint. Here is the code in Javascript:

const data = { platforms: ["facebook"] };

const requestOptions = {
  method: 'POST',
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify(data)
};

fetch("https://app.ayrshare.com/api/analytics/social", requestOptions)
  .then(res => res.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Or call the analytics in Python:

import requests

payload = {'platforms': ['facebook']}
headers = {'Content-Type': 'application/json', 
        'Authorization': 'Bearer API_KEY'}

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

Detailed Facebook analytics are returned, such as followers, likes, demographics, and more.

{
    "facebook": {
        "analytics": {
            "about": "What to watch next? Create private groups with your friends to get recommendations on the next movie or show to watch.",
            "birthday": "11/20/1985",       // Applicable to Pages representing people
            "emails": ["[email protected]"],
            "engagement": {
                "count": 587,
                "socialSentence": "587 people like this."
            },
            "fanCount": 587,
            "followersCount": 587,
            "id": "102619320979033",
            "link": "https://www.facebook.com/102619320979033",
            "location": {
                "street": "142 W 57th St",
                "zip": "10019"
            }
            "name": "theGoodone",
            "pageConsumptions": 11,               // The number of times people clicked on any of your content.
            "pageConsumptionsByConsumptionType": {
                "link clicks": 3,
                "other clicks": 4,
                "video play": 4
            },
            "pageEngagedUsers": 1234,            // The number of people who engaged with your Page. Engagement includes any click.
            "pageFansByLikeSource": {},          // Daily: This is a breakdown of the number of Page likes from the most common places where people can like your Page. (Total Count)
            "pageFansByLikeSourceUnique": {},    // Daily: The number of people who liked your Page, broken down by the most common places where people can like your Page. (Unique Users)
            "pageFansCity": {                    // Lifetime: Aggregated Facebook location data, sorted by city (top 50), about the people who like your Page. (Unique Users)
                "Seattle, United States of America": 1,
                "Ras al-Khaimah, United Arab Emirates": 1,
                "Mexico City, Mexica": 1,
                ...
            },
            "pageFansCountry": {        // Lifetime: Aggregated Facebook location data, sorted by country (top 50), about the people who like your Page. (Unique Users)
                "BD": 1,
                "EG": 1,
                 ...
            },
            "pageFansGenderAge": {     // Lifetime: Aggregated demographic data about the people who like your Page based on the age and gender information they provide in their user profiles. (Unique Users)
                "M.25-34": 92,
                "F.13-17": 1,
                "M.55-64": 1,
                ...
            },
            "pageFansLocale": {        // Lifetime: Aggregated language data about the people who like your Page based on the default language setting selected when accessing Facebook. (Unique Users)
                "bn_IN": 3,
                "es_LA": 6,
                "pa_IN": 1,
                ...
            },
            "pageFanRemoves": 1,              // Unlikes of your Page.
            "pageImpressions": 160,           // The number of times any content from your Page or about your Page entered a person's screen. This includes posts, stories, ads, as well other content or information on your Page.
            "pageImpressionsPaid": 23,        // The number of times any post or story content from your Page or about your Page entered a person's screen through paid distribution such as an ad.
            "pagePostEngagements": 20,        // The number of times people have engaged with your posts through reactions, comments, shares and more.
            "pagePostsImpressions": 124,      // The number of times your Page's posts entered a person's screen. Posts include statuses, photos, links, videos and more.
            "pagePostsImpressionsPaid": 34,   // The number of times your Page's posts entered a person's screen through paid distribution such as an ad.
            "pageVideoViewTime": 10232,       // The total time, in milliseconds, people viewed your Page's video.
            "pageVideoViews": 31,             // The number of times your Page's videos played for at least 3 seconds, or for nearly their total length if they're shorter than 3 seconds. During a single instance of a video playing, we'll exclude any time spent replaying the video.
            "pageVideoViewsPaid": 6,          // The number of times your Page's promoted videos played for at least 3 seconds, or for nearly their total length if they're shorter than 3 seconds. For each impression of a video, we'll count video views separately and exclude any time spent replaying the video.
            "reactions": {                    // Total over past 180 days
                "like": 1,         // Like reactions - The "like" reaction counts include both "like" and "care" reactions.
                "love": 1,         // Love reactions
                "anger": 1,        // Anger reactions
                "haha": 1,         // Haha reactions
                "wow": 1,          // Wow reactions
                "sorry": 1,        // Sorry reactions
                "total": 6         // Total number of reactions
            },
            "username": "theGoodone",
            "verified": true,      // verified Facebook Page
            "website": "https://www.theGoodone.com"
        }
    }
}

If you want to get analytics on individual Facebook posts, call the /analytics post endpoint. The post level analytics data returned includes the shares, likes, impressions, clicks, and more:

{
    "facebook": {
        "id": "1397547544885713_2159201585286968", // ID of the post at Facebook
        "postUrl": "https://www.facebook.com/1397547544885713_2159201585286968",
        "analytics": {
            "impressionsUnique": 3,    // People who had your Page's post enter their screen. Posts include statuses, photos, links, videos and more.
            "engagedUsers": 63,        // People who clicked anywhere in your posts.
            "clicksUnique": 2,         // Times people clicked on anywhere in your posts.
            "commentCount": 1,         // Count of comment for the post
            "impressionsUnique": 1,    // Count of unique impressions
            "likeCount": 0,            // Count of likes for the post
            "negativeFeedback": 1,     // Times people took a negative action in your post (e.g. hid it).
            "negativeFeedbackUnique": 1, // Unique times people took a negative action in your post (e.g. hid it).
            "reactions": {
                "like": 1,         // Like reactions - The "like" reaction counts include both "like" and "care" reactions.
                "love": 1,         // Love reactions
                "anger": 1,        // Anger reactions
                "haha": 1,         // Haha reactions
                "wow": 1,          // Wow reactions
                "sorry": 1,        // Sorry reactions
                "total": 6         // Total number of reactions
            },
            "videoViewTime": 0,        // Time, in milliseconds, your videos played, including videos played for less than 3 seconds and replays
            "videoViews": 0,           // Times your videos played for at least 3 seconds, or for nearly their total length if they're shorter than 3 seconds. During a single instance of a video playing, we'll exclude any time spent replaying the video. This includes live views.
            "videoViewsUnique": 0,     // Unique times your videos played for at least 3 seconds, or for nearly their total length if they're shorter than 3 seconds. During a single instance of a video playing, we'll exclude any time spent replaying the video. This includes live views.
        }
    }
}

Start Sharing to Facebook

If you want to find out more about how to connect your Facebook account and post text, images, or videos using our social API, check out this guide. Also, we have several integration packages to make things easier.

And of course, let us know if you have any questions.