If you build anything around creators, such as a CRM, a vetting tool or a dashboard, you need profile data: who the account is, how big it is and how its content performs. This tutorial shows how to get all of it from a username with the IGramAPI Profile API, including a working engagement-rate calculation.
What you need
- An IGramAPI key. The free plan includes 100 credits a month, which is plenty for this tutorial.
- Python 3, Node.js 18+ or just cURL.
Create the key in the dashboard and keep it in an environment variable:
export IGRAMAPI_KEY="igk_your_key_here"
Step 1: fetch a profile
curl "https://api.igramapi.com/v1/profiles/example_creator" \
-H "Authorization: Bearer $IGRAMAPI_KEY"
The response contains a profile object:
{
"profile": {
"user_id": "1234567890",
"username": "example_creator",
"full_name": "Example Creator",
"biography": "Photographer. Travel and street stories.",
"is_verified": true,
"is_private": false,
"followers": 182400,
"following": 311,
"posts_count": 742
},
"cached": false
}
Counts are real integers, so you can sort and chart them directly. Keep the user_id: usernames can change, but the id does not.
Step 2: do it in code
Python
import os
import requests
BASE = "https://api.igramapi.com"
HEADERS = {"Authorization": f"Bearer {os.environ['IGRAMAPI_KEY']}"}
def get(path, **params):
r = requests.get(BASE + path, headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
return r.json()
profile = get("/v1/profiles/example_creator")["profile"]
print(profile["username"], profile["followers"])
Node.js
const BASE = "https://api.igramapi.com";
const headers = { Authorization: `Bearer ${process.env.IGRAMAPI_KEY}` };
async function get(path, params = {}) {
const url = new URL(BASE + path);
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
const response = await fetch(url, { headers });
if (!response.ok) throw new Error((await response.json()).error.message);
return response.json();
}
const { profile } = await get("/v1/profiles/example_creator");
console.log(profile.username, profile.followers);
Step 3: add recent posts
The Posts API returns the latest posts with likes, comments and timestamps:
posts = get("/v1/profiles/example_creator/posts")["items"]
Step 4: compute engagement rate
Engagement rate is usually the average of likes plus comments per post, divided by followers:
def engagement_rate(profile, posts):
usable = [p for p in posts if not p["like_and_view_counts_hidden"]]
if not usable or not profile["followers"]:
return None
average = sum(p["like_count"] + p["comment_count"] for p in usable) / len(usable)
return round(average / profile["followers"] * 100, 2)
print(engagement_rate(profile, posts), "%")
Notice like_and_view_counts_hidden. When an account hides likes, the count would be zero and drag the average down, so the API flags those posts and you leave them out.
Step 5: handle errors
Every error has the same format and a stable code:
r = requests.get(BASE + "/v1/profiles/does_not_exist_12345", headers=HEADERS, timeout=30)
if r.status_code == 404:
print(r.json()["error"]["code"]) # profile_not_found
Failed requests are not charged. See error handling for the list of codes and how to retry correctly.
Step 6: let people search by name
Most users do not know the exact username. Put the Search API in front of the profile lookup, show matches with their picture and verification badge, then fetch the one they choose.
Costs and good practice
- A profile lookup is 1 credit, and a page of posts is 1 credit, so one report is 2 credits.
- Responses may be served from a short cache. The
cachedfield tells you, so store a timestamp when you take a snapshot. - Call the API from your backend, never from the browser, to keep the key secret.
- Read
X-Credits-RemainingandX-RateLimit-Remainingto schedule your jobs. The credits guide explains both.
Next steps
Track growth by saving a snapshot every day, use the Reels API to find top-performing content, and read how influencer platforms put these pieces together.