API
This page lists common Univer Server APIs. The default base URL is http://localhost:8000.
Note:
typeparameter values:1for Docs,2for Sheets.
Document Management
Create Document
POST/universer-api/snapshot/{type}/unit/-/create
Headers
content-type: application/jsonBody Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
type* | enum(int) | - | 1 (docs), 2 (sheets) for path and body |
name* | string | - | Document name |
creator* | string | - | Creator id |
curl http://localhost:8000/universer-api/snapshot/{type}/unit/-/create \ -X POST \ -H 'Content-Type: application/json' \ --data-raw '{"type":2,"name":"New Sheet By Univer","creator":"userID"}'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
unitID | string | - | Document id |
{ "error": { "code": 1, "message": "success" }, "unitID": "ETVf-B4lQqOSE_p09mcp9Q"}List Documents
GET/universer-api/snapshot/{type}/units
Headers
Query Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
type* | enum(int) | - | 1 (doc), 2 (sheet) for path and body |
nextCursor | string | - | Next page cursor |
curl -X GET 'http://localhost:8000/universer-api/snapshot/1/units?nextCursor=100'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
units | array[object] | - | Document list |
unitID | string | - | Document id |
name | string | - | Document name |
type | enum(int) | - | 1 (doc), 2 (sheet) |
nextCursor | string | - | Next page cursor; empty means last page |
{ "error": { "code": 1, "message": "" }, "units": [ { "unitID": "1", "name": "a", "type": 1 } ], "nextCursor": "200"}Delete Documents
DELETE/universer-api/snapshot/-/units
Headers
content-type: application/jsonQuery Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
unitIds* | array[string] | - | Document id list |
curl -X DELETE 'http://localhost:8000/universer-api/snapshot/-/units?unitIds=1&unitIds=2'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
{ "error": { "code": 1, "message": "" }}Files and Import/Export
Upload File
POST/universer-api/stream/file/upload
Headers
content-type: multipart/form-dataBody Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
size* | int | - | File size in bytes (query param). Must match actual size. |
file* | Form.file | - | File in HTML form |
curl 'http://localhost:8000/universer-api/stream/file/upload?size=125466' \ --header 'cookie: _univer=XXXXXX' \ --form 'file=@"demo.xlsx"'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
FileId | string | - | File id for import/export |
{ "FileId": "xxxx"}Import
POST/universer-api/exchange/{type}/import
Headers
content-type: application/jsonBody Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
type* | enum(int) | - | 1 (doc), 2 (sheet) |
outputType* | enum(int) | - | 1 (unit), 2 (json) |
fileID* | string | - | Uploaded file id |
minSheetRowCount* | int | - | Minimum rows; import validates row count |
minSheetColumnCount* | int | - | Minimum columns; import validates column count |
curl -X POST 'http://localhost:8000/universer-api/exchange/2/import' \ -H 'Content-Type: application/json' \ --data-raw '{"fileID":"123","outputType":1,"minSheetRowCount":1000,"minSheetColumnCount":20}'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
taskID | string | - | Task id for polling |
{ "error": { "code": 1, "message": "" }, "taskID": "456"}Export
POST/universer-api/exchange/{type}/export
Headers
content-type: application/jsonBody Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
type* | enum(int) | - | 1 (doc), 2 (sheet) |
unitID* | string | - | Document id |
sscSwitch | boolean | - | Enable SSC (server-side calculation); default false |
curl -X POST 'http://localhost:8000/universer-api/exchange/2/export' \ -H 'Content-Type: application/json' \ --data-raw '{"unitID":"xxxx","type":2}'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
taskID | string | - | Task id for polling |
{ "error": { "code": 1, "message": "" }, "taskID": "456"}Get Task Result
GET/universer-api/exchange/task/{taskID}
Headers
Path Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
taskID* | string | - | Task id |
curl -X GET 'http://localhost:8000/universer-api/exchange/task/123'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
status | enum(string) | - | "pending", "done", "failed" |
export | object | - | - |
fileID | string | - | Exported file id |
import | object | - | - |
unitID | string | - | Imported unitID |
jsonID | string | - | JSON file id |
{ "error": { "code": 1, "message": "" }, "status": "done", "export": { "fileID": "456" }, "import": { "unitID": "789", "jsonID": "012" }}Get File
GET/universer-api/file/{fileID}/sign-url
Headers
Path Parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
fileID* | string | - | Result file id |
curl -X GET 'http://localhost:8000/universer-api/file/1234/sign-url'Response
application/json
| Parameter | Type | Example | Description |
|---|---|---|---|
error | object | - | - |
code | enum(int) | - | 1 (success) |
message | string | - | Error message |
url | string | - | Download URL |
{ "error": { "code": 1, "message": "" }, "url": "https://example.com/path/to/file.xlsx"}How is this guide?
