Skip to content

CSV to JSON API

Overview

Convert CSV text to JSON. The endpoint accepts input directly in the request body or asynchronously from a URL or a previously uploaded file.

Endpoint

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

Authentication

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

Input modes

  • Body — Send CSV text in the request body. Processing is synchronous.
  • URL — Send a JSON object containing a URL. Processing is asynchronous.
  • File — Send a JSON object containing a file reference returned by the upload workflow. Processing is asynchronous.

Headers

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. Header names are case-insensitive.

Accepted file extensions

For URL and file modes, the input file must use one of these extensions: .txt, .csv, or .log.

Request body

Body mode

Send raw CSV text as the request body. For example:

name,age
Ada,36
Linus,54

URL mode

Send a JSON object with a url field:

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

File mode

Send a JSON object with a file field. Use the exact storage key associated with the file uploaded through the upload workflow.

{
  "file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}

curl examples

Body mode

curl -X POST "https://api.apidatatools.com/csv-to-json-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: body" \
  -H "Content-Type: text/plain" \
  --data-raw $'name,age\nAda,36\nLinus,54'

URL mode

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

File mode

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

Success responses

Synchronous body-mode response

Body mode returns HTTP 200. A data-producing success has a request_id, a status, and a preview containing serialized JSON.

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

Asynchronous URL- or file-mode response

URL and file modes return HTTP 202 when the job is accepted.

{
  "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 the job is accepted:

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

Include x-api-key on the request. The status response includes request_id, job_id, status, created_at, and updated_at. The shapes below show the additional fields for each state.

Queued or processing

Both states include a message and retry_after:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "queued",
  "created_at": 0,
  "updated_at": 0,
  "message": "Your job is being processed.",
  "retry_after": 2
}

status is queued or processing, as applicable.

Success

A completed job includes its result under result:

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

Failed

A failed job includes an error object:

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

Error handling

Error responses use this envelope. Additional fields may appear in details.

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

The following HTTP statuses are established by the endpoint and job-input handling:

HTTP status Error codes When it applies
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY Invalid source type, 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 or input, unreachable or unsuccessful URL, unavailable file, or unsupported extension.
401 UNAUTHORIZED Authentication context is missing or invalid.
404 USER_NOT_FOUND, UNKNOWN_FUNCTION User or synchronous API endpoint was not found.
413 PAYLOAD_TOO_LARGE, FILE_TOO_LARGE Request body or input file exceeds the applicable plan limit.
429 QUOTA_EXCEEDED, RATE_LIMITED Plan quota or rate limit was reached.
500 PLAN_NOT_FOUND, INTERNAL_ERROR, CONFIG_ERROR, PLAN_CONFIG_ERROR Plan configuration, service configuration, or request processing failed.

Job-status lookup can also return INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, or DDB_ERROR; these are returned as tool errors with HTTP 400 by the status endpoint. Asynchronous jobs can end in failure with codes including INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, FILE_TOO_LARGE, or INTERNAL_ERROR. These codes appear in the failed job’s error object; they do not describe the HTTP status of the original accepted request.

Notes

  • Body-size, file-size, quota, rate, and output-retention limits depend on your plan. See tool limits.
  • Download URLs are temporary; retention is plan-dependent.