JSON to Excel API Documentation¶
Overview¶
The JSON to Excel API converts any valid JSON input into a downloadable Excel (.xlsx) file.
It supports synchronous conversion for direct JSON body input and asynchronous processing for remote files or URLs.
The API validates JSON structure before conversion and returns an Excel file stored securely for download.
Endpoint (POST)¶
POST https://api.apidatatools.com/json-to-excel-api
Headers¶
| Header | Description | Example |
|---|---|---|
Content-Type | Specifies the input type. Must be application/json. | application/json |
x-source-type | Defines input mode: body, url, or file. | body |
x-api-key | Your API key for authentication | Yes |
Accepted File Extensions¶
This tool supports the following input file extensions:
.txt, .json, .log
Input Example (Body Mode)¶
{
"user": {
"id": 101,
"name": "Alice",
"roles": ["admin", "editor"]
},
"active": true
}
Input Example (URL Mode)¶
{
"url": "https://example.com/data/sample.json"
}
Input Example (File Mode)¶
{
"file": "user_uploads/2024/records.json"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/json-to-excel-api" \
-H "Content-Type: application/json" \
-H "x-source-type: body" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"user":{"id":101,"name":"Alice","roles":["admin","editor"]},"active":true}'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/json-to-excel-api" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url":"https://example.com/data/sample.json"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/json-to-excel-api" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"file":"user_uploads/2024/records.json"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "c8f3e2a1-9b2c-4a7b-8e1d-7a3f9c1b2e4f",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xlsx",
"preview": ""
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "job_9f8e7d6c-5b4a-3c2b-1a0f-9e8d7c6b5a4f",
"status_url": "https://api.apidatatools.com/jobs/job_9f8e7d6c-5b4a-3c2b-1a0f-9e8d7c6b5a4f",
"request_id": "c8f3e2a1-9b2c-4a7b-8e1d-7a3f9c1b2e4f"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_JSON | 400 | JSON validation failed or malformed input. | {"status":"error","error":"INVALID_JSON","details":{"message":"Expecting value at line 1 column 1"}} |
EXCEL_CONVERSION_FAILED | 400 | Conversion to Excel failed due to invalid structure. | {"status":"error","error":"EXCEL_CONVERSION_FAILED","details":{"message":"Excel conversion failed"}} |
EMPTY_BODY | 400 | Request body is empty. | {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}} |
INVALID_BODY_ENCODING | 400 | Failed to decode Base64 body. | {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode request body."}} |
FILE_TOO_LARGE | 413 | File exceeds plan limit. | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}} |
INVALID_URL | 400 | URL is missing or invalid. | {"status":"error","error":"INVALID_URL","details":{"message":"URL must be valid http/https."}} |
URL_UNREACHABLE | 400 | Remote URL cannot be reached. | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}} |
INVALID_FILE_EXTENSION | 400 | Unsupported file extension. | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Extension not allowed"}} |
INTERNAL_ERROR | 500 | Unexpected server 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 provided in the accepted response.
Endpoint¶
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued¶
{
"job_id": "job_9f8e7d6c-5b4a-3c2b-1a0f-9e8d7c6b5a4f",
"status": "queued",
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "job_9f8e7d6c-5b4a-3c2b-1a0f-9e8d7c6b5a4f",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345689,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.xlsx",
"preview": ""
}
}
Failed¶
{
"job_id": "job_9f8e7d6c-5b4a-3c2b-1a0f-9e8d7c6b5a4f",
"status": "failed",
"error": {
"code": "INVALID_JSON",
"message": "JSON validation failed.",
"details": {"line": 1, "column": 2}
}
}
Notes for Developers¶
- The API supports three input modes:
body: Direct JSON text in request body (synchronous).url: Remote file URL (asynchronous).file: Previously uploaded file path (asynchronous).- Each response includes a unique
request_idfor traceability. - For asynchronous operations, a
job_idandstatus_urlare returned. - Use the Status API to poll job progress until completion.
- Output files are stored securely and expire based on plan retention settings.
- Ensure your JSON input is valid and within size limits defined by your plan.
- The Excel output is encoded and stored as
.xlsxwith MIME typeapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet. - Recommended retry interval for async jobs: 2 seconds.