Skip to content
moxon home

6.3.0

API

API v6.3.0 — New /badge endpoint: a standalone SVG badge, in v6.

Endpoints

  • New GET /badge in v6: it draws a standalone SVG badge, a pill that works in a plain <img>. Only label is required. start and end give a gradient, ink the color of the text and of the icons and border an outline. icon and trail take the name of one of 106 bundled icons (105 from Lucide, plus discord). message adds a second part, in the manner of shields.io, with its own messageStart, messageEnd and messageInk. size goes from xs to lg (16 to 28 px), radius, angle and lift shape the badge, and font and weight set the text.
  • The texts are bounded and checked: label and message hold 64 characters at most and refuse control, zero-width and bidirectional formatting characters, and lift, radius and angle take a plain decimal with at most two decimals. Any invalid value is refused with a 400 and a message that names it. The image is sent with Cache-Control: public, max-age=86400 and Content-Security-Policy: default-src 'none'.
  • Nothing else changes: v4 and v5 do not have /badge and answer 404 with Endpoint not available in v4. or Endpoint not available in v5., and no other endpoint is touched.

Package

  • New badge export, available from @moxon/api/v6 and from the package root, which resolves to it: it takes the options of the query string, with lift, radius and angle as numbers, and returns { contentType, body }, body being the SVG. It throws an Error with the message of the HTTP 400. @moxon/api/v4 and @moxon/api/v5 do not export it.
  • The icons come from Lucide, whose ISC licence and the MIT licence of the portions derived from Feather are kept in the source code.

Documentation

  • The new Badge page documents the parameters in three tables (text and icons, colors, shape and font), the bundled icons by family, the two-part badge, the response and its headers, the use from Node.js and every error message, with a Try panel that shows the badge it draws.
  • The catalogue now lists 50 endpoints, 8 of them in Images.