Using the Excel to JSON API - Programmatic Access for Developers
Welcome to part 8 of our Excel to JSON series! We’ve covered user-facing tools: Web App, Excel Add-in, and WPS Add-in, along with Pro features. Today, we’re exploring the Excel to JSON API - the perfect solution for developers who need to integrate Excel to JSON functionality into their applications and workflows.
Introduction to Excel to JSON API
The Excel to JSON API provides a powerful, programmatic way to convert Excel data to JSON format. It’s designed for developers who need to:
Automate Excel to JSON conversions in their applications
Integrate conversion capabilities into existing workflows
Process Excel data from web services and APIs
Build custom solutions around Excel to JSON functionality
API Overview
Endpoint
The Excel to JSON API is accessible via a single endpoint:
1
POST https://mcp.wtsolutions.cn/excel-to-json-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
Tab-separated or comma-separated text data with at least two rows (header row + data row). Either ‘data’ or ‘url’ must be provided
url
string
No
URL pointing to an Excel or CSV file. Either ‘data’ or ‘url’ must be provided
# API endpoint url = "https://mcp.wtsolutions.cn/excel-to-json-api"
# Prepare your Excel data with nested structure excel_data = "id\tstudent.name\tstudent.familyname\tstudent.age\n1\tMeimei\tHan\t12\n2\tLily\tJaskson\t15"
# Make request with Pro options response = requests.post( url, json={ "data": excel_data, "options": { "proCode": "your-email@example.com", "jsonMode": "nested", "delimiter": ".", "emptyCell": "null", "booleanFormat": "trueFalse" } }, headers={"Content-Type": "application/json"} )
# Process response result = response.json()
ifnot result["isError"]: json_data = result["data"] print("JSON Data:", json_data) # Save to file withopen("output.json", "w") as f: f.write(json_data) else: print("Error:", result["msg"])
// API endpoint const url = 'https://mcp.wtsolutions.cn/excel-to-json-api';
// Prepare your Excel data with nested structure const excelData = 'id\tstudent.name\tstudent.familyname\tstudent.age\n1\tMeimei\tHan\t12\n2\tLily\tJaskson\t15';
// Make request with Pro options axios.post(url, { data: excelData, options: { proCode: 'your-email@example.com', jsonMode: 'nested', delimiter: '.', emptyCell: 'null', booleanFormat: 'trueFalse' } }, { headers: { 'Content-Type': 'application/json' } }) .then(response => { const result = response.data; if (!result.isError) { console.log('JSON Data:', result.data); // Save to file (Node.js) const fs = require('fs'); fs.writeFileSync('output.json', result.data); } else { console.log('Error:', result.msg); } }) .catch(error => { console.error('Request failed:', error); });
defconvert_with_cache(excel_data): cache_key = get_cache_key(excel_data) if cache_key in cache: return cache[cache_key] # Make API call response = requests.post( 'https://mcp.wtsolutions.cn/excel-to-json-api', json={"data": excel_data} ) result = response.json() # Cache result cache[cache_key] = result return result
Next Steps
Now that you understand how to use the Excel to JSON API programmatically, you’re ready to explore MCP Service integration. In our next post, we’ll cover MCP Service, which provides another way for developers to integrate Excel to JSON functionality into their workflows, particularly for those working with AI and automation tools.
Ready to integrate the API? Start building your Excel to JSON integration today!