XML to CSV API¶
Overview¶
Convert XML input to CSV. Body mode processes the XML synchronously. URL and file modes submit an asynchronous job.
Endpoint¶
POST https://api.apidatatools.com/xml-to-csv-api
Authentication¶
Include your API key in the x-api-key header.
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous. Send the XML document as raw text. |
url | Asynchronous. Send a JSON object containing the URL of the input file. |
file | Asynchronous. Send a JSON object containing the exact storage key returned by the upload workflow. |
Headers¶
Header names are case-insensitive. The lowercase spellings below are used in examples.
| 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: txt, xml, log.
Request body¶
Body mode¶
Send the XML document as raw text. No JSON wrapper is used.
URL mode¶
Send a JSON object with a non-empty url containing an HTTP or HTTPS URL:
{
"url": "https://example.com/input.xml"
}
File mode¶
Send a JSON object with a non-empty file containing the exact storage key associated with an upload:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/xml-to-csv-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: body' \
--data-raw '<root><item>example</item></root>'
URL mode¶
curl -X POST 'https://api.apidatatools.com/xml-to-csv-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-csv-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¶
A successful body-mode request returns HTTP 200 with a JSON response containing request_id, status, file, and preview.
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "CSV preview"
}
The download URL is 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 status endpoint with the returned job_id:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key when polling. A successful status response includes request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps in seconds.
For queued and processing jobs, the response also includes:
{
"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 shape applies when status is processing.
For a successful job, the response includes result, which contains the worker’s success response:
{
"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": "CSV preview"
}
}
For a failed job, the response includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000005,
"error": {
"code": "DOWNLOAD_FAILED",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
The failed-job error.code and details depend on the failure. The status endpoint returns HTTP 400 for status-operation errors such as an invalid job ID, a job that cannot be found, or a job that does not belong to the authenticated user.
Example status request:
curl -X GET 'https://api.apidatatools.com/jobs/JOB_ID' \
-H 'x-api-key: YOUR_API_KEY'
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"
}
}
The following HTTP statuses are defined by the backend for this API and its asynchronous input handling:
| HTTP status | Error codes | When it applies |
|---|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY | Invalid input mode, body encoding, or empty request body. |
400 | INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION | Invalid asynchronous request body, URL or file input, inaccessible URL or file, or unsupported input extension. |
400 | Tool-specific errors | The XML conversion could not be completed for the supplied input. |
400 | INVALID_JOB_ID, DDB_ERROR, JOB_NOT_FOUND, FORBIDDEN | Status endpoint errors. |
401 | UNAUTHORIZED | Authentication is missing or invalid. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | The authenticated user or requested API endpoint was not found. |
413 | PAYLOAD_TOO_LARGE | The synchronous request body exceeds the limit for the plan. |
413 | FILE_TOO_LARGE | The URL or uploaded file exceeds the applicable plan limit. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | The plan’s request quota or rate limit has been reached. |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR | Plan configuration is missing or request processing failed. |
500 | CONFIG_ERROR, PLAN_CONFIG_ERROR | Asynchronous job configuration or plan limits are invalid. |
Asynchronous worker failures, including DOWNLOAD_FAILED, UPLOAD_FAILED, and INVALID_JOB, are reported in the failed job’s status response.
Notes¶
- Body mode is synchronous; URL and file modes are asynchronous.
- Request-body and file-size limits, quotas, rate limits, and download retention depend on your plan. See Tool limits.
- Output download URLs are temporary, and their retention period depends on your plan.