Welcome to part 8 of our JSON to Excel series! We’ve covered the user-facing tools: Web App, Excel Add-in, and WPS Add-in, along with Pro features. Today, we’re exploring the JSON to Excel API - the perfect solution for developers who need to integrate JSON to Excel functionality into their applications and workflows.

Introduction to the JSON to Excel API
The JSON to Excel API provides a powerful, programmatic way to convert JSON data to CSV format (which can be easily imported into Excel). It’s designed for developers who need to:
- Automate JSON to Excel conversions in their applications
- Integrate conversion capabilities into existing workflows
- Process JSON data from web services and APIs
- Build custom solutions around JSON to Excel functionality
API Overview
Endpoint
The JSON to Excel API is accessible via a single endpoint:
1 | POST https://mcp2.wtsolutions.cn/json-to-excel-api |
Two Usage Modes
The API offers two distinct usage modes:
- Standard Mode: Free of charge, with standard conversion rules
- Pro Mode: Requires valid subscription, with custom conversion rules
Standard API Usage
Request Format
The Standard API accepts POST requests with application/json content type containing one of two parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | No | JSON data string to be converted. Must be valid JSON array or object |
| url | string | No | URL pointing to a JSON file. Either ‘data’ or ‘url’ must be provided |
Important: Provide either data or url, not both.
Request Examples
Example 1: Converting JSON Data
Request:
1 | { |
Response:
1 | { |
Example 2: Converting from URL
Request:
1 | { |
Response:
1 | { |
Response Format
The API returns a JSON object with the following structure:
| Field | Type | Description |
|---|---|---|
| isError | boolean | Indicates if there was an error processing the request |
| msg | string | ‘success’ or error description |
| data | string | Converted CSV data string, ‘’ if there was an error |
Error Response Example
1 | { |
Pro API Usage
Request Format
The Pro API accepts POST requests with application/json content type containing:
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | No | JSON data string to be converted. Must be valid JSON array or object |
| url | string | No | URL pointing to a JSON file. Either ‘data’ or ‘url’ must be provided |
| options | object | Yes | Configuration object for customizing the conversion process |
Important:
- Provide either
dataorurl, not both optionsis mandatory for Pro mode- You must have a valid Pro Code to use Pro mode
Options Object
The options object can contain the following properties:
| Property | Type | Default | Description |
|---|---|---|---|
| proCode | string | “” | Pro Code for custom conversion rules. This is mandatory. |
| jsonMode | string | “flat” | Format mode: “nested” or “flat” |
| delimiter | string | “.” | Delimiter for nested JSON keys when using jsonMode: “nested”. Acceptable: “.”, “_”, “__”, “/“ |
| maxDepth | string | “unlimited” | Maximum depth for nested JSON objects when using jsonMode: “nested”. Acceptable: “unlimited”, “1” ~ “20” |
Pro Request Example
Request:
1 | { |
Response:
1 | { |
Implementation Examples
Python Implementation
Standard Mode
1 | import requests |
Pro Mode
1 | import requests |
JavaScript/Node.js Implementation
Standard Mode
1 | const axios = require('axios'); |
Pro Mode
1 | const axios = require('axios'); |
cURL Implementation
Standard Mode
1 | curl -X POST https://mcp2.wtsolutions.cn/json-to-excel-api \ |
Pro Mode
1 | curl -X POST https://mcp2.wtsolutions.cn/json-to-excel-api \ |
Data Type Handling
The API automatically handles different JSON data types:
| JSON Type | CSV Representation |
|---|---|
| Numbers | Numeric values in CSV |
| Booleans | ‘true’/‘false’ strings |
| Strings | Escaped and quoted if necessary |
| Arrays | JSON.stringify array string |
| Objects | JSON.stringify object string (unless using nested mode) |
Error Handling
The API provides descriptive error messages for common issues:
| Error Message | Cause |
|---|---|
| Invalid JSON format | Input data is not valid JSON |
| Empty JSON data | Input data is an empty JSON string |
| Network Error when fetching file | Error downloading file from URL |
| File not found | File at provided URL cannot be found |
| Server Internal Error | Unexpected server error |
| Invalid Pro Code | Pro Code is not valid or expired |
Best Practices for Error Handling
Always Check
isErrorFlag1
2
3
4
5
6if result["isError"]:
# Handle error
print(f"Error: {result['msg']}")
else:
# Process successful response
csv_data = result["data"]Implement Retry Logic
1
2
3
4
5
6
7
8
9
10
11
12
13import time
max_retries = 3
for attempt in range(max_retries):
try:
response = requests.post(url, json=payload)
result = response.json()
if not result["isError"]:
break
except Exception as e:
if attempt < max_retries - 1:
time.sleep(2 ** attempt) # Exponential backoff
else:
raiseLog Errors for Debugging
1
2
3
4
5
6import logging
logging.basicConfig(level=logging.INFO)
if result["isError"]:
logging.error(f"API Error: {result['msg']}")
logging.error(f"Request payload: {payload}")
CORS Considerations
When making requests from a web browser, you may encounter CORS (Cross-Origin Resource Sharing) issues. To handle CORS:
Use a Server-Side Proxy
- Make API calls from your server, not directly from the browser
- Your server forwards requests to JSON to Excel API
- Client communicates with your server
Configure CORS Headers
- Ensure your server properly handles CORS
- Set appropriate headers for cross-origin requests
Use Cases
Use Case 1: Automated Report Generation
1 | import requests |
Use Case 2: Web Service Integration
1 | // Express.js endpoint that converts JSON to Excel |
Use Case 3: Data Pipeline Integration
1 | import requests |
Performance Considerations
Rate Limiting
Be mindful of API rate limits:
- Implement appropriate delays between requests
- Use caching for repeated conversions
- Batch requests when possible
Large Data Handling
For large JSON datasets:
- Consider splitting data into smaller chunks
- Process asynchronously to avoid blocking
- Implement progress tracking for long-running conversions
Caching Strategy
Cache conversion results to avoid redundant API calls:
1 | import hashlib |
Next Steps
Now that you understand how to use the JSON to Excel API programmatically, you’re ready to explore the MCP Server integration. In our next post, we’ll cover the MCP Server, which provides another way for developers to integrate JSON to Excel functionality into their workflows, particularly for those working with AI and automation tools.
Ready to integrate the API into your application? Start building your JSON to Excel integration today!