← Engagement Rate Calculator
Your token

Engagement Rate Calculator API

Reading an export, every post's engagement rate, the grade, the splits by format, day, time, length and hashtag, and every download run free in the browser and need no API. The API is for the one metered step: send your posts' text, format and rate, and get back, as JSON ids, the kind of each post (story, how-to, promotion...), the kinds that lift and drag your rate, and up to three posts worth repeating. The page builds this input for you and checks every claim against its own numbers before showing it.

Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.

The task field

This app has one task. Always send "task": "read".

taskWhat it doesReply
readReads each post's text, gives it one to three kinds, and finds which kinds lift or drag the rate and which posts to repeat.One JSON object

Input fields

Every field is a string; facts holds JSON text. Both are required.

FieldMeaning
task"read"
factsJSON object: platform, measure (what rate means, such as "engagement rate in percent"), posts (each {id, text, format, rate}, ids P1, P2...; at most 60 posts and 280 characters of text each) and traits (the 14 kind ids with their meaning: story, behind, how_to, list, opinion, question, data, news, promo, event, milestone, humor, hiring, ugc).

The reply

job.output.output is text holding one JSON object: tags (post id to one to three kind ids), lift (up to three kinds, on at least 2 posts each, whose median rate is above the median of all posts), drag (up to three kinds with a median below it) and next (up to three {trait, like}: a lifting kind and a post of that kind, at or above the median, to repeat). Before using it, check it as the page does: every post is tagged with known kinds; work out each kind's median from your own rates and drop any lift or drag claim the numbers do not support; drop any pick whose post lacks the kind or is below the median. If the balance ran low, truncated is true and the object may stop early; the page keeps what arrived whole.

Worked example

Input (input.json), from the page's "Instagram bakery" example with 8,400 followers:

{
  "task": "read",
  "facts": "{\"platform\":\"Instagram\",\"measure\":\"engagement rate in percent\",\"posts\":[{\"id\":\"P1\",\"text\":\"5am. Ovens on. This is what the first hour looks like before we open the doors - our head baker Lena has done this every morning for 11 years. #bakerylife #behindthescenes #sourdough\",\"format\":\"Reel\",\"rate\":8.548},{\"id\":\"P2\",\"text\":\"This week only: 20% off every loaf when you order online before Thursday. Link in bio. #sourdough #bakery #deal\",\"format\":\"Photo\",\"rate\":1.167},{\"id\":\"P3\",\"text\":\"How to keep sourdough fresh for 4 days: 1) cut side down on the board 2) linen bag, never plastic 3) freeze slices, toast from frozen 4) revive a stale loaf with 5 minutes at 180C. Save this for later. #sourdough #breadtips\",\"format\":\"Carousel\",\"rate\":5.19},{\"id\":\"P4\",\"text\":\"Cardamom bun or cinnamon knot - which one are you picking for Saturday? Tell us below and we will bake extra of the winner. #bakery #weekend\",\"format\":\"Photo\",\"rate\":4.131},{\"id\":\"P5\",\"text\":\"Shaping 240 croissants by hand, sped up 8x. Watch the lamination at 0:12. #behindthescenes #croissant #bakerylife\",\"format\":\"Reel\",\"rate\":6},{\"id\":\"P6\",\"text\":\"Gift cards are back for the holidays. Any amount, delivered by email. Order in the link in bio. #giftideas #bakery\",\"format\":\"Photo\",\"rate\":1.095},{\"id\":\"P7\",\"text\":\"Three years ago today we opened with one oven and a borrowed mixer. Thank you to every single one of you who came through that door. #thankyou #smallbusiness\",\"format\":\"Photo\",\"rate\":3.298},{\"id\":\"P8\",\"text\":\"The bread that almost closed us: in our first winter the starter died and we had nothing to sell for a week. Here is what we changed. #smallbusiness #sourdough\",\"format\":\"Reel\",\"rate\":7.274},{\"id\":\"P9\",\"text\":\"New hours from Monday: open 7am to 3pm, closed Tuesdays. #bakery #newhours\",\"format\":\"Photo\",\"rate\":1.536},{\"id\":\"P10\",\"text\":\"Our focaccia recipe, scaled for a home oven: 500g flour, 400g water, 10g salt, 3g yeast, lots of olive oil. Full steps in the slides. #focaccia #recipe #breadtips\",\"format\":\"Carousel\",\"rate\":5.56},{\"id\":\"P11\",\"text\":\"Bread class Sunday 14 December, 10am to 1pm, 8 seats left. Booking in bio. #breadclass #sourdough\",\"format\":\"Photo\",\"rate\":2.083},{\"id\":\"P12\",\"text\":\"Meet Omar, who starts at 4am and has never once been late. A day with our morning crew. #behindthescenes #bakerylife\",\"format\":\"Reel\",\"rate\":8.214},{\"id\":\"P13\",\"text\":\"Pre-order your Christmas stollen now - limited batch of 150. #christmas #bakery #preorder\",\"format\":\"Photo\",\"rate\":1.179},{\"id\":\"P14\",\"text\":\"We are testing three new rye breads. Swipe and tell us which one should stay on the menu. #rye #bakery\",\"format\":\"Carousel\",\"rate\":6.714},{\"id\":\"P15\",\"text\":\"Repost from @mia.eats who turned our day-old loaf into the best bread pudding we have ever seen. #bakery #nowaste\",\"format\":\"Photo\",\"rate\":2.381},{\"id\":\"P16\",\"text\":\"Why we still mill part of our own flour - a 40 second story from the mill in the back room. #sourdough #bakerylife #behindthescenes\",\"format\":\"Reel\",\"rate\":9.857},{\"id\":\"P17\",\"text\":\"We now deliver within 5 km on weekends. #delivery #bakery\",\"format\":\"Photo\",\"rate\":1.595},{\"id\":\"P18\",\"text\":\"Things customers say at 7:01am, a short compilation. #bakerylife #funny\",\"format\":\"Reel\",\"rate\":5.726}],\"traits\":{\"story\":\"Story: a personal story or something that happened\",\"behind\":\"Behind the scenes: the team, the process, a day at work\",\"how_to\":\"How-to: tips, steps, a recipe or a tutorial\",\"list\":\"List: a numbered list, checklist or template\",\"opinion\":\"Opinion: a take or argument to agree or disagree with\",\"question\":\"Question: asks the audience to answer or vote\",\"data\":\"Data: numbers, research or results\",\"news\":\"News: a launch, update, new hours or announcement\",\"promo\":\"Promotion: a sale, offer, price or link to buy or sign up\",\"event\":\"Event: a class, webinar, live stream or meet-up\",\"milestone\":\"Milestone: an anniversary, a number reached, thanks\",\"humor\":\"Humor: a joke, meme or funny moment\",\"hiring\":\"Hiring: a job opening\",\"ugc\":\"Someone else's post: a customer post, review or reshare\"}}"
}

