API

GitHubEdit on GitHub

Create Document

POST/universer-api/snapshot/{type}/unit/-/create
Headers
content-type: application/json
Body Parameters
ParameterTypeExampleDescription
type*enum(int)-1 (docs), 2 (sheets) path and request body parameters
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
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
unitIDstring-Document ID
{
  "error": {
    "code": 1,
    "message": "success"
  },
  "unitID": "ETVf-B4lQqOSE_p09mcp9Q"
}

Get Document List

GET/universer-api/snapshot/{type}/units
Headers
Query Parameters
ParameterTypeExampleDescription
type*enum(int)-1 (doc), 2 (sheet) path and request body parameters
nextCursorstring-Next page cursor for pagination
curl -X GET 'http://localhost:8000/universer-api/snapshot/1/units?nextCursor=100'
Response
application/json
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
unitsarray[object]-List of documents
unitIDstring-Document ID
namestring-Document name
typeenum(int)-1(doc),2(sheet)
nextCursorstring-Next page cursor for pagination, empty when it is the last page
{
  "error": {
    "code": 1,
    "message": ""
  },
  "units": [
    {
      "unitID": "1",
      "name": "a",
      "type": 1
    }
  ],
  "nextCursor": "200"
}

Delete Document

DELETE/universer-api/snapshot/-/units
Headers
content-type: application/json
Query Parameters
ParameterTypeExampleDescription
unitIds*array[string]-Array of document IDs
curl -X DELETE 'http://localhost:8000/universer-api/snapshot/-/units?unitIds=1&unitIds=2'
Response
application/json
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
{
  "error": {
    "code": 1,
    "message": ""
  }
}

Upload File

POST/universer-api/stream/file/upload
Headers
content-type: multipart/form-data
Body Parameters
ParameterTypeExampleDescription
size*int-File size (byte), query parameter; the parameter must equal the actual file size, otherwise it will return an error
file*Form.file-HTML form file upload
curl 'http://localhost:8000/universer-api/stream/file/upload?size=125466' \
  --header 'cookie: _univer=XXXXXX' \
  --form 'file=@"demo.xlsx"'
Response
application/json
ParameterTypeExampleDescription
FileIdstring-File ID, used for subsequent requests such as import and export
{
  "FileId": "xxxx"
}

Import

POST/universer-api/exchange/{type}/import
Headers
content-type: application/json
Body Parameters
ParameterTypeExampleDescription
type*enum(int)-1 (doc), 2 (sheet)
outputType*enum(int)-1 (unit), 2 (json)
fileID*string-The ID of the uploaded file
minSheetRowCount*int-Minimum row count, the import will check if the sheet row count meets the requirement
minSheetColumnCount*int-Minimum column count, the import will check if the sheet column count meets the requirement
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
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
taskIDstring-Conversion task ID, import and export are asynchronous, use this ID to poll the interface for conversion results
{
  "error": {
    "code": 1,
    "message": ""
  },
  "taskID": "456"
}

Export

POST/universer-api/exchange/{type}/export
Headers
content-type: application/json
Body Parameters
ParameterTypeExampleDescription
type*enum(int)-1 (doc), 2 (sheet)
unitID*string-Document ID
sscSwitchboolean-Whether to enable SSC (Server Side Calculation), set to true to trigger server-side formula calculation, default is 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
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
taskIDstring-Conversion task ID, import and export are asynchronous, use this ID to poll the interface for conversion results
{
  "error": {
    "code": 1,
    "message": ""
  },
  "taskID": "456"
}

Get Conversion Result

GET/universer-api/exchange/task/{taskID}
Headers
Path Parameters
ParameterTypeExampleDescription
taskID*string-Conversion task ID
curl -X GET 'http://localhost:8000/universer-api/exchange/task/123'
Response
application/json
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
statusenum(string)-"pending", "done", "failed"
exportobject--
fileIDstring-The file ID of the export conversion result, used for subsequent requests to get file content
importobject--
unitIDstring-The unit ID after import conversion, used to open the online spreadsheet
jsonIDstring-The file ID of the import conversion result in JSON format, used for subsequent requests to get file content
{
  "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
ParameterTypeExampleDescription
fileID*string-The file ID of the conversion task result
curl -X GET 'http://localhost:8000/universer-api/file/1234/sign-url'
Response
application/json
ParameterTypeExampleDescription
errorobject--
codeenum(int)-1 (success)
messagestring-The information of fail situation
urlstring-The download URL of the file
{
  "error": {
    "code": 1,
    "message": ""
  },
  "url": "https://example.com/path/to/file.xlsx"
}