Skip to content

XML to YAML API Documentation

Overview

The XML to YAML API converts well-formed XML content into YAML format.
It supports three input modes:

  • Body Mode – Direct XML content in the request body (synchronous).
  • URL Mode – Remote XML file accessible via HTTP/HTTPS (asynchronous).
  • File Mode – Previously uploaded XML file from your account storage (asynchronous).

The API validates XML structure before conversion and returns a downloadable YAML file link.


Endpoint (POST)

POST https://api.apidatatools.com/xml-to-yaml-api

Headers

Header Type Required Description
x-api-key string Yes Your API key for authentication.
x-source-type string No Input mode: body (default), url, or file.
x-tab-space integer No Number of spaces for YAML indentation (default: 4).
Content-Type string Yes Must be application/json for URL/File mode or text/plain for body mode.

Accepted File Extensions

Mode Allowed Extensions
Body .xml, .txt, .log
URL .xml, .txt, .log
File .xml, .txt, .log

Input Example (Body Mode)

<note>
  <to>User</to>
  <from>API</from>
  <message>Hello World</message>
</note>

Input Example (URL Mode)

{
  "url": "https://example.com/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-yaml-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/xml" \
  -H "x-source-type: body" \
  -d'<note><to>User</to><from>API</from><message>Hello</message></note>'

Asynchronous (Remote File URL)

curl -X POST "https://api.apidatatools.com/xml-to-yaml-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-source-type: url" \
  -d '{"url": "https://example.com/data.xml"}'

Asynchronous (Input File)

curl -X POST "https://api.apidatatools.com/xml-to-yaml-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-source-type: file" \
  -d '{"file": "user123/uploads/data.xml"}'

Example Response

Successful (Body Mode)

{
  "status": "success",
  "request_id": "b1a2c3d4-5678-90ef-1234-56789abcdef0",
  "file": "https://downloads.apidatatools.com/apidatatools_convert_abcd1234.yaml",
  "preview": "note:\n  to: User\n  from: API\n  message: Hello\n"
}

Async Job Accepted (URL/File Mode)

{
  "status": "accepted",
  "job_id": "a123b456-c789-012d-ef34-567890abcdef",
  "status_url": "https://api.apidatatools.com/jobs/a123b456-c789-012d-ef34-567890abcdef",
  "request_id": "b1a2c3d4-5678-90ef-1234-56789abcdef0"
}

Error Handling

Error Code HTTP Status Description Example
INVALID_XML 400 XML is malformed or invalid. {"status":"error","error":"INVALID_XML","details":{"message":"XML parsing failed.","line":2,"column":5}}
YAML_SERIALIZATION_FAILED 400 Failed to convert XML to YAML. {"status":"error","error":"YAML_SERIALIZATION_FAILED","details":{"message":"Failed to serialize XML to YAML."}}
INVALID_URL 400 URL missing or invalid. {"status":"error","error":"INVALID_URL","details":{"message":"URL must be valid http/https."}}
URL_UNREACHABLE 400 Remote file could not be reached. {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL."}}
URL_NOT_OK 400 Remote file returned non-200 status. {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}}
INVALID_FILE 400 File path missing or invalid. {"status":"error","error":"INVALID_FILE","details":{"message":"Missing or invalid 'file'."}}
INVALID_FILE_EXTENSION 400 File extension not supported. {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Extension '.pdf' is not allowed."}}
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 exceeds allowed size. {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds 5120KB limit for your plan."}}
UNKNOWN_FUNCTION 404 Invalid endpoint. {"status":"error","error":"UNKNOWN_FUNCTION","details":{"message":"Unsupported API endpoint."}}
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 the status_url provided in the accepted response.

Endpoint

GET https://api.apidatatools.com/jobs/{job_id}

Example Status Response for Async

Queued or Processing

{
  "job_id": "a123b456-c789-012d-ef34-567890abcdef",
  "status": "queued",
  "message": "Your job is being processed.",
  "retry_after": 2,
  "created_at": 1712345678,
  "updated_at": 1712345678
}

Successful

{
  "job_id": "a123b456-c789-012d-ef34-567890abcdef",
  "status": "success",
  "created_at": 1712345678,
  "updated_at": 1712345690,
  "result": {
    "status": "success",
    "file": "https://downloads.apidatatools.com/apidatatools_convert_abcd1234.yaml",
    "request_id": "b1a2c3d4-5678-90ef-1234-56789abcdef0",
    "preview": "note:\n  to: User\n  from: API\n  message: Hello\n"
  }
}

Failed

{
  "job_id": "a123b456-c789-012d-ef34-567890abcdef",
  "status": "failed",
  "created_at": 1712345678,
  "updated_at": 1712345680,
  "error": {
    "code": "INVALID_XML",
    "message": "XML parsing failed.",
    "details": {
      "line": 2,
      "column": 5
    }
  }
}

Notes for Developers

  • The API automatically validates XML before conversion.
  • The YAML output preserves XML structure and order.
  • The preview field in the response contains the first 100 KB of the YAML output.
  • Always store the job_id or status_url for later retrieval.
  • Ensure your plan allows sufficient file size for remote or uploaded files.
  • For URL/File mode, the job is queued and processed asynchronously; use the status endpoint to retrieve results.