JSON to CSV API¶
Overview¶
Convert JSON input to CSV. Body mode processes the request synchronously. URL and file modes submit an asynchronous job; retrieve its status and result from the job status endpoint.
Endpoint¶
POST https://api.apidatatools.com/json-to-csv-api
Authentication¶
Include your API key in the x-api-key header on every request.
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous conversion of JSON text sent in the request body. |
url | Asynchronous conversion of a file at a URL. |
file | Asynchronous conversion of a previously uploaded file. |
Headers¶
Header names are case-insensitive. The spellings below are the documented lowercase forms.
| 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¶
For URL and file modes, the input file must use one of these extensions:
txtjsonlog
File-size limits depend on your plan. See tool limits.
Request body¶
Body mode¶
Send the JSON document as raw text in the request body. Do not wrap it in a url or file object.
URL mode¶
Send a JSON object with a url property:
{
"url": "https://example.com/input.json"
}
The URL must use HTTP or HTTPS.
File mode¶
Send a JSON object with a file property. Its value must be the exact storage key returned by the upload workflow:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl -X POST "https://api.apidatatools.com/json-to-csv-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
--data-raw '[{"name":"Ada","role":"Engineer"},{"name":"Lin","role":"Designer"}]'
URL mode¶
curl -X POST "https://api.apidatatools.com/json-to-csv-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-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 file-producing conversion returns HTTP 200 with request_id, status, file, and preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/TEMPORARY_DOWNLOAD_URL",
"preview": "CSV preview"
}
The download URL is temporary. File retention depends on your plan; see tool limits.
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 URL returned when the job was accepted:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key when polling. For example:
curl -X GET "https://api.apidatatools.com/jobs/JOB_ID" \
-H "x-api-key: YOUR_API_KEY"
The status response includes request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps. The remaining fields depend on the job state.
Queued¶
{
"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
}
Processing¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "processing",
"created_at": 1700000000,
"updated_at": 1700000001,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/TEMPORARY_DOWNLOAD_URL",
"preview": "CSV preview"
}
}
Failed¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000002,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
The details object may contain additional error information.
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 defined for these errors:
| HTTP status | Error codes |
|---|---|
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 |
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 |
Conversion errors are also returned as HTTP 400; their codes depend on the input and conversion error.
For asynchronous jobs, DOWNLOAD_FAILED and UPLOAD_FAILED are job failure codes, not documented HTTP statuses. Check the job status response for these failures.
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.
- Download URLs are temporary; retention depends on your plan.