JSON Minify API¶
Overview¶
The JSON Minify API accepts JSON text and returns the minified result. It supports synchronous body input and asynchronous input from a URL or a pre-uploaded file.
Endpoint¶
POST https://api.apidatatools.com/json-minify-api
Authentication¶
Include your API key in the x-api-key header. The same authentication header is required when checking an asynchronous job’s status.
Input modes¶
Set x-source-type to select an input mode:
| Mode | Behavior |
|---|---|
body | Synchronous. Send JSON text as the request body. This is the default mode. |
url | Asynchronous. Send a JSON object containing the URL of the input file. |
file | Asynchronous. Send a JSON object containing the exact storage key returned by the upload workflow. |
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 accepted extensions are .txt, .json, and .log.
Request body¶
Body mode¶
Send JSON text as the raw request body. The body must not be empty.
URL mode¶
Send a JSON object with a url field:
{
"url": "https://example.com/input.json"
}
The URL must be valid and use HTTP or HTTPS.
File mode¶
Send a JSON object with a file field. 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-minify-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-minify-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-minify-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 synchronous request returns HTTP 200. A file-producing response has this shape:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "..."
}
A data-producing response has this shape:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "{\"result\":\"...\"}"
}
For a data-producing response, preview contains serialized JSON.
Asynchronous URL and file modes¶
A successfully accepted asynchronous request 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¶
Check a job with an authenticated GET request:
GET https://api.apidatatools.com/jobs/{job_id}
curl "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. When a job is queued or processing, it also includes the processing message and retry interval:
{
"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
}
For a job with status processing, the same fields are returned with "status": "processing".
A successful job includes its result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000002,
"result": {
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "..."
}
}
A failed job includes its error code, message, and details:
{
"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"
}
}
}
Error handling¶
Error responses use this envelope. Additional fields may be included in details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error"
}
}
The following HTTP statuses and error codes are grounded in the API behavior:
| 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 input, source type, URL, or file; unreachable or unsuccessful URL checks; or an unsupported file extension. |
400 | INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR | Job status request has no job ID, the job does not exist, the requester does not own the job, or the job lookup fails. |
400 | Tool-specific errors | A tool execution error. The specific error code depends on the tool response. |
401 | UNAUTHORIZED | Authentication context is missing or invalid. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | The authenticated user cannot be found, or the requested API endpoint is unsupported. |
413 | PAYLOAD_TOO_LARGE, FILE_TOO_LARGE | The request body or input file exceeds the applicable plan limit. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | The plan quota is exhausted or the request rate limit is exceeded. |
500 | PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR | Plan configuration is unavailable, asynchronous job configuration is missing or invalid, or an internal processing error occurs. |
Asynchronous jobs can also fail with DOWNLOAD_FAILED or UPLOAD_FAILED. These codes are reported in the job’s failed status response; they are not HTTP statuses for the initial job-submission request.
Notes¶
- Body mode is synchronous. URL and file modes are asynchronous.
- Body-size, file-size, quota, rate, and output-retention limits depend on your plan. See API tool limits.
- Download URLs are temporary; their retention period depends on your plan.
- For file mode, use the exact storage key returned by the upload workflow. Do not add a prefix.