You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added support for SVG export to compile endpoints. Using /compile?format=svg outputs an SVG instead of the default PDF. One can also set which pages to export using an additional parameter pages, like in the Typst CLI.
Added pages query parameter support for PDFs as well.
Added new endpoint POST /admin/fonts to add new fonts to the database using multipart/form-data.
Created a static website /add-fonts that asks for ADMIN_TOKEN as input, and allows uploading font files. It internally calls POST /admin/fonts. The website is just for ease of use when adding new fonts to the font database.
Changed
Improved logs for when CACHE_ALL_133_TYPST_FONTS is set, added a timeout for each download and made the FontState update every 20 downloaded fonts.
Added env var CACHE_ALL_133_TYPST_FONTS to download, extract, and cache the 133 fonts from the Typst web app, from a curated mirror I created, which is hosted on Mapaor/typst-fonts-mirror.
Also added the equivalent new endpoint POST /admin/fonts/sync to manually trigger a background sync of the font mirror repository. The idea is once again to run the server at startup with the env variable, and then use this endpoint to fetch updates.
Added a new Docker named volume typst-fonts in docker-compose.yml to persist mirrored fonts.
Fixed API hanging on startup if CACHE_ALL_PACKAGES was set.
Now if ADMIN_TOKEN but AUTH_TOKEN isn't, /compile and /compile/source remain publicly accessible. This is better than everything under ADMIN_TOKEN (old logic). Now you can make your API public while still protecting the admin/ routes.
Fixed docker-publish workflow to properly update the release notes (internal detail).
Implemented cargo-dist to automatically generate and publish pre-compiled standalone binaries for Windows, macOS, and Linux across x86_64 and aarch64 architectures.
Released binaries are now packaged with assets/fonts and a .env.example file.
I've modified the GH Actions workflow to build both AMD and ARM images.
Note: QEMU is used to emulate ARM during the build process, the VM runs only during the build in GH Actions servers, the final ARM image runs natively and can be used by anyone with a raspberry pi or apple M series laptop at full-speed.
Endpoint Moved: The POST /fonts/refresh endpoint has been moved to POST /admin/fonts/refresh.
New Features
New endpoints to manage Typst packages cache:
GET /admin/packages: List cached packages and their total size
POST /admin/packages/preload: Add to the cache a specific list of packages
POST /admin/packages/sync-all: Download (or update) the entire Typst registry in the background
DELETE /admin/packages/cache: Clear all downloaded packages
Admin Authentication:
New ADMIN_TOKEN environment variable. If set, it secures /admin endpoints. If not set it falls back to AUTH_TOKEN.
New configuration options (in the env file):
PRELOAD_PACKAGES to set a list of packages that need to be available on start up
CACHE_ALL_PACKAGES downloads the entire Typst registry in the background, which is around 1.5-2GB. Later on one can use the sync-all endpoint for keeping up to date with package updates.
Internal/technical
Added a typst-packages Docker named volume (for the cache to persist across container restarts).
Refactored main.rs into separate files and moved the request handling logic into a handlers directory.
This is the initial release of a library that provides a dockerized REST API for compiling Typst documents into PDFs.
Features
Compile Typst files through POST /compile.
Compile inline Typst source through POST /compile/source.
Support multipart uploads for typst files, images and custom fonts or other files (like json or yaml).
Load custom fonts in the mounted fonts/ directory, use POST /fonts/refresh to reload them to the cache.
Support ephemeral fonts uploaded per request (dynamic custom fonts).
Download Typst packages and templates from the Typst Universe on demand.
Return complete error messages and diagnostics.
Optional Bearer-token authentication for the API.
Configurable server port, API limits (max payload size, compilation timeout and max concurrent compilations), custom font path and authentication token.
CORS support.
Health check endpoint at GET /health.
Example requests for different Typst documents using curl and PowerShell.
Current endpoints
GET /health
POST /compile
POST /compile/source
GET /fonts
POST /fonts/refresh
The main POST /compile endpoint returns a PDF as a response when the compilation is successful and a JSON with the error message and diagnostics if the compilation fails.
Deployment
The API can be run locally with Docker Compose or using the docker image published at Docker Hub. The end goal is that anyone can easily self-host a Typst API server so that then it can be used in client-side websites or automated tasks.