XML to JSON API¶
Overview¶
Convert XML input to JSON. Body mode processes the XML synchronously. URL and file modes submit an asynchronous job.
Endpoint¶
POST https://api.apidatatools.com/xml-to-json-api
Authentication¶
Send your API key in the x-api-key header.
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous conversion of raw XML text. This is the default mode. |
url | Asynchronous conversion of a file at an HTTP or HTTPS URL. |
file | Asynchronous conversion of a pre-uploaded file. |
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | string | Yes | Your API key | Authenticates the request. |
x-source-type | string | No | body; body, url, or file | Selects the input mode. Header names are case-insensitive. |
Accepted file extensions¶
For URL and file modes, the input file must have one of these extensions:
txtxmllog
Request body¶
Body mode¶
Send the XML document as raw text in the request body.
URL mode¶
Send a JSON object with a url property containing the file’s HTTP or HTTPS URL:
{
"url": "https://example.com/input.xml"
}
File mode¶
Send a JSON object with a file property containing the exact storage key returned by the upload workflow:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl -X POST "https://api.apidatatools.com/xml-to-json-api" \
-H "x-api-key: YOUR_API_KEY" \
--data-raw '<root><item>value</item></root>'
URL mode¶
curl -X POST "https://api.apidatatools.com/xml-to-json-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
--data-raw '{"url":"https://example.com/input.xml"}'
File mode¶
curl -X POST "https://api.apidatatools.com/xml-to-json-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
--data-raw '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
Body mode returns HTTP 200. The preview is serialized JSON.
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "{\n \"root\": {\n \"item\": \"value\"\n }\n}"
}
Asynchronous URL and file modes¶
URL and file modes return HTTP 202 when the job is accepted.
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Async job status¶
Check a job with:
GET https://api.apidatatools.com/jobs/{job_id}
Include the x-api-key header. The status response includes request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps in seconds.
Queued or processing¶
For statuses other than success and failed, the response includes a message and retry interval:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 1760000000,
"updated_at": 1760000000,
"message": "Your job is being processed.",
"retry_after": 2
}
The same shape applies when status is processing.
Success¶
A completed job includes its result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1760000000,
"updated_at": 1760000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "JSON preview"
}
}
Failed¶
A failed job includes an error code, message, and details:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1760000000,
"updated_at": 1760000002,
"error": {
"code": "FILE_TOO_LARGE",
"message": "File exceeds allowed limit.",
"details": {
"message": "File exceeds allowed limit."
}
}
}
Error handling¶
Error responses use this envelope. Additional fields may appear inside details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error"
}
}
Synchronous request errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, and XML conversion errors |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR |
XML conversion errors are returned with HTTP 400; their specific codes depend on the conversion error.
URL and file submission errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION |
413 | FILE_TOO_LARGE |
500 | CONFIG_ERROR, PLAN_CONFIG_ERROR |
Job status request errors¶
Job status request errors use HTTP 400 for INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR. An unexpected server error uses HTTP 500 with INTERNAL_ERROR.
Errors that occur while an asynchronous job is running are reported in the job’s failed status response; they are not HTTP statuses for the original submission request. Codes include INVALID_JOB, FILE_TOO_LARGE, DOWNLOAD_FAILED, UPLOAD_FAILED, and INTERNAL_ERROR.
Notes¶
- Body-size, file-size, quota, rate, and output-retention limits depend on your plan. See API tool limits.
- Output download URLs are temporary; their retention period depends on your plan.