API reference
Export a file
GET /api/pub/v1/files/{fileId}/export?format=, a page as HTML, a sheet as CSV or XLSX, a deck as PDF or PPTX.
GET
https://api.dhanu.ai/api/pub/v1/files/{fileId}/exportExports an artifact in a portable format. Which formats fit depends on the kind:
| Kind | Formats | Notes |
|---|---|---|
page | html | The single self-contained HTML document, as it is served in the app. |
sheet | csv, xlsx | csv exports the first tab; xlsx keeps every tab and its formulas. |
deck | pptx, pdf | pdf needs a render first, see below. |
A deck’s PDF is rendered by a background job, so the first pdf export of a deck
answers export_not_rendered: call render a file,
wait for the job, then export. Every other pairing is produced on the spot. A
format the kind does not support answers unsupported_export_format.
Request
curl -OJ "https://api.dhanu.ai/api/pub/v1/files/$FILE_ID/export?format=xlsx" \
-H "Authorization: Bearer $DHANU_API_KEY"const workbook = await dhanu.files.export(fileId, "xlsx");
await fs.writeFile(workbook.filename ?? "export.xlsx", workbook.bytes);workbook = dhanu.files.export(file_id, "xlsx")
with open(workbook.filename or "export.xlsx", "wb") as fh:
fh.write(workbook.bytes) Response
200 OK
The exported document, with the format’s Content-Type and a Content-Disposition filename.
Errors
| Code | Status | Meaning |
|---|---|---|
invalid_api_key | 401 | The bearer key is missing or unknown. |
api_key_revoked | 401 | The key was revoked. |
api_key_expired | 401 | The key passed its expiry date. |
api_key_ip_not_allowed | 403 | The caller's IP is outside the key's allowlist. |
developer_access_revoked | 403 | The key's creator lost developer access in the workspace. |
api_key_project_scope | 403 | The key covers no active projects, or projectId is outside its scope. |
not_found | 404 | No such resource in the key's workspace. |
invalid_request_body | 422 | The body did not match the schema; error.issues names each field. |
unsupported_export_format | 422 | That file kind cannot be exported in the requested format. |
export_not_rendered | 409 | The deck's PDF has not been rendered yet. |