Docs › Files, documents and media
Typst to PDF API
Turn a Typst document into a PDF, with Indian scripts set correctly.
Typst is a modern markup language for documents, quicker to write than LaTeX. Send a document and get a PDF, or one page as PNG or SVG. Noto fonts for Latin and nine Indian scripts are available; packages, other files and the network are not, so a document must be self-contained. Each document has 20 seconds.
Compile Typst to PDF
GET/v1/typstPOST
Returns the PDF itself, or one page as an image. A mistake in the document returns 422 with Typst's message, line and column.
Also takes POST: The Typst document. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.
The answer returns the PDF itself; errors are JSON as everywhere else.
What you send here is never written to the log, and the answer is not cached.
| Parameter | Description |
|---|---|
textquery | The document (or POST it). |
formatquery | Default pdf. One of: pdf, png, svg. |
pagequery | png and svg: which page. Default 1. |
ppiquery | png: pixels per inch, 36 to 300. Default 144. |
curl
curl -o out.pdf "https://api.dharun.dev/v1/typst?text=%23set%20page%28width%3A%2012cm%2C%20height%3A%20auto%2C%20margin%3A%201cm%29%0A=%20வணக்கம்%2C%20India%20API%0ATypst%20sets%20%2ATamil%2A%2C%20हिन्दी%20and%20English%20on%20one%20page."Python
import requests
response = requests.get("https://api.dharun.dev/v1/typst?text=%23set%20page%28width%3A%2012cm%2C%20height%3A%20auto%2C%20margin%3A%201cm%29%0A=%20வணக்கம்%2C%20India%20API%0ATypst%20sets%20%2ATamil%2A%2C%20हिन्दी%20and%20English%20on%20one%20page.", timeout=60)
response.raise_for_status()
open("out.pdf", "wb").write(response.content)Using an AI assistant? Connect the MCP server and it can call this API by itself.