XML to Excel API Documentation¶
Overview¶
The XML to Excel API converts XML data into a downloadable Excel (.xlsx) file.
It supports three input modes:
- Body Mode (Synchronous) — Direct XML content in the request body.
- URL Mode (Asynchronous) — Remote XML file via a public HTTP/HTTPS URL.
- File Mode (Asynchronous) — Previously uploaded XML file reference.
The API validates the XML for well-formedness, converts it into a tabular structure, and returns an Excel file link or an asynchronous job reference.
Endpoint (POST)¶
POST https://api.apidatatools.com/xml-to-excel-api
Headers¶
| Header | Description | Required | Example |
|---|---|---|---|
x-api-key | Your API key for authentication | Yes | abc123xyz |
Content-Type | Request content type | Yes | application/json |
x-source-type | Input source type: body, url, or file | Optional (default: body) | body |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| Body | .xml, .txt, .log |
| URL | .xml, .txt, .log |
| File | .xml, .txt, .log |
Input Example (Body Mode)¶
<root><item><name>John</name><age>30</age></item><item><name>Jane</name><age>25</age></item></root>
Input Example (URL Mode)¶
{
"url": "https://example.com/data/sample.xml"
}
Input Example (File Mode)¶
{
"file": "user123/uploads/sample.xml"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/xml-to-excel-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: body" \
-d '<root><item><name>John</name><age>30</age></item></root>'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/xml-to-excel-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-d '{"url": "https://example.com/data/sample.xml"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/xml-to-excel-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-d '{"file": "user123/uploads/sample.xml"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "b2f1e1a3-9c2b-4f8b-9b3e-4b2a1c9e7f0a",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xlsx",
"preview": ""
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "7e5b3f2a-9a4d-4b6e-8c1f-1a2b3c4d5e6f",
"status_url": "https://api.apidatatools.com/jobs/7e5b3f2a-9a4d-4b6e-8c1f-1a2b3c4d5e6f",
"request_id": "b2f1e1a3-9c2b-4f8b-9b3e-4b2a1c9e7f0a"
}
Error Handling¶
| Error Code | HTTP Status | Message | Example |
|---|---|---|---|
INVALID_XML | 400 | XML validation or parsing failed | {"status":"error","error":"INVALID_XML","details":{"message":"XML parsing failed.","line":2,"column":5}} |
EXCEL_CONVERSION_FAILED | 400 | Failed to convert XML to Excel | {"status":"error","error":"EXCEL_CONVERSION_FAILED","details":{"message":"Conversion error"}} |
EXCEL_WRITE_FAILED | 400 | Failed to write Excel file | {"status":"error","error":"EXCEL_WRITE_FAILED","details":{"message":"Write error"}} |
INVALID_URL | 400 | Invalid or missing URL | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Could not reach the provided URL | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}} |
URL_NOT_OK | 400 | URL returned non-200 response | {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404"}} |
INVALID_FILE | 400 | Invalid or missing 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":"Extension not allowed"}} |
FILE_UNAVAILABLE | 400 | File not accessible | {"status":"error","error":"FILE_UNAVAILABLE","details":{"message":"Could not access file"}} |
FILE_TOO_LARGE | 413 | File exceeds plan limit | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"File exceeds plan limit."}} |
PAYLOAD_TOO_LARGE | 413 | Request body too large | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit"}} |
UNKNOWN_FUNCTION | 404 | Unsupported endpoint | {"status":"error","error":"UNKNOWN_FUNCTION","details":{"message":"Unsupported API endpoint."}} |
INTERNAL_ERROR | 500 | Unexpected internal error | {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}} |
Async Job Status¶
To check the status of an asynchronous job, use the status_url returned in the accepted response.
Endpoint¶
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued or Processing¶
{
"job_id": "7e5b3f2a-9a4d-4b6e-8c1f-1a2b3c4d5e6f",
"status": "queued",
"message": "Your job is being processed.",
"retry_after": 2,
"created_at": 1712345678,
"updated_at": 1712345678
}
Success¶
{
"job_id": "7e5b3f2a-9a4d-4b6e-8c1f-1a2b3c4d5e6f",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xlsx",
"request_id": "b2f1e1a3-9c2b-4f8b-9b3e-4b2a1c9e7f0a",
"preview": ""
}
}
Failed¶
{
"job_id": "7e5b3f2a-9a4d-4b6e-8c1f-1a2b3c4d5e6f",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "INVALID_XML",
"message": "XML parsing failed.",
"details": {
"message": "mismatched tag",
"line": 4,
"column": 12
}
}
}
Notes for Developers¶
- The API supports synchronous and asynchronous workflows.
- For large files or remote sources, use URL or File mode to avoid timeouts.
- The
request_idis unique per request and can be used for debugging or support. - The returned Excel file is stored temporarily and accessible via the provided download URL.
- For asynchronous jobs, use the
status_urlto poll job progress until completion.