API Documentation
API Reference
For complete API specifications and interactive testing, visit the Swagger Documentation
Rate Limits
The API is rate limited to 20 requests per minute per user. If you exceed this limit,
you'll receive a
429 Too Many Requests error.Current Limitation
The API currently handles only single LaTeX files. Multi-file projects with includes or custom packages are
not yet supported.
Step 1: Generate an API Key
To use the compile API, you'll need to generate an API key first.
- Navigate to the API Keys page
- Click the "Create Api Key" button
- Enter a name for your API key (minimum 5 characters)
- Click "Submit" to generate the key
- Copy the generated API key and store it securely - it won't be shown again
Security Note: Treat your API key like a password. Never commit it to version control or share it publicly.
Step 2: Using the Compile API
The API provides two endpoints for compiling LaTeX documents to PDF.
Option 1: Compile from JSON
Send LaTeX content directly as JSON.
POST
/api/latex/compilecurl -X POST https://your-domain.com/api/latex/compile \
-H "Content-Type: application/json" \
-H "X-API-KEY: your-api-key-here" \
-d '{
"content": "\\documentclass{article}\n\\begin{document}\nHello World!\n\\end{document}"
}' \
--output document.pdfOption 2: Compile from File
Upload a .tex file directly.
POST
/api/latex/compile/filecurl -X POST https://your-domain.com/api/latex/compile/file \
-H "X-API-KEY: your-api-key-here" \
-F "file=@document.tex" \
--output document.pdfAuthentication
All API requests must include your API key in the request headers.
| Header | Value | Required |
|---|---|---|
| X-API-KEY | Your API key | Yes |
| Content-Type | application/json (for JSON endpoint) | Yes (for JSON) |
Response
On success, the API returns the compiled PDF file with appropriate headers.
Status:
200 OKContent-Type:
application/pdfBody: PDF binary data
Error Handling
If compilation fails or authentication is invalid, you'll receive an error response.
| Status Code | Description |
|---|---|
| 401 | Unauthorized - Invalid or missing API key |
| 400 | Bad Request - Invalid LaTeX syntax or missing content |
| 429 | Too Many Requests - Rate limit exceeded (20 requests per minute) |
| 500 | Internal Server Error - Compilation failed |
Code Examples
Python
import requests
api_key = "your-api-key-here"
base_url = "https://your-domain.com"
# Option 1: Compile from JSON
latex_content = r"""
\documentclass{article}
\begin{document}
Hello World!
\end{document}
"""
response = requests.post(
f"{base_url}/api/latex/compile",
headers={
"X-API-KEY": api_key,
"Content-Type": "application/json"
},
json={
"content": latex_content
}
)
if response.status_code == 200:
with open("output.pdf", "wb") as f:
f.write(response.content)
print("PDF compiled successfully!")
else:
print(f"Error: {response.status_code} - {response.text}")
# Option 2: Compile from file
with open("document.tex", "rb") as f:
files = {
"file": ("document.tex", f, "text/x-tex")
}
response = requests.post(
f"{base_url}/api/latex/compile/file",
headers={
"X-API-KEY": api_key
},
files=files
)
if response.status_code == 200:
with open("output.pdf", "wb") as f:
f.write(response.content)
print("PDF compiled successfully!")
else:
print(f"Error: {response.status_code} - {response.text}")JavaScript (Node.js)
const fs = require('fs');
const FormData = require('form-data');
const axios = require('axios');
const apiKey = 'your-api-key-here';
const baseUrl = 'https://your-domain.com';
// Option 1: Compile from JSON
const latexContent = `\\documentclass{article}
\\begin{document}
Hello World!
\\end{document}`;
axios.post(`${baseUrl}/api/latex/compile`, {
content: latexContent
}, {
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
},
responseType: 'arraybuffer'
})
.then(response => {
fs.writeFileSync('output.pdf', response.data);
console.log('PDF compiled successfully!');
})
.catch(error => {
console.error('Error:', error.response?.status, error.message);
});
// Option 2: Compile from file
const formData = new FormData();
formData.append('file', fs.createReadStream('document.tex'));
axios.post(`${baseUrl}/api/latex/compile/file`, formData, {
headers: {
'X-API-KEY': apiKey,
...formData.getHeaders()
},
responseType: 'arraybuffer'
})
.then(response => {
fs.writeFileSync('output.pdf', response.data);
console.log('PDF compiled successfully!');
})
.catch(error => {
console.error('Error:', error.response?.status, error.message);
});