API Reference Documentation
The FreeLibreOffice API converts office documents into high-fidelity vector PDF files or directly extracts individual pages as responsive raster/vector image layers.
POST
/api/convertTransforms an uploaded document file or remote URL, stores the layout output inside the CDN Edge Cache, and returns a JSON payload containing metadata and a high-speed direct stream URL.
| Query Param | Type | Default | Description |
|---|---|---|---|
| format | string | Target extension: pdf, svg, png, jpeg, webp, avif. | |
| page | number | 1 | The target page to extract. Ignored for PDF conversions. |
| quality | number | 80 | Raster image compression ratio (1-100). Applies only to jpeg, webp, avif. |
| url | string | None | A direct public link to the source document. Bypass multipart files entirely. |
Response Payload (JSON)
{
"success": true,
"hash": "eebcd49494a4d378e81dbb8d7...",
"format": "webp",
"mimeType": "image/webp",
"totalPages": 12,
"actualPage": 1,
"url": "https://freelibreoffice.pages.dev/api/convert?hash=eebcd49494a4d378e81dbb8d7...&format=webp&page=1&quality=80"
}GET
/api/convert?hash=...Retrieves the cached converted file directly from the Cloudflare Edge CDN using its unique content hash. Returns the raw file bytes with appropriate content-type headers and 1-year browser cache headers (Cache-Control).
Code Integration Examples
cURL (Multipart Upload)
curl --request POST \ --url "https://freelibreoffice.pages.dev/api/convert?format=webp&page=1&quality=85" \ --header "Content-Type: multipart/form-data" \ --form "file=@/path/to/document.docx"
cURL (Import Remote URL)
curl --request POST \ --url "https://freelibreoffice.pages.dev/api/convert?format=svg&page=1&url=https://example.com/document.docx"
JavaScript (Web API / Fetch)
const formData = new FormData();
formData.append("file", fileInput.files[0]);
// 1. Get CDN Cached URL Metadata
const response = await fetch("https://freelibreoffice.pages.dev/api/convert?format=webp&page=1", {
method: "POST",
body: formData
});
const metadata = await response.json();
console.log("Streamable Link:", metadata.url);
// 2. Load directly into your <img> tag
document.getElementById("preview-img").src = metadata.url;Python (Requests)
import requests
url = "https://freelibreoffice.pages.dev/api/convert"
params = {
"format": "webp",
"page": "1",
"quality": "80"
}
# Uploading local file
files = {'file': open('document.docx', 'rb')}
response = requests.post(url, params=params, files=files)
metadata = response.json()
print("CDN Streaming URL:", metadata.get("url"))Go (net/http Multipart)
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
apiUrl := "https://freelibreoffice.pages.dev/api/convert?format=png&page=1"
var b bytes.Buffer
w := multipart.NewWriter(&b)
f, _ := os.Open("document.docx")
defer f.Close()
fw, _ := w.CreateFormFile("file", "document.docx")
io.Copy(fw, f)
w.Close()
req, _ := http.NewRequest("POST", apiUrl, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
client := &http.Client{}
res, _ := client.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}