XML to YAML API¶
Overview¶
Convert XML input to YAML using the XML-to-YAML API. Body mode runs synchronously; URL and file modes submit an asynchronous job.
Endpoint¶
| Method | URL |
|---|---|
POST | https://api.apidatatools.com/xml-to-yaml-api |
Authentication¶
Include your API key in the x-api-key header on every request, including job-status requests.
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous conversion. This is the default mode. |
url | Asynchronous conversion of a file at a URL. |
file | Asynchronous conversion of a previously uploaded file. |
Headers¶
Header names are case-insensitive. The lowercase spellings below are documented.
| 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¶
URL and file inputs must use one of these extensions:
txtxmllog
File-size limits depend on your plan. See tool limits.
Request body¶
Body mode¶
Send the XML as raw text in the request body. The conversion is synchronous.
URL mode¶
Send a JSON object with a url property:
{
"url": "https://example.com/input.xml"
}
File mode¶
Send a JSON object with a file property. Use the exact storage key returned by the upload workflow.
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl --request POST \
--url https://api.apidatatools.com/xml-to-yaml-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: body' \
--data-raw '<root><item>Example</item></root>'
URL mode¶
curl --request POST \
--url https://api.apidatatools.com/xml-to-yaml-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: url' \
--data-raw '{"url":"https://example.com/input.xml"}'
File mode¶
curl --request POST \
--url https://api.apidatatools.com/xml-to-yaml-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: file' \
--data-raw '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful conversion returns HTTP 200 with a file URL and preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "YAML preview"
}
The download URL is temporary; retention depends on your plan.
Asynchronous URL and file modes¶
A successfully accepted request returns HTTP 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Acceptance means the job was queued; check its status to get the result.
Async job status¶
Poll the status URL returned when the job is accepted:
curl --request GET \
--url https://api.apidatatools.com/jobs/JOB_ID \
--header 'x-api-key: YOUR_API_KEY'
The status endpoint returns the job ID, request ID, state, and creation and update times. Timestamps are Unix time in seconds.
For queued and processing jobs, the response includes a 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 same pending response shape applies when status is processing.
For a completed job, result contains the conversion output:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "YAML preview"
}
}
For a failed job, error contains the failure code, message, and details:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000002,
"error": {
"code": "DOWNLOAD_FAILED",
"message": "Failure message",
"details": {}
}
}
Error handling¶
Errors use this response envelope. Additional fields may appear in details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error"
}
}
The following HTTP statuses are defined for these errors:
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION, INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR |
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, CONFIG_ERROR, PLAN_CONFIG_ERROR |
DOWNLOAD_FAILED and UPLOAD_FAILED are reported as asynchronous job failures in the job-status response. INVALID_JOB is also a job failure code. Body-size and file-size limits depend on your plan; see tool limits.
Notes¶
- Body mode is synchronous. URL and file modes are asynchronous.
- For file mode, provide the exact storage key associated with the uploaded file.
- Download URLs are temporary, and output retention depends on your plan.