JSON to YAML API¶
Overview¶
Convert JSON text to YAML. Send JSON text directly for synchronous body-mode conversion, or submit a URL or pre-uploaded file for asynchronous conversion.
Endpoint¶
| Method | URL |
|---|---|
POST | https://api.apidatatools.com/json-to-yaml-api |
Authentication¶
Include your API key in the x-api-key header.
x-api-key: YOUR_API_KEY
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous conversion. |
url | Asynchronous conversion from a URL. |
file | Asynchronous conversion from a pre-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 | None | Your API key. |
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.json.log
Request body¶
Body mode¶
Send raw JSON text as the request body. Body mode is synchronous.
{"name":"Ada","active":true}
URL mode¶
Send a JSON object containing the input URL. URL mode is asynchronous.
{"url":"https://example.com/input.json"}
File mode¶
Send a JSON object containing the exact storage key returned by the upload workflow. Do not add a prefix to the key. File mode is asynchronous.
{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}
curl examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/json-to-yaml-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: body' \
--data-raw '{"name":"Ada","active":true}'
URL mode¶
curl -X POST 'https://api.apidatatools.com/json-to-yaml-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: url' \
--data-raw '{"url":"https://example.com/input.json"}'
File mode¶
curl -X POST 'https://api.apidatatools.com/json-to-yaml-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 conversion returns HTTP 200 with a file URL and preview.
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "..."
}
Asynchronous URL and file modes¶
A successful job submission 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 URL returned when submitting a URL or file job:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key on the status request. The status response includes request_id, job_id, status, created_at, and updated_at.
For a queued or processing job, the response also includes a message and retry interval:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 1710000000,
"updated_at": 1710000000,
"message": "Your job is being processed.",
"retry_after": 2
}
For a successful job, the response includes result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1710000000,
"updated_at": 1710000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "..."
}
}
For a failed job, the response includes error:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1710000000,
"updated_at": 1710000002,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {}
}
}
Error handling¶
Errors use this envelope. details may contain additional fields.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
The following HTTP statuses are established for these errors:
| HTTP status | Error codes / conditions |
|---|---|
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, and input-validation errors raised during conversion. |
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 |
Asynchronous job failures can also report INVALID_JOB, DOWNLOAD_FAILED, or UPLOAD_FAILED in the job status response. These are job error codes, not HTTP statuses for the initial submission.
Notes¶
- Body-size, file-size, quota, rate, and output-retention limits depend on your plan. See tool limits.
- Output download URLs are temporary; retention depends on your plan.
- URL and file submissions are asynchronous. Poll the returned
status_urlto check job progress and retrieve the result.