Reply:

{"tags":{"P1":["behind"],"P2":["promo"],"P3":["how_to","list"],"P4":["question"],"P5":["behind"],"P6":["promo"],"P7":["milestone"],"P8":["story"],"P9":["news"],"P10":["how_to"],"P11":["event","promo"],"P12":["behind"],"P13":["promo"],"P14":["question"],"P15":["ugc"],"P16":["behind"],"P17":["news"],"P18":["humor"]},"lift":["behind","question","how_to"],"drag":["promo","news"],"next":[{"trait":"behind","like":"P16"},{"trait":"question","like":"P14"},{"trait":"how_to","like":"P10"}]}

Errors

HTTPWhat to do
401The token is missing, expired or a guest token on a run. Get a personal token on the token page.
402The balance is below what the run reserves. Top up at skillsafe.ai/account/billing.
400The body is not a JSON object of the fields above, or a required field is missing or empty.
429Wait and retry with the same Idempotency-Key.

Step 1 — a tiny client helper

One function that sends JSON and unwraps the {data, error} envelope.

BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here"   # from https://engagement-rate-calculator.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
  curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
    ${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}

Step 2 — a token

A guest token is enough for /me and /estimate. A run is metered, so it needs your personal token: sign in on the token page and copy it.

# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"engagement-rate-calculator"}' | jq -r '.data.token')

Step 3 — who am I, and my balance

subject_type is guest or user; credits is the balance (1 credit = $0.0001).

api GET /me | jq '.data | {subject_type, credits}' 

Step 4 — price a run for free

/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.

