{"openapi":"3.1.0","info":{"title":"RasterFox API","description":"Optimize PNG, JPEG, WebP, AVIF and JPEG XL images, convert between them, and resize them. Send your key as `Authorization: Bearer <key>`. TinyPNG-compatible routes (`POST /shrink`, then the output URL) are also available for existing tinify clients.","contact":{"name":"Trilby Media"},"license":{"name":"LicenseRef-Proprietary","identifier":"LicenseRef-Proprietary"},"version":"0.1.0"},"servers":[{"url":"https://api.rasterfox.app"}],"paths":{"/v1/compress":{"post":{"tags":["Images"],"summary":"Compress an image.","description":"Send the image as the request body, or as a multipart form field named `file`. Without a key\nthis is the free web tool (5 MB each, with an hourly limit per address against scripts); with\none it counts against the key's monthly images. Sending the same image again within 8 hours\nisn't counted. Every caller can convert to another format; resizing needs a paid plan, so the\nfree web tool and the Free plan keep images at their own size.","operationId":"compress","parameters":[{"name":"preset","in":"query","description":"`balanced` (the default), `high_quality`, `small_size` or `adaptive`.","required":false,"schema":{"type":"string"}},{"name":"format","in":"query","description":"`keep` (the default), `png`, `jpeg`, `webp`, `avif` or `jxl`; a comma-separated list\nreturns the smallest; `auto` is the smallest of WebP, JPEG and PNG.","required":false,"schema":{"type":"string"}},{"name":"width","in":"query","description":"Fit inside this width (pixels). Images are never scaled up.","required":false,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"height","in":"query","description":"Fit inside this height (pixels).","required":false,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"fit","in":"query","description":"`fit` (the default) keeps the aspect ratio; `cover` fills `width` × `height` exactly,\ncropping from the centre.","required":false,"schema":{"type":"string"}},{"name":"percent","in":"query","description":"Scale to this percentage (1–100) instead of a box.","required":false,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"metadata","in":"query","description":"`strip` (the default) or `keep` the image's metadata.","required":false,"schema":{"type":"string"}},{"name":"lossless","in":"query","description":"Lossless JPEG XL; a JPEG becomes JPEG XL byte for byte reversibly.","required":false,"schema":{"type":"boolean"}},{"name":"background","in":"query","description":"What transparent pixels become in a JPEG: `#rrggbb`, `white` or `black`. Defaults to\nwhite when JPEG is the only format asked for.","required":false,"schema":{"type":"string"}}],"requestBody":{"description":"The image: PNG, JPEG, WebP, AVIF or JPEG XL.","content":{"application/octet-stream":{"schema":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}}}},"required":true},"responses":{"200":{"description":"The optimized image. Headers: `Image-Width`, `Image-Height`, `X-Input-Size`, `X-Output-Size`, `X-Output-Id`, `Location`, `X-Images-Limit` and `X-Images-Remaining` (when there is a limit) and, with a key, `Compression-Count`.","content":{"image/*":{}}},"201":{"description":"With `Accept: application/json`: where the output is.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompressResult"}}}},"400":{"description":"Bad options, or an image that can't be processed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"401":{"description":"A bad, revoked or expired key, or a licence key sent in place of an API key (see `account_url`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Resizing without a paid plan; see `upgrade_url`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"413":{"description":"Larger than the plan allows.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"415":{"description":"Not an image RasterFox reads.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"The month's images are used up, or the free web tool's hour's.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"503":{"description":"Busy, too many of the caller's images waiting at once, or the key couldn't be checked; see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}},"security":[{},{"bearer":[]}]}},"/v1/output/{id}":{"get":{"tags":["Images"],"summary":"Fetch an output.","description":"Outputs are kept for an hour. One made with a key needs the same key; one from the free web\ntool is fetched by its id alone.","operationId":"output","parameters":[{"name":"id","in":"path","description":"The output id from `X-Output-Id` or the JSON answer.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The image.","content":{"image/*":{}}},"404":{"description":"No such output, or it has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}},"security":[{},{"bearer":[]}]}},"/v1/usage":{"get":{"tags":["Account"],"summary":"Show the key's plan and this month's use.","description":"Without a key, it shows the free web tool's images this hour from the caller's address. The\nstore's account page sends a signed view token in place of a key to show a customer's usage.","operationId":"usage","responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsageBody"}}}},"401":{"description":"A bad key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}},"security":[{},{"bearer":[]}]}}},"components":{"schemas":{"CompressResult":{"type":"object","description":"The JSON answer to `POST /v1/compress` with `Accept: application/json`.","required":["id","input","output","expires_at","usage"],"properties":{"compression_count":{"type":["integer","null"],"format":"int64","description":"The key's images this month; absent for the free web tool.","minimum":0},"expires_at":{"type":"string","description":"When the output is deleted (RFC 3339)."},"id":{"type":"string"},"input":{"$ref":"#/components/schemas/ImageInfo"},"output":{"$ref":"#/components/schemas/OutputInfo"},"usage":{"$ref":"#/components/schemas/Quota","description":"Where the caller stands after this image: the key's month, or the free web tool's hour."}}},"ErrorBody":{"type":"object","description":"The body of every error response.","required":["error","message"],"properties":{"account_url":{"type":["string","null"],"description":"Where to create an API key, when a licence key was sent in place of one."},"error":{"type":"string","description":"A stable name to branch on: Unauthorized, BadRequest, Forbidden, NotFound,\nPayloadTooLarge, UnsupportedMediaType, TooManyRequests, ServiceUnavailable or\nInternalServerError."},"message":{"type":"string","description":"A sentence for people; may be reworded."},"upgrade_url":{"type":["string","null"],"description":"Where to get more images (a spent quota) or a paid plan (a paid feature)."}}},"ImageInfo":{"type":"object","required":["size","type"],"properties":{"size":{"type":"integer","format":"int64","description":"Bytes.","minimum":0},"type":{"type":"string","description":"The MIME type."}}},"OutputInfo":{"type":"object","required":["size","type","width","height","ratio","url"],"properties":{"height":{"type":"integer","format":"int32","minimum":0},"ratio":{"type":"number","format":"double","description":"Output size over input size."},"size":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string"},"url":{"type":"string","description":"Where to fetch it while it's kept."},"width":{"type":"integer","format":"int32","minimum":0}}},"Quota":{"type":"object","description":"Where a caller stands against its limit: a key's images this month (and today, on a plan\nwith a daily limit), or the free web tool's images this hour from this address.","required":["period","used","resets_at"],"properties":{"limit":{"type":["integer","null"],"format":"int64","description":"Images allowed in the period; null for unlimited.","minimum":0},"period":{"type":"string","description":"`month` for a key, `hour` for the free web tool."},"remaining":{"type":["integer","null"],"format":"int64","description":"Images left; null for unlimited.","minimum":0},"resets_at":{"type":"string","description":"When the count starts again (RFC 3339)."},"today":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/Today","description":"A key whose plan also has a daily limit: today's count (UTC)."}]},"used":{"type":"integer","format":"int64","description":"Images counted so far.","minimum":0}}},"Today":{"type":"object","description":"Today's count for a key whose plan has a daily limit.","required":["limit","used","remaining","resets_at"],"properties":{"limit":{"type":"integer","format":"int64","minimum":0},"remaining":{"type":"integer","format":"int64","minimum":0},"resets_at":{"type":"string","description":"Midnight UTC (RFC 3339)."},"used":{"type":"integer","format":"int64","minimum":0}}},"UsageBody":{"type":"object","description":"A key's plan and use this month, or without a key, the free web tool's use this hour from this\naddress.","required":["period","used","resets_at","max_file_mb","concurrent","resize","resize_and_convert"],"properties":{"concurrent":{"type":"integer","format":"int32","description":"Images that may be in progress at once; more wait their turn.","minimum":0},"limit":{"type":["integer","null"],"format":"int64","description":"Images allowed in the period; null for unlimited.","minimum":0},"max_file_mb":{"type":"integer","format":"int64","description":"The largest file accepted, in MB.","minimum":0},"month":{"type":["string","null"],"description":"For a key: the month counted, `YYYY-MM` (UTC)."},"monthly_images":{"type":["integer","null"],"format":"int64","description":"For a key: images a month (null for unlimited), the same as `limit`.","minimum":0},"period":{"type":"string","description":"`month` for a key, `hour` for the free web tool."},"plan":{"type":["string","null"],"description":"The plan's name, when the store gives one; `web` for the free web tool."},"remaining":{"type":["integer","null"],"format":"int64","description":"Images left; null for unlimited.","minimum":0},"resets_at":{"type":"string","description":"When the count starts again (RFC 3339)."},"resize":{"type":"boolean","description":"Whether resizing is allowed (paid plans). Converting is allowed on every plan."},"resize_and_convert":{"type":"boolean","description":"The same as `resize`, kept for older clients (converting no longer needs a paid plan)."},"today":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/Today","description":"For a key whose plan also has a daily limit: today's count (UTC)."}]},"used":{"type":"integer","format":"int64","description":"Images counted so far.","minimum":0}}}},"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"Images","description":"Compress, convert and resize"},{"name":"Account","description":"Your plan and usage"}]}