XML to HTML API¶
Overview¶
Convert XML input to HTML. Body mode runs synchronously; URL and file modes run asynchronously.
Endpoint¶
| Method | URL |
|---|---|
POST | https://api.apidatatools.com/xml-to-html-api |
Authentication¶
Send your API key in the x-api-key header.
Input modes¶
| Mode | Description | Processing |
|---|---|---|
body | Send XML text directly in the request body. | Synchronous |
url | Provide a URL to an XML file. | Asynchronous |
file | Provide the storage key for a previously uploaded XML file. | Asynchronous |
Headers¶
Header names are case-insensitive.
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | Your API key | Authenticates the request. |
x-source-type | String | No | Default: body. Values: body, url, file | Selects the input mode. |
Accepted file extensions¶
For URL and file modes, accepted extensions are .txt, .xml, and .log.
Request body¶
Body mode¶
Send the XML as raw text in the request body. The body must not be empty.
URL mode¶
Send a JSON object containing the URL:
{
"url": "https://example.com/input.xml"
}
The URL must use HTTP or HTTPS, be reachable, and return HTTP 200 or 206.
File mode¶
Send a JSON object containing the exact storage key associated with a file uploaded through the upload workflow:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
Do not add a prefix to the storage key.
curl examples¶
Body mode¶
curl -X POST "https://api.apidatatools.com/xml-to-html-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
--data-raw '<root><item>Hello</item></root>'
URL mode¶
curl -X POST "https://api.apidatatools.com/xml-to-html-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
--data '{"url":"https://example.com/input.xml"}'
File mode¶
curl -X POST "https://api.apidatatools.com/xml-to-html-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful response that produces a file has HTTP 200 and includes a download URL in file and the output preview in preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "HTML preview"
}
Download URLs are temporary; retention depends on your plan.
Asynchronous URL and file modes¶
A successfully accepted job returns HTTP 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Async job status¶
Poll the returned status_url with GET to retrieve the job status. This status endpoint requires the same API key.
curl -X GET "https://api.apidatatools.com/jobs/JOB_ID" \
-H "x-api-key: YOUR_API_KEY"
The status response includes request_id, job_id, status, created_at, and updated_at. Timestamps are Unix timestamps.
Queued or processing¶
For either queued or processing, the response also includes message and retry_after:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 1700000000,
"updated_at": 1700000000,
"message": "Your job is being processed.",
"retry_after": 2
}
The status value in this shape may also be "processing".
Success¶
A completed job includes a result object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000005,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "HTML preview"
}
}
Failed¶
A failed job includes an error object. Its details may contain additional information:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000005,
"error": {
"code": "ERROR_CODE",
"message": "Description of the error",
"details": {
"message": "Description of the error"
}
}
}
Error handling¶
Errors use this envelope; details may include additional fields:
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error"
}
}
The following HTTP statuses are defined for this API and its job-status endpoint:
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY; URL/file job-submission errors INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION; job-status errors INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR; and converter input errors. |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE, FILE_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR; URL/file job-submission errors CONFIG_ERROR, PLAN_CONFIG_ERROR |
Asynchronous processing can also fail after the job has been accepted. Such failures appear in the job-status response; possible codes include INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, FILE_TOO_LARGE, and INTERNAL_ERROR.
Notes¶
- Body-size, file-size, quota, and rate limits depend on your plan. See API tool limits.
- Download URLs are temporary, and retention depends on your plan.
- URL and file modes validate the input file extension against the accepted extensions listed above.