Excel to XML API Documentation¶
Overview¶
The Excel to XML API converts Excel files (.xls, .xlsx) into structured XML format.
It supports multiple sheets, optional header rows, and customizable XML tag names.
The API can process data synchronously (direct upload) or asynchronously (remote file URL or uploaded file reference).
Base URL:
https://api.apidatatools.com/excel-to-xml-api
Endpoint (POST)¶
POST https://api.apidatatools.com/excel-to-xml-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key | string | Yes | Your API key for authentication |
x-source-type | string | Optional | Input source type: body, url, or file (default: body) |
x-has-header | string | Optional | "0", "false", or "no" disables header row detection |
x-sheet-name | string | Optional | Process only the specified sheet name |
x-sheet-index | integer | Optional | Process only the specified sheet index (0-based) |
x-tab-space | integer | Optional | Number of spaces for XML indentation (default: 2) |
x-root-name | string | Optional | Root XML element name (default: root) |
x-row-name | string | Optional | Row XML element name (default: row) |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| Body / URL / File | .xls, .xlsx |
Input Example (Body Mode)¶
Binary Excel content must be Base64-encoded when sent in the request body.
Headers:
x-source-type: body
Content-Type: application/octet-stream
x-api-key: YOUR_API_KEY
Body: Binary Excel file data
Input Example (URL Mode)¶
Headers:
x-source-type: url
Content-Type: application/json
x-api-key: YOUR_API_KEY
Body:
{
"url": "https://example.com/data/sample.xlsx"
}
Input Example (File Mode)¶
Headers:
x-source-type: file
Content-Type: application/json
x-api-key: YOUR_API_KEY
Body:
{
"file": "user123/upl_abc123/sample.xlsx"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/excel-to-xml-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
-H "Content-Type: application/octet-stream" \
--data-binary "@sample.xlsx"
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/excel-to-xml-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/data/sample.xlsx"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/excel-to-xml-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
-H "Content-Type: application/json" \
-d '{"file": "user123/upl_abc123/sample.xlsx"}'
Example Response¶
Successful (Body Mode)¶
Status Code: 200 OK
{
"status": "success",
"request_id": "b1e2f3a4-5678-90ab-cdef-1234567890ab",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xml",
"preview": "<root>\n <sheet name=\"Sheet1\">...</sheet>\n</root>"
}
Async Job Accepted¶
Status Code: 202 Accepted
{
"status": "accepted",
"job_id": "job-1234567890abcdef",
"status_url": "https://api.apidatatools.com/jobs/job-1234567890abcdef",
"request_id": "b1e2f3a4-5678-90ab-cdef-1234567890ab"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_EXCEL_CONTENT_TYPE | 400 | Input is not valid Excel bytes | {"status":"error","error":"INVALID_EXCEL_CONTENT_TYPE","details":{"message":"Excel content must be raw bytes."}} |
EXCEL_READ_FAILED | 400 | Excel file could not be read | {"status":"error","error":"EXCEL_READ_FAILED","details":{"message":"Failed to read Excel file."}} |
EXCEL_TO_XML_CONVERSION_FAILED | 400 | Conversion to XML failed | {"status":"error","error":"EXCEL_TO_XML_CONVERSION_FAILED","details":{"message":"Failed to convert Excel to XML."}} |
XML_SERIALIZATION_FAILED | 400 | XML serialization failed | {"status":"error","error":"XML_SERIALIZATION_FAILED","details":{"message":"Failed to serialize XML."}} |
INVALID_BODY_ENCODING | 400 | Base64 decoding failed | {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode binary body."}} |
EMPTY_BODY | 400 | Missing request body | {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}} |
PAYLOAD_TOO_LARGE | 413 | Body exceeds plan limit | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit."}} |
INVALID_URL | 400 | Invalid or missing URL | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Could not reach remote file | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}} |
URL_NOT_OK | 400 | Remote file returned non-200 status | {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404"}} |
FILE_TOO_LARGE | 413 | File exceeds plan limit | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}} |
INVALID_FILE | 400 | Invalid file reference | {"status":"error","error":"INVALID_FILE","details":{"message":"Missing or invalid 'file'."}} |
INVALID_FILE_EXTENSION | 400 | Unsupported file extension | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension"}} |
INTERNAL_ERROR | 500 | Unexpected internal error | {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}} |
Async Job Status¶
Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Response Examples:
Queued / Processing¶
{
"job_id": "job-1234567890abcdef",
"status": "queued",
"message": "Your job is being processed.",
"retry_after": 2,
"created_at": 1712345678,
"updated_at": 1712345678
}
Completed Successfully¶
{
"job_id": "job-1234567890abcdef",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xml",
"request_id": "b1e2f3a4-5678-90ab-cdef-1234567890ab",
"preview": "<root><sheet name=\"Sheet1\">...</sheet></root>"
}
}
Failed¶
{
"job_id": "job-1234567890abcdef",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "EXCEL_READ_FAILED",
"message": "Failed to read Excel file.",
"details": {
"message": "Excel file is corrupted."
}
}
}
Notes for Developers¶
- The API supports three input modes:
- Body: Direct upload (synchronous)
- URL: Remote file (asynchronous)
- File: Pre-uploaded file (asynchronous)
- For asynchronous jobs, use the returned
status_urlto poll job progress. - The
previewfield in responses contains the first 100 KB of the generated XML for quick inspection. - Ensure correct Excel MIME type and Base64 encoding when using body mode.
- Headers such as
x-root-nameandx-row-nameallow customization of XML structure. - Always include
x-api-keyfor authentication.