← Skeleton Loader Generator
Your token

Skeleton Loader Generator API

Reading your HTML, drawing the skeleton, the checks and all the code (HTML, CSS, React, the loader script) run free in the browser and need no API. The API is for the one metered step: send the parts of the skeleton and get back, as JSON, a loading plan: which headings and labels can show as real text at once, the order the other parts should arrive, the timings and what a screen reader hears. The page uses only parts it sent, shows kept text exactly as it was, puts back any part the reply left out, keeps timings inside the loading rules and refuses a label with words that are not in the content; do the same with the reply.

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": "plan".

taskWhat it doesReply
planPicks the fixed headings and labels that can show as real text at once (at most 12), orders the other parts into 1 to 5 load steps (never more than 6) with short names, sets the show delay (100 to 1000 ms), minimum time on screen (200 to 1500 ms), long-wait time (5000 to 30000 ms) and list stagger (30 to 50 ms), and writes the screen reader label and the still-loading line from the content's own words, plus up to 3 notes.One JSON object

Input fields

FieldTypeMeaning
taskstring"plan"
titlestringThe component's name, from its first heading or class name.
blocksstringJSON text: a list of {id, kind, text, where, filled_in, size}, ids "b1", "b2", ... in page order. kind is heading h1 to heading h6, text, media, avatar, icon, button, field, check, badge, table or divider; text is up to 80 characters of the part's words ({...} marks a value filled in from data). The page sends at most 80 parts.
clipped_notestringEmpty, or a sentence saying only the first parts were sent.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence): keep, a list of {id, why}; order, a list of {name, ids, why} in load order; timing, {delay_ms, min_ms, long_ms, stagger_ms}; label; long_text; and notes (0 to 3 strings). Before using it, check every id is one you sent and appears once; keep only headings and text that are not filled in from data; put any id that is missing into the last step; keep timings inside the ranges above. If the balance ran low, truncated is true and the object may stop early; the page keeps every step that arrived whole.

Worked example

Input (input.json):

{
  "task": "plan",
  "title": "Recent orders",
  "blocks": "[{\"id\":\"b1\",\"kind\":\"heading h2\",\"text\":\"Recent orders\",\"where\":\"section.card > div > h2\"},{\"id\":\"b2\",\"kind\":\"button\",\"text\":\"View all\",\"where\":\"section.card > div > a.btn\"},{\"id\":\"b3\",\"kind\":\"table\",\"text\":\"OrderCustomerDateStatusTotal\",\"size\":\"5 rows x 5 columns\",\"where\":\"section.card > table.orders\"}]",
  "clipped_note": ""
}

Reply:

{"keep":[{"id":"b1","why":"The section heading is the same for every visitor, so it can show at once."}],"order":[{"name":"Orders table","ids":["b3"],"why":"The table of recent orders is what people came to see."},{"name":"Actions","ids":["b2"],"why":"The View all button is a secondary action that can arrive last."}],"timing":{"delay_ms":150,"min_ms":400,"long_ms":10000,"stagger_ms":40},"label":"Loading recent orders","long_text":"Still loading recent orders...","notes":["The table is 5 rows x 5 columns, so reserve that height to avoid layout shifts when the rows arrive."]}

On the page, this reply shows the heading "Recent orders" as real text at once, loads the orders table first and the View all button second, and sets the screen reader label to "Loading recent orders", with every word taken from the content.

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.
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://skeleton-loader-generator.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":"skeleton-loader-generator"}' | 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": "plan", "title": "Recent orders", "blocks": "[{\"id\":\"b1\",\"kind\":\"heading h2\",\"text\":\"Recent orders\"},{\"id\":\"b2\",\"kind\":\"button\",\"text\":\"View all\"},{\"id\":\"b3\",\"kind\":\"table\",\"size\":\"5 rows x 5 columns\"}]", "clipped_note": ""}
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="skeleton-loader-generator:plan:$(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: keep, order, timing, label, long_text, notes
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: skeleton-loader-generator:plan:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json