Docs · API

API quickstart

Send a few numbers to our server, and the answer is a font file. Nothing to install: any language that can make an HTTP request will do.

The hosted API runs the engine on Typomat's servers. It suits a server of yours that makes images, video or PDFs, or any product where installing an SDK isn't worth it. It makes TrueType, OpenType, WOFF and WOFF2 files, with all 271 characters.

1. Make a key

In your account, open the API part and make a key. It's shown once, when you make it, so copy it then. Anyone who has it can spend your plan, so it stays on your server, never in a web page or an app. Put it in your environment for the next step:

Terminal
export TYPOMAT_KEY=tm_live_...

2. Ask for a font

Send the key as a bearer token, and a JSON body with a name and a few parameters: numbers that set things like weight and contrast. Anything you leave out stays at its default. See them all.

curl https://engine.typomat.app/api/v1/fonts \
  -H "Authorization: Bearer $TYPOMAT_KEY" \
  -H "Content-Type: application/json" \
  -o acme-display.ttf \
  -d '{
    "name": "Acme Display",
    "parameters": {
      "weight": 118,
      "contrast": 0.92,
      "serif": 0.5
    }
  }'

What you should see: a new file, acme-display.ttf, about 54 KB. Open it with your computer's font viewer to see the letters. The response's X-Typomat-Compile-Ms header says how long the engine took.

3. If it goes wrong

An error comes back as JSON instead of a font, with a code to check and a message to read:

JSON
{ "error": { "code": "invalid_key", "message": "..." } }

missing_key or invalid_key (status 401) means the key didn't arrive, or isn't right: check TYPOMAT_KEY. invalid_request (400) usually means a parameter's name is misspelled. The API reference lists them all.

4. Make it smaller

A font holds all 271 characters unless you pick. For a few words on an image, ask for only the characters you need, and the file is a fraction of the size. Each request counts as one font against your plan, whatever it holds.

curl https://engine.typomat.app/api/v1/fonts \
  -H "Authorization: Bearer $TYPOMAT_KEY" \
  -H "Content-Type: application/json" \
  -o acme.ttf \
  -d '{
    "name": "Acme Display",
    "parameters": {
      "weight": 118,
      "contrast": 0.92
    },
    "characters": "Acme"
  }'

Nothing is stored on our side. The same numbers always make the same letters, so keep the numbers, and the file for as long as they don't change, and ask again when they do.