YAML Validator API Documentation¶
Overview¶
The YAML Validator API validates YAML content and returns a pretty-printed version of the input.
It supports single and multi-document YAML files and ensures proper indentation.
If the YAML is invalid, it returns detailed error information including line and column numbers.
This API supports synchronous (body mode) and asynchronous (URL or file mode) operations.
Base URL:
https://api.apidatatools.com/yaml-validator-api
Endpoint (POST)¶
POST https://api.apidatatools.com/yaml-validator-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
Content-Type | application/x-yaml or text/plain | Yes | Specifies the content type of the input. |
x-tab-space | Integer | No | Controls indentation spaces in the pretty-printed YAML. Default is 4. |
x-source-type | String | No | Defines the input source type: body, url, or file. Default is body. |
x-api-key | String | Yes | abcd1234xyz |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| URL / File | .yml, .yaml, .txt, .log |
Input Example (Body Mode)¶
name: John Doe
age: 30
skills:
- Python
- YAML
Input Example (URL Mode)¶
{
"url": "https://example.com/sample.yaml"
}
Input Example (File Mode)¶
{
"file": "user_uploads/sample.yaml"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/yaml-validator-api" \
-H "Content-Type: text/plain" \
-H "x-source-type: body" \
-H "x-api-key: YOUR_API_KEY" \
-d 'name: John\nage: 30\nskills:\n - Python\n - YAML'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/yaml-validator-api" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url": "https://example.com/sample.yaml"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/yaml-validator-api" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"file": "user_uploads/sample.yaml"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "b3f9e2c1-4a2e-4d7f-9a8f-7e3b2a1f9cde",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.yaml",
"preview": "name: John Doe\nage: 30\nskills:\n - Python\n - YAML\n"
}
Async Job Accepted (URL or File Mode)¶
{
"status": "accepted",
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status_url": "https://api.apidatatools.com/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"request_id": "b3f9e2c1-4a2e-4d7f-9a8f-7e3b2a1f9cde"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_YAML | 400 | YAML syntax is invalid. | { "status": "error", "error": "INVALID_YAML", "details": { "message": "YAML validation failed.", "line": 3, "column": 5 } } |
YAML_SERIALIZATION_FAILED | 400 | Failed to pretty-print YAML. | { "status": "error", "error": "YAML_SERIALIZATION_FAILED", "details": { "message": "Failed to pretty-print YAML." } } |
INVALID_URL | 400 | URL is missing or invalid. | { "status": "error", "error": "INVALID_URL", "details": { "message": "Missing or invalid 'url'." } } |
URL_UNREACHABLE | 400 | The provided URL could not be reached. | { "status": "error", "error": "URL_UNREACHABLE", "details": { "message": "Could not reach URL." } } |
URL_NOT_OK | 400 | URL returned a non-200 HTTP status. | { "status": "error", "error": "URL_NOT_OK", "details": { "message": "URL returned HTTP 404, expected 200." } } |
FILE_TOO_LARGE | 413 | File exceeds plan limit. | { "status": "error", "error": "FILE_TOO_LARGE", "details": { "message": "Remote file exceeds plan limit." } } |
INVALID_FILE | 400 | File path is 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": "Invalid or unsupported file extension." } } |
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." } } |
INTERNAL_ERROR | 500 | Unexpected internal 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 returned in the accepted response.
Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued or Processing¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "queued",
"message": "Your job is being processed.",
"retry_after": 2,
"created_at": 1712345678,
"updated_at": 1712345678
}
Successful¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"request_id": "b3f9e2c1-4a2e-4d7f-9a8f-7e3b2a1f9cde",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.yaml",
"preview": "name: John Doe\nage: 30\nskills:\n - Python\n - YAML\n"
}
}
Failed¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "INVALID_YAML",
"message": "YAML validation failed.",
"details": {
"line": 3,
"column": 5
}
}
}
Notes for Developers¶
-
The API supports three input modes:
-
Body Mode: Direct YAML text in the request body (synchronous).
- URL Mode: Remote YAML file via public HTTP/HTTPS URL (asynchronous).
-
File Mode: YAML file uploaded to the platform (asynchronous).
-
For asynchronous operations, a
job_idis returned. Use thestatus_urlto poll job status. -
The
x-tab-spaceheader controls indentation in the output YAML. Invalid values are ignored, defaulting to 4 spaces. -
The response always includes a
request_idfor traceability. -
Output files are temporarily stored and accessible via a secure download link.
-
Ensure that input files conform to the allowed extensions for this tool (
.yml,.yaml,.txt,.log).