← Spring Animation Generator
Your token

Spring Animation Generator API

The spring, the preview, the curve, the check against the spring rules and every copy and download run free in the browser and need no API. The API is for the one metered step: send the current spring's settings and a description of what moves and how it is used, and get back, as JSON, advice for that interaction: keep or change, a summary, what kind of motion it is, the damping ratio and response, the starting speed, what reduce motion shows, the principles at work and what to avoid. The page builds this input for you, checks the reply against the rules and draws the spring.

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

taskWhat it doesReply
adviseReads one spring's kind, damping ratio, response and starting speed, the page's measurements and your description of the interaction, and returns keep or change, a summary, the kind, the spring, the starting speed, what reduce motion shows, principles and things to avoid.One JSON object

Input fields

Every field is a string; page_check holds JSON text. task, kind and description are required.

FieldMeaning
task"advise"
kindWhat moves: ui (a menu or popover that appears), move (dragged or repositioned), sheet (a drawer or bottom sheet), flick (a card a finger throws) or rotate.
damping_ratio1 = no bounce; lower bounces; above 1 drags. 0.25-2.
response_sHow quickly it reaches the target, in seconds. 0.1-1.5.
velocityStarting speed from a finger, in distances per second ("0" = from rest).
page_check{settle_ms, overshoot_percent, bounces, stiffness, damping_coefficient, skill_spring_for_kind, response_range_s, bounce_damping_range, bounce_allowed_for_kind, gesture_driven, verdict, notes}, from the page.
descriptionWhat moves, whether a finger drags or throws it, how often people see it and the product's character (at most 1,200 characters).
clipped_noteEmpty, or a sentence saying the description was cut.

The reply

job.output.output is text holding one JSON object: verdict (keep or change), summary, kind ({id, why}), spring ({damping_ratio, response, why}), velocity ({value, why}), reduced_motion, principles ([{name, how}], names from the skill's principles) and avoid. Before using it, check the values as the page does: a damping ratio of 1.0 for ui and move and 0.7-1.0 for the others (1.0 when no bounce is wanted, never above 1), a response of 0.3-0.4 s, and a starting speed of 0 for ui. Stiffness = (2π / response)² and damping = 4π × damping ratio / response, for mass 1. If the balance ran low, truncated is true and the object may stop early; the page keeps every part that arrived whole.

Worked example

Input (input.json), from the page's "Bottom sheet" example:

{
  "task": "advise",
  "kind": "sheet",
  "damping_ratio": "0.8",
  "response_s": "0.3",
  "velocity": "0",
  "page_check": "{\"settle_ms\":410,\"overshoot_percent\":1.52,\"bounces\":1,\"stiffness\":438.65,\"damping_coefficient\":33.51,\"skill_spring_for_kind\":{\"damping\":0.8,\"response\":0.3},\"response_range_s\":[0.3,0.4],\"bounce_damping_range\":[0.7,0.9],\"bounce_allowed_for_kind\":true,\"gesture_driven\":true,\"verdict\":\"good\",\"notes\":[]}",
  "description": "A share sheet in a photo app on phones. People pull it up and flick it back down many times a day; it should feel quick and physical, like a real card.",
  "clipped_note": ""
}

Reply:

{"verdict":"change","summary":"The share sheet should keep its slightly bouncy, quick spring, since people pull it up and flick it down by hand many times a day and it should feel like a real card. Only the starting speed changes: when a finger lets go, the sheet should carry on at the finger's speed instead of starting from rest.","kind":{"id":"sheet","why":"It is a sheet that slides up and is pulled or flicked back down by a finger."},"spring":{"damping_ratio":0.8,"response":0.3,"why":"A sheet driven by a finger suits a little bounce, and the quick end of the response range fits something used many times a day."},"velocity":{"value":2.0,"why":"A typical flick-down speed is shown here as a stand-in; the real value comes from the finger's release speed divided by the distance still to go."},"reduced_motion":"With reduce motion on, the sheet fades in and out in a short cross-fade with no slide and no overshoot.","principles":[{"name":"Velocity handoff","how":"When the finger lets go of the sheet, it keeps moving at the finger's exact speed so the flick down feels continuous."},{"name":"Interruptibility","how":"A person can grab the sheet mid-slide and reverse it, and the spring picks up from where it is."},{"name":"Direct manipulation","how":"The sheet follows the finger while it is pulled, so it feels like a physical card."},{"name":"Reduced motion","how":"The slide and bounce give way to a plain fade for people who turn motion down."}],"avoid":["Starting the release animation from rest, which makes a flick feel like it stalls","Slowing the response past 0.4 seconds, which makes a daily action feel heavy","Adding more bounce than a card would have"]}

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://spring-animation-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":"spring-animation-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": "advise", "kind": "sheet", "damping_ratio": "0.8", "response_s": "0.3", "velocity": "0", "page_check": "{...}", "description": "A share sheet in a photo app on phones. People pull it up and flick it back down many times a day; it should feel quick and physical, like a real card.", "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="spring-animation-generator:advise:$(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: verdict, summary, kind, spring, velocity, reduced_motion, principles, avoid
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: spring-animation-generator:advise:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json