← API Page Generator
Your token

API Page Generator API

Reading your notes, checking them and writing the API page HTML, the CSS, the head tags with JSON-LD and Markdown all run free in the browser and need no API. The API is for the one metered step: send your API facts (name, style, headline, what it does, who it is for, capabilities, use cases, auth, SDKs, limits, pricing, first-call steps and proof) and get back, as JSON, lines to reword with an optional rewrite of each, a hero headline, and a search title and meta description. The page checks every field and reason, and refuses any rewrite, headline, title or description that adds a number, a name or a claim your notes do not contain.

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

taskWhat it doesReply
refinePoints out lines to reword (field value, capabilities, usecases or auth; why vague, reference_detail, jargon, needs_source or filler) with a rewrite from the API's own facts or an empty one, writes one hero headline, and writes a search title (with the word API) and a meta description.One JSON object

Input fields

All values are strings. task and api are required.

FieldMeaning
task"refine"
productYour product name, or "".
headingYour page heading, or "".
apiJSON text: {name, type, headline, value, audience, capabilities, usecases, auth, sdks, limits, pricing, steps, proof, endpoints}. type is REST, GraphQL, gRPC, WebSocket, Webhooks, SOAP or ""; in capabilities, usecases, limits, pricing and steps items are separated by ; ; sdks is comma-separated; endpoints is a count. Every string may be "".
items_noteEmpty, or a sentence saying what was cut.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence) with three keys: flag, a list of {field, why, text} where text is a suggested rewrite of that line or ""; headline, a string; and seo, {title, description}. Before using it, check that a rewrite, headline, title or description adds no number, name or claim, that the title is at most 60 characters and says API, and that the description is at most 160; the page does all of this and lists what it refused. 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), the README sample on the page:

{
  "task": "refine",
  "product": "Weatherly",
  "heading": "",
  "api": "{\"name\":\"Weatherly API\",\"type\":\"REST\",\"headline\":\"\",\"value\":\"The most powerful weather API for developers. Hyperlocal forecasts, seamlessly delivered. Forecasts, current conditions and severe weather alerts for any latitude and longitude, as JSON.\",\"audience\":\"\",\"capabilities\":\"\",\"usecases\":\"\",\"auth\":\"API key in the appid query parameter.\",\"sdks\":\"\",\"limits\":\"Free: 1,000 calls per day; Pro: 60 calls per minute\",\"pricing\":\"\",\"steps\":\"\",\"proof\":\"\",\"endpoints\":9}",
  "items_note": ""
}

Reply:

{"flag":[{"field":"value","why":"filler","text":"Get forecasts, current conditions and severe weather alerts for any latitude and longitude, as JSON."}],"headline":"Get weather forecasts and alerts for any latitude and longitude","seo":{"title":"Weatherly API: forecasts and severe weather alerts","description":"Get forecasts, current conditions and severe weather alerts for any latitude and longitude as JSON. See how to authenticate and the rate limits."}}

On the page, “most powerful” and “seamlessly” leave the what-it-does line, the hero reads “Get weather forecasts and alerts for any latitude and longitude”, and the page title becomes “Weatherly API: forecasts and severe weather alerts”.

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://api-page-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":"api-page-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": "refine", "product": "Ledgerly", "heading": "", "api": "{...}", "items_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="api-page-generator:refine:$(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: flag, headline, seo
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: api-page-generator:refine:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json