Skip to content

CSV to YAML API

Overview

Converts CSV input to YAML. Submit CSV text synchronously, or submit a URL or uploaded-file reference to start an asynchronous job.

Endpoint

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

Authentication

Include your API key in the x-api-key header on every request.

Input modes

Mode Behavior
body Synchronous processing of raw CSV text. This is the default mode.
url Asynchronous processing of a CSV file at a URL.
file Asynchronous processing of a previously uploaded file.

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 No default API key used to authenticate the request.
x-source-type String No Default: body. Values: body, url, file. Selects the input mode.

Accepted file extensions

For URL and file modes, the input file must use one of these extensions:

  • .txt
  • .csv
  • .log

Request body

Body mode

Send the CSV as raw text in the request body.

column1,column2
value1,value2

URL mode

Send a JSON object with a url property:

{
  "url": "https://example.com/input.csv"
}

File mode

Send a JSON object with a file property. Its value must be the exact storage key associated with a file uploaded through the upload workflow.

{
  "file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}

curl examples

Body mode

curl --request POST \
  --url https://api.apidatatools.com/csv-to-yaml-api \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'x-source-type: body' \
  --data-raw $'column1,column2\nvalue1,value2'

URL mode

curl --request POST \
  --url https://api.apidatatools.com/csv-to-yaml-api \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'x-source-type: url' \
  --data-raw '{"url":"https://example.com/input.csv"}'

File mode

curl --request POST \
  --url https://api.apidatatools.com/csv-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 synchronous response has HTTP status 200. The response shape depends on whether the result is returned as a file or as data.

File-producing response:

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "TEMPORARY_DOWNLOAD_URL",
  "preview": "..."
}

Data-producing response:

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "preview": "SERIALIZED_JSON"
}

Asynchronous URL and file modes

A successful job submission has HTTP status 202:

{
  "status": "accepted",
  "job_id": "JOB_ID",
  "status_url": "https://api.apidatatools.com/jobs/JOB_ID",
  "request_id": "REQUEST_ID"
}

Async job status

Check a submitted job with:

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

Include x-api-key with the request. The job status response includes request_id, job_id, status, created_at, and updated_at. Its additional fields depend on the job status.

For queued and processing:

{
  "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 status value is processing instead of queued when the job is processing.

For success:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1700000000,
  "updated_at": 1700000000,
  "result": {
    "status": "success",
    "file": "TEMPORARY_DOWNLOAD_URL",
    "preview": "..."
  }
}

For failed:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "failed",
  "created_at": 1700000000,
  "updated_at": 1700000000,
  "error": {
    "code": "ERROR_CODE",
    "message": "Error message",
    "details": {
      "message": "Error message"
    }
  }
}

Poll the status URL to check for completion:

curl --request GET \
  --url 'https://api.apidatatools.com/jobs/JOB_ID' \
  --header 'x-api-key: YOUR_API_KEY'

Error handling

Errors use this response envelope. Additional fields may appear in details.

{
  "status": "error",
  "error": "ERROR_CODE",
  "request_id": "REQUEST_ID",
  "details": {
    "message": "Error message"
  }
}

The following HTTP statuses and error codes are defined for this endpoint and its job-status operation:

HTTP status Error codes When it applies
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, DDB_ERROR, JOB_NOT_FOUND, FORBIDDEN Invalid input, source, file or URL; or a job-status lookup error. Job-status tool errors are returned as HTTP 400.
401 UNAUTHORIZED Authentication is missing or invalid.
404 USER_NOT_FOUND, UNKNOWN_FUNCTION The authenticated user or requested endpoint is not found.
413 PAYLOAD_TOO_LARGE, FILE_TOO_LARGE The request body or input file exceeds the applicable plan limit.
429 QUOTA_EXCEEDED, RATE_LIMITED The applicable request quota or rate limit has been reached.
500 PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR Plan configuration or service processing error.

Asynchronous processing can also end in a failed job with codes such as INVALID_JOB, DOWNLOAD_FAILED, FILE_TOO_LARGE, UPLOAD_FAILED, or INTERNAL_ERROR. These are reported in the job’s failed status response; they are not necessarily HTTP errors from the initial job-submission request.

Notes

  • Body mode is synchronous. URL and file modes submit asynchronous jobs.
  • Body-size and file-size limits, quota, rate limits, and download retention depend on the plan. See API limits.
  • Download URLs are temporary; their retention period depends on the plan.
  • URL and file inputs are checked against the accepted file extensions.