← Sprite Sheet Maker
Your token

Sprite Sheet Maker API

Reading the frames, trimming, packing, the PNG, the atlas JSON and the Phaser code all run free in the browser and need no API. The API is for the one metered step: send the frame names and sizes, the page's grouping and a description of how the sprite moves, and get back, as JSON, the named animations (which frames, frame rate, looping, there-and-back) and which one-off animation hands over to which. The page checks every frame name before using the plan.

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
planReads frame names, sizes, groups and the description and returns named animations, hand-overs and up to four notes. It never sees the images and never writes code.One JSON object

Input fields

All values are strings.

FieldMeaning
task"plan"
sheetThe texture key, e.g. hero.
layoutpacked (atlas JSON) or grid (equal cells).
framesJSON text: a list of {name, w, h} in the order the frames were supplied (at most 300).
groupsJSON text: a list of {group, count, first, last}; a group is the frame names without their trailing number.
descriptionHow the sprite moves, in plain words; may name frame ranges ("frames 1-4 are idle").
frames_noteEmpty, or a sentence saying what was cut.

The reply

job.output.output is text holding one JSON object with three keys: animations (a list of {key, group | frames, frameRate, repeat, yoyo, reason}; repeat is -1 to loop or 0-20), chains ({after, play}: when after ends, play play) and notes (0 to 4 strings). Before using an animation, check that every frame name exists in your sheet; the page does, and leaves out anything that does not match. Each animation maps directly onto this.anims.create({key, frames, frameRate, repeat, yoyo}) in Phaser. If the balance ran low, truncated is true and the object may stop early; the page keeps every animation that arrived whole.

Worked example

Input (input.json), the Walking hero sample on the page (11 frames):

{
  "task": "plan",
  "sheet": "hero",
  "layout": "packed",
  "frames": "[{\"name\":\"hero_idle_01\",\"w\":48,\"h\":64},{\"name\":\"hero_idle_02\",\"w\":48,\"h\":64},{\"name\":\"hero_walk_01\",\"w\":48,\"h\":64},{\"name\":\"hero_walk_02\",\"w\":48,\"h\":64},{\"name\":\"hero_walk_03\",\"w\":48,\"h\":64},{\"name\":\"hero_walk_04\",\"w\":48,\"h\":64},{\"name\":\"hero_walk_05\",\"w\":48,\"h\":64},{\"name\":\"hero_walk_06\",\"w\":48,\"h\":64},{\"name\":\"hero_attack_01\",\"w\":48,\"h\":64},{\"name\":\"hero_attack_02\",\"w\":48,\"h\":64},{\"name\":\"hero_attack_03\",\"w\":48,\"h\":64}]",
  "groups": "[{\"group\":\"hero_idle\",\"count\":2,\"first\":\"hero_idle_01\",\"last\":\"hero_idle_02\"},{\"group\":\"hero_walk\",\"count\":6,\"first\":\"hero_walk_01\",\"last\":\"hero_walk_06\"},{\"group\":\"hero_attack\",\"count\":3,\"first\":\"hero_attack_01\",\"last\":\"hero_attack_03\"}]",
  "description": "a little hero: breathing idle, a walk cycle, and a sword swing that goes back to idle",
  "frames_note": ""
}

Reply:

{"animations":[{"key":"idle","group":"hero_idle","frameRate":4,"repeat":-1,"yoyo":false,"reason":"A slow loop over two frames reads as gentle breathing."},{"key":"walk","group":"hero_walk","frameRate":10,"repeat":-1,"yoyo":false,"reason":"Six frames at a steady walking pace, looping as a cycle."},{"key":"attack","group":"hero_attack","frameRate":14,"repeat":0,"yoyo":false,"reason":"A quick one-off swing that plays once."}],"chains":[{"after":"attack","play":"idle"}],"notes":["The idle has only two frames, so the breathing will look stepped; add a few more for a smoother cycle."]}

On the page, every frame in this plan exists: idle loops slowly, walk loops at 10 fps, and attack plays once and hands back to idle, which becomes an animationcomplete-attack handler in the Phaser code.

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://sprite-sheet-maker.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":"sprite-sheet-maker"}' | 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", "sheet": "hero", "layout": "packed", "frames": "[...]", "groups": "[...]", "description": "a walk cycle and a sword swing", "frames_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="sprite-sheet-maker: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: animations, chains, 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: sprite-sheet-maker:plan:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json