← Reduced Motion Generator
Your token

Reduced Motion Generator API

Reading your CSS, measuring and rating every animation and writing the prefers-reduced-motion block all run free in the browser and need no API. The API is for the one metered step: send the items that need a decision and get back, as JSON, a role for each (what the animation is for) and an action (fade or remove). The page refuses a role that does not fit the kind of motion and an action the item or role does not allow, and keeps its own choice for anything missing; 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
planNames the role of each animation (loader, progress, entrance, exit, feedback, state, attention, decorative, ticker, parallax, scroll) and picks fade or remove from the actions the item allows, by the accessible-motion rules for that role.One JSON object

Input fields

FieldTypeMeaning
taskstring"plan"
itemsstringJSON text: a list of {id, kind, selector, keyframes, motion, duration_ms, repeats, trigger, fades, rating, allowed}, ids "m1", "m2", ... kind is animation, transition, smooth-scroll, parallax or scroll-animation; rating is caution or avoid; allowed lists fade and/or remove. The page sends only items that are not safe and not already handled, at most 40.
clipped_notestringEmpty, or a sentence saying only the first items were sent.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence): {"items": [{"id", "role", "action"}]}, one entry per item sent. Before using it, check every id is one you sent and appears once, the role fits the kind (scroll only for smooth-scroll, parallax only and always for parallax and scroll-animation, entrance/exit only for animations that do not repeat forever) and the action is in that item's allowed list and allowed for the role (attention, decorative, ticker, parallax and scroll are only remove). If the balance ran low, truncated is true and the object may stop early; the page keeps every entry that arrived whole.

Worked example

Input (input.json, from the Loading spinners example):

{
  "task": "plan",
  "items": "[{\"id\":\"m1\",\"kind\":\"animation\",\"selector\":\".spinner\",\"keyframes\":\"spin\",\"motion\":\"spins 360°, 800 ms, forever\",\"duration_ms\":800,\"repeats\":\"forever\",\"trigger\":\"page load\",\"fades\":false,\"rating\":\"avoid\",\"allowed\":[\"fade\",\"remove\"]},{\"id\":\"m2\",\"kind\":\"animation\",\"selector\":\".dots span\",\"keyframes\":\"bounce\",\"motion\":\"slides 12px, 1.2 s, forever\",\"duration_ms\":1200,\"repeats\":\"forever\",\"trigger\":\"page load\",\"fades\":false,\"rating\":\"avoid\",\"allowed\":[\"fade\",\"remove\"]},{\"id\":\"m3\",\"kind\":\"animation\",\"selector\":\".skeleton\",\"keyframes\":\"shimmer\",\"motion\":\"moves its background, 1.5 s, forever\",\"duration_ms\":1500,\"repeats\":\"forever\",\"trigger\":\"page load\",\"fades\":false,\"rating\":\"avoid\",\"allowed\":[\"fade\",\"remove\"]},{\"id\":\"m4\",\"kind\":\"animation\",\"selector\":\".progress-bar.indeterminate::after\",\"keyframes\":\"indeterminate\",\"motion\":\"moves 300% of its size or the screen, 1.4 s, forever\",\"duration_ms\":1400,\"repeats\":\"forever\",\"trigger\":\"page load\",\"fades\":false,\"rating\":\"avoid\",\"allowed\":[\"fade\",\"remove\"]},{\"id\":\"m5\",\"kind\":\"transition\",\"selector\":\".progress-bar .fill\",\"motion\":\"changes size, 400 ms, when a value changes\",\"duration_ms\":400,\"trigger\":\"value change\",\"fades\":false,\"rating\":\"caution\",\"allowed\":[\"remove\"]},{\"id\":\"m6\",\"kind\":\"animation\",\"selector\":\".status-dot\",\"keyframes\":\"breathe\",\"motion\":\"fades, 2 s, forever\",\"duration_ms\":2000,\"repeats\":\"forever\",\"trigger\":\"page load\",\"fades\":true,\"rating\":\"caution\",\"allowed\":[\"fade\",\"remove\"]}]",
  "clipped_note": ""
}

Reply:

{"items": [
  {"id": "m1", "role": "loader", "action": "fade"},
  {"id": "m2", "role": "loader", "action": "fade"},
  {"id": "m3", "role": "loader", "action": "fade"},
  {"id": "m4", "role": "progress", "action": "fade"},
  {"id": "m5", "role": "progress", "action": "remove"},
  {"id": "m6", "role": "attention", "action": "remove"}
]}

On the page, this reply turns the spinner, bouncing dots and shimmer into a slow opacity pulse, the indeterminate bar too, makes the progress fill jump to each value, and stops the status dot.

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://reduced-motion-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":"reduced-motion-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", "items": "[{\"id\":\"m1\",\"kind\":\"animation\",\"selector\":\".spinner\",\"keyframes\":\"spin\",\"motion\":\"spins 360 deg, 800 ms, forever\",\"duration_ms\":800,\"repeats\":\"forever\",\"trigger\":\"page load\",\"fades\":false,\"rating\":\"avoid\",\"allowed\":[\"fade\",\"remove\"]}]", "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="reduced-motion-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: {items: [{id, role, action}]}
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: reduced-motion-generator:plan:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json