# input.json: the run input object - {"task": "read", "facts": "{\"platform\":\"Instagram\",\"measure\":\"engagement rate in percent\",\"posts\":[{\"id\":\"P1\",\"text\":\"5am. Ovens on. This is what the first hour looks like before we open the doors - our head baker Lena has done this every morning for 11 years. #bakerylife #behindthescenes #sourdough\",\"format\":\"Reel\",\"rate\":8.548},{\"id\":\"P2\",\"text\":\"This week only: 20% off every loaf when you order online before Thursday. Link in bio. #sourdough #bakery #deal\",\"format\":\"Photo\",\"rate\":1.167},{\"id\":\"P3\",\"text\":\"How to keep sourdough fresh for 4 days: 1) cut side down on the board 2) linen bag, never plastic 3) freeze slices, toast from frozen 4) revive a stale loaf with 5 minutes at 180C. Save this for later. #sourdough #breadtips\",\"format\":\"Carousel\",\"rate\":5.19},{\"id\":\"P4\",\"text\":\"Cardamom bun or cinnamon knot - which one are you picking for Saturday? Tell us below and we will bake extra of the winner. #bakery #weekend\",\"format\":\"Photo\",\"rate\":4.131},{\"id\":\"P5\",\"text\":\"Shaping 240 croissants by hand, sped up 8x. Watch the lamination at 0:12. #behindthescenes #croissant #bakerylife\",\"format\":\"Reel\",\"rate\":6},{\"id\":\"P6\",\"text\":\"Gift cards are back for the holidays. Any amount, delivered by email. Order in the link in bio. #giftideas #bakery\",\"format\":\"Photo\",\"rate\":1.095},{\"id\":\"P7\",\"text\":\"Three years ago today we opened with one oven and a borrowed mixer. Thank you to every single one of you who came through that door. #thankyou #smallbusiness\",\"format\":\"Photo\",\"rate\":3.298},{\"id\":\"P8\",\"text\":\"The bread that almost closed us: in our first winter the starter died and we had nothing to sell for a week. Here is what we changed. #smallbusiness #sourdough\",\"format\":\"Reel\",\"rate\":7.274},{\"id\":\"P9\",\"text\":\"New hours from Monday: open 7am to 3pm, closed Tuesdays. #bakery #newhours\",\"format\":\"Photo\",\"rate\":1.536},{\"id\":\"P10\",\"text\":\"Our focaccia recipe, scaled for a home oven: 500g flour, 400g water, 10g salt, 3g yeast, lots of olive oil. Full steps in the slides. #focaccia #recipe #breadtips\",\"format\":\"Carousel\",\"rate\":5.56},{\"id\":\"P11\",\"text\":\"Bread class Sunday 14 December, 10am to 1pm, 8 seats left. Booking in bio. #breadclass #sourdough\",\"format\":\"Photo\",\"rate\":2.083},{\"id\":\"P12\",\"text\":\"Meet Omar, who starts at 4am and has never once been late. A day with our morning crew. #behindthescenes #bakerylife\",\"format\":\"Reel\",\"rate\":8.214},{\"id\":\"P13\",\"text\":\"Pre-order your Christmas stollen now - limited batch of 150. #christmas #bakery #preorder\",\"format\":\"Photo\",\"rate\":1.179},{\"id\":\"P14\",\"text\":\"We are testing three new rye breads. Swipe and tell us which one should stay on the menu. #rye #bakery\",\"format\":\"Carousel\",\"rate\":6.714},{\"id\":\"P15\",\"text\":\"Repost from @mia.eats who turned our day-old loaf into the best bread pudding we have ever seen. #bakery #nowaste\",\"format\":\"Photo\",\"rate\":2.381},{\"id\":\"P16\",\"text\":\"Why we still mill part of our own flour - a 40 second story from the mill in the back room. #sourdough #bakerylife #behindthescenes\",\"format\":\"Reel\",\"rate\":9.857},{\"id\":\"P17\",\"text\":\"We now deliver within 5 km on weekends. #delivery #bakery\",\"format\":\"Photo\",\"rate\":1.595},{\"id\":\"P18\",\"text\":\"Things customers say at 7:01am, a short compilation. #bakerylife #funny\",\"format\":\"Reel\",\"rate\":5.726}],\"traits\":{\"story\":\"Story: a personal story or something that happened\",\"behind\":\"Behind the scenes: the team, the process, a day at work\",\"how_to\":\"How-to: tips, steps, a recipe or a tutorial\",\"list\":\"List: a numbered list, checklist or template\",\"opinion\":\"Opinion: a take or argument to agree or disagree with\",\"question\":\"Question: asks the audience to answer or vote\",\"data\":\"Data: numbers, research or results\",\"news\":\"News: a launch, update, new hours or announcement\",\"promo\":\"Promotion: a sale, offer, price or link to buy or sign up\",\"event\":\"Event: a class, webinar, live stream or meet-up\",\"milestone\":\"Milestone: an anniversary, a number reached, thanks\",\"humor\":\"Humor: a joke, meme or funny moment\",\"hiring\":\"Hiring: a job opening\",\"ugc\":\"Someone else's post: a customer post, review or reshare\"}}"}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' 

Step 5 — run it and wait for the job

Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.

KEY="engagement-rate-calculator:read:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
  J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
  case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json   # one JSON object: tags, lift, drag, next
echo "$J" | jq '.data | {charged_credits, truncated}' 

Step 6 — or stream it

/run-stream sends Server-Sent Events while the job runs and the finished job at the end.

# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: engagement-rate-calculator:read:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json