XML Minify API Documentation¶
Overview¶
The XML Minify API removes unnecessary whitespace and formatting from XML documents while preserving their structure and content.
It validates the input XML for well-formedness before performing minification.
This API supports Body, URL, and File input modes.
Base URL:
https://api.apidatatools.com/xml-minify-api
Endpoint (POST)¶
POST https://api.apidatatools.com/xml-minify-api
Headers¶
| Header | Description | Required | Example |
|---|---|---|---|
Content-Type | Defines the content type of the request body. | Yes | application/xml |
x-source-type | Specifies the input mode: body, url, or file. | Optional (default: body) | x-source-type: url |
x-api-key | Your API key for authentication | Yes | abcd1234xyz |
Accepted File Extensions¶
Allowed extensions for this tool: - .txt - .xml - .log
Input Example (Body Mode)¶
<note>
<to>John</to>
<from>Jane</from>
<message> Hello World </message>
</note>
Input Example (URL Mode)¶
{
"url": "https://example.com/sample.xml"
}
Input Example (File Mode)¶
{
"file": "user_uploads/sample.xml"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/xml-minify-api" \
-H "Content-Type: application/xml" \
-H "x-source-type: body" \
-H "x-api-key: YOUR_API_KEY" \
-d '<note><to>John</to><from>Jane</from><message>Hello World</message></note>'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/xml-minify-api" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url": "https://example.com/sample.xml"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/xml-minify-api" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"file": "user_uploads/sample.xml"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "a1b2c3d4e5",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xml",
"preview": "<note><to>John</to><from>Jane</from><message>Hello World</message></note>"
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "job-1234567890",
"status_url": "https://api.apidatatools.com/jobs/job-1234567890",
"request_id": "a1b2c3d4e5"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_XML | 400 | Input XML is malformed or invalid. | {"status":"error","error":"INVALID_XML","details":{"message":"XML validation failed."}} |
INVALID_BODY_ENCODING | 400 | Failed to decode base64 body. | {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode request body."}} |
EMPTY_BODY | 400 | Request body is empty. | {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}} |
PAYLOAD_TOO_LARGE | 413 | Body size exceeds plan limit. | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit."}} |
INVALID_URL | 400 | URL is missing or invalid. | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Remote URL cannot be reached. | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL."}} |
URL_NOT_OK | 400 | Remote URL returned non-200 status. | {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}} |
FILE_TOO_LARGE | 413 | File exceeds plan limit. | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"File exceeds plan limit."}} |
INVALID_FILE_EXTENSION | 400 | File extension not supported. | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension."}} |
FILE_UNAVAILABLE | 400 | File not accessible in storage. | {"status":"error","error":"FILE_UNAVAILABLE","details":{"message":"Could not access file."}} |
INVALID_SOURCE_TYPE | 400 | Invalid source type header. | {"status":"error","error":"INVALID_SOURCE_TYPE","details":{"message":"Must be 'url' or 'file'."}} |
INTERNAL_ERROR | 500 | Unexpected server 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:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued¶
{
"job_id": "job-1234567890",
"status": "queued",
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "job-1234567890",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345680,
"result": {
"status": "success",
"request_id": "a1b2c3d4e5",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xml",
"preview": "<note><to>John</to><from>Jane</from><message>Hello World</message></note>"
}
}
Failed¶
{
"job_id": "job-1234567890",
"status": "failed",
"error": {
"code": "INVALID_XML",
"message": "XML validation failed.",
"details": {
"line": 2,
"column": 5
}
}
}
Notes for Developers¶
- The API supports three modes:
body,url, andfile. - For
urlorfilemode, the operation is asynchronous and returns ajob_id. - Use the
status_urlprovided in the async response to poll job status. - The
request_idis included in every response for traceability. - Output files are stored securely and accessible via a temporary download link.
- Ensure XML input is well-formed; invalid XML will trigger
INVALID_XMLerrors. - Preview data is limited to 100 KB for quick inspection.
- The API automatically validates file extensions before processing.