How to calculate an Instagram engagement rate in Python

Checked on 2026-11-19.

An engagement rate is interactions divided by an audience, times 100. The versions differ in what they take as the audience: followers, reach or views. For an account you do not own only the follower and view versions can be computed, because reach is private. Here are the formulas, where each number comes from, and Python code for both cases.

The formulas, and which is which

The names in quotation marks are the ones Hootsuite's guide to these formulas uses.

NameFormulaWho can compute it
By followers ("ER post")engagements on a post / followers × 100Anyone: both numbers are public
By reach ("ERR")engagements on a post / reach of that post × 100The account's owner
By impressions ("ER impressions")engagements on a post / impressions × 100The account's owner
By views ("ER views")engagements on a video / video views × 100Anyone, for Reels that show their plays
Daily ("Daily ER")engagements in a day / followers × 100The account's owner

Two things decide what a quoted rate means. The first is the audience in the lower half of the fraction. The second is what counts as an engagement: Hootsuite defines it as "any action someone takes to interact with your content, including likes, comments, shares, saves". On a public profile only likes and comments are visible, so a rate computed from outside counts those two, and it is lower than the same formula with saves and shares added. Always say which formula and which interactions you used.

You will find no "good engagement rate" figure here. Published benchmarks mix formulas and samples, so a number is only comparable with numbers made the same way. Compare accounts of similar size with one formula.

Where the numbers come from

  • Followers: on the public profile.
  • Likes and comments of recent posts: public, unless the owner hides like counts. Meta's reference says of its own field that like_count "is omitted if the media owner has hidden like counts".
  • Plays of Reels: part of what a public profile shows for its Reels; the profile endpoint below returns them as playCount.
  • Reach, saves and shares: only in the Insights of your own professional account, as the metrics reach, saved, shares and total_interactions. Meta's reference notes that saved_count and shares_count are not accessible through Business Discovery, its endpoint for other people's accounts. The impressions metric is deprecated for media created after July 2, 2024.

Any public account: the rate by followers

The Pipefetch profile endpoint returns the exact follower count and the latest posts with their like and comment counts in one request, which is everything the first formula needs.

Python
import os
import requests

res = requests.get(
    "https://pipefetch.com/v1/instagram/profile",
    params={"username": "nasa"},
    headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
    timeout=90,
)
if res.status_code == 404:
    raise SystemExit("No such account")  # not charged
res.raise_for_status()
profile = res.json()["data"]

followers = profile["followerCount"]
posts = [p for p in profile["latestPosts"] if not p["isPinned"] and p["likeCount"] is not None]
if not followers or not posts:
    raise SystemExit("Not enough public numbers: private account, no posts or hidden like counts")

avg_likes = sum(p["likeCount"] for p in posts) / len(posts)
avg_comments = sum(p["commentCount"] or 0 for p in posts) / len(posts)
rate = (avg_likes + avg_comments) / followers * 100
print(f"{rate:.3f} % by followers, over {len(posts)} posts")
print(profile["engagementRate"], profile["avgLikes"], profile["avgComments"])   # the same, precomputed

The endpoint already returns this figure as engagementRate, next to avgLikes, avgComments, avgPlays and postsPerWeek. The value is a percentage: 0.088 means 0.088 %. Like the code above, it leaves pinned posts out of the average as long as at least three other posts remain, since a pinned post is an old pick that stays on top. In the example answer on the reference page, nasa read on 18 November 2026, that is 104,328,951 followers and, over 14 posts, an average of 90,661 likes and 1,362 comments: 0.088 %.

For Reels the same answer has the plays, so the rate by views is a few more lines:

Python
for reel in posts:
    if reel["isReel"] and reel["playCount"]:
        by_views = (reel["likeCount"] + (reel["commentCount"] or 0)) / reel["playCount"] * 100
        print(reel["url"], f"{by_views:.2f} % by views")

Where it stops: the sample is what Instagram shows without a login, about the 12 latest Reels and the newest grid posts, not the full history. When the owner hides like counts, engagementRate is null and the code above stops; a private account returns no posts at all. Saves, shares and reach are not public, so they are not in the answer. A profile costs 2 credits, an account that does not exist answers 404 and costs nothing, and a new account has 100 free credits and needs no card. Pipefetch is not an official API and is not affiliated with Instagram or Meta.

Business and creator accounts: the official route

Meta's Business Discovery returns the follower count and the like and comment counts of another account's posts, if that account is a business or creator account and you have a professional account, a Meta app and a token of your own. The request joins the two field lists of Meta's examples:

Python
import os
import requests

ME = os.environ["IG_ACCOUNT_ID"]   # the ID of your own professional account
fields = "business_discovery.username(bluebottle){followers_count,media{like_count,comments_count}}"
res = requests.get(
    f"https://graph.facebook.com/v27.0/{ME}",
    params={"fields": fields, "access_token": os.environ["IG_ACCESS_TOKEN"]},
    timeout=30,
)
found = res.json()["business_discovery"]
media = [m for m in found["media"]["data"] if "like_count" in m]   # left out when likes are hidden
if media:
    engagements = sum(m["like_count"] + m.get("comments_count", 0) for m in media)
    print(engagements / len(media) / found["followers_count"] * 100)

This reads the first page of the account's posts; further pages take the after cursor of the answer. Personal accounts are out of its reach. The guide on follower counts lists what the setup takes.

Your own account: the rate by reach

For an account you run, Insights has the numbers nobody else sees. Per post, total_interactions counts likes, saves, comments and shares, and reach is the number of unique users who saw it at least once. On the Unified Login setup the token needs the instagram_basic and instagram_manage_insights permissions.

Python
import os
import requests

media_id = os.environ["IG_MEDIA_ID"]   # the ID of one of your own posts
res = requests.get(
    f"https://graph.facebook.com/v27.0/{media_id}/insights",
    params={"metric": "reach,total_interactions", "access_token": os.environ["IG_ACCESS_TOKEN"]},
    timeout=30,
)
metrics = {m["name"]: m["values"][0]["value"] for m in res.json()["data"]}
print(metrics["total_interactions"] / metrics["reach"] * 100)

Meta notes that the data behind these metrics can be delayed by up to 48 hours, and that reach is an estimate. The reference lists the host and the permission names of the two older setups, which differ.

Which one should you use?

SituationFormulaNumbers from
Vetting or comparing accounts you do not runBy followers, by views for ReelsAn HTTP API such as Pipefetch, or Business Discovery for business and creator accounts
Reporting on your own accountBy reachInsights in the official API
Comparing your account with othersBy followers for all of them, yours includedThe same source for every account

What skews the number

  • Fresh posts. A post from an hour ago is still collecting likes. Use publishedAt to leave out posts younger than a cut-off you choose.
  • Mixed formats. One average over Reels and photos hides the difference between them. isReel lets you compute a rate per format.
  • Paid posts. isPaidPartnership marks posts labelled as paid partnerships, if you want organic posts only.
  • A small sample. A dozen posts with one outlier give a different picture than a quarter of posts. Store each reading and average over time.

To compare the accounts of a niche, the search endpoint returns business and creator accounts named after a keyword with their follower counts, for 1 credit; it asks the advertiser search of Meta's Ad Library and is not the search of the Instagram app. Each account you then read in full is one profile request.

Try it with 100 free credits. No card needed. No login, cookies or proxies. Get an API key or read the docs.

Free tools for this

Every source

YouTube

Websites

TikTok

Facebook

Google

Threads

LinkedIn

App stores

Steam

X

Pinterest

Airbnb

Real estate

Keywords

Job boards

Eventbrite

Shopify stores

Public tenders

All guides