Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit 8680a28

Browse files
Merge pull request #13 from slashformotion/rework-readme
rework readme
2 parents dd2735f + 9cce945 commit 8680a28

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

README.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,71 @@
11
# Typst HTTP API
22

3+
***Compile typst documents with a simple HTTP request.***
4+
35
<!-- This sentence is from the typst repo -->
46
> [Typst](https://github.com/typst/typst) is a new markup-based typesetting system
57
> that is designed to be as powerful as LaTeX while being much easier to learn and use.
68
I recommend that you check it out if you don't know it yet.
79

810
This project is a web server that allows users to compile typst markup remotely by a simple API call.
9-
This webserver is provided in the form of a docker container.
10-
*For now there is no official image on any registry.*
11+
This webserver is provided in the form of a docker container [`ghcr.io/slashformotion/typst-http-api` see available tags](https://github.com/slashformotion/typst-http-api/pkgs/container/typst-http-api).
1112

1213
I want to bring some elements to your attention:
1314

14-
- Please be aware that while the container runs,
15-
I do not consider this project production-ready, more work is needed.
1615
- All contributions are welcome of course welcome.
1716
- Currently, there is no way to compile a file that loads external resources (images or other `.typ` files for example).
1817

19-
Current version: v0.1.0
18+
## HTTP interface
2019

21-
## Build and run
20+
This service expose two endpoints:
2221

23-
Build the docker image
22+
- `POST /` : send the typst content directly to the endpoint (no Content-Type header required) and a streaming reponse will be return with the raw pdf bytes. You can find the corresponding curl command in the section [How does it work ?](#how-does-it-work-).
23+
24+
If your document is not valid and an error happen at the compilation step, you will get a code 422 and a json response with the raw error[^1].
25+
26+
- `GET /metrics` : a traditional prometheus metrics endpoint (includes python gc data, http requests info and others).
27+
28+
## How does it work ?
29+
30+
Run the container:
2431

2532
```shell
26-
docker build . -t typst_image
27-
# This command build an image using the Dockerfile at the root of the project,
28-
# then tag it with "typst_image"
33+
docker run -p 8000:8000 ghcr.io/slashformotion/typst-http-api
2934
```
3035

31-
Create a container:
36+
Send a valid Typst file (here `test.typ`) to the api and output the file to `result.pdf`:
3237

3338
```shell
34-
docker run -p 8000:8000 typst_image
35-
# This command creates a docker container based on the image created at the last step
39+
curl -H "Content-Type:text/plain" -X POST --data-binary @test.typ http://localhost:8000 --output result.pdf
3640
```
3741

38-
Send `test.typ` to the api and output the file to `result.pdf`:
42+
### With docker-compose
3943

40-
```shell
41-
curl -H "Content-Type:text/plain" --data-binary @test.typ http://localhost:8000 --output result.pdf
44+
```yml
45+
version: "3.8"
46+
47+
services:
48+
typst-builder:
49+
image: ghcr.io/slashformotion/typst-http-api:v0.3.0
50+
ports:
51+
- "8000:8000"
4252
```
4353
44-
Or more simply use [httpie](https://httpie.io/cli):
54+
## Build the docker image locally
55+
56+
Build the docker image
4557
4658
```shell
47-
cat test.typ | http POST http://localhost:8000 > result.pdf
59+
docker build . -t typst_image
60+
# This command build an image using the Dockerfile at the root of the project,
61+
# then tag it with "typst_image"
4862
```
4963

50-
- If the compilation succeeds, you will get a response with an HTTP code `200`.
51-
The body of the response will contain the pdf document.
52-
- On an invalid input you will get a JSON containing the error returned by the compiler with an HTTP code `422 Unprocessable Content`.
64+
Create a container:
65+
66+
```shell
67+
docker run -p 8000:8000 typst_image
68+
# This command creates a docker container based on the image created at the last step
69+
```
5370

54-
```json
55-
{
56-
"error": "compile error: 16:21 expected length, found string"
57-
}
58-
```
71+
[^1]: error example: `{"reason":"compilation error", "content": "raw error log here"}`

0 commit comments

Comments
 (0)