API Overview
The SphereChat API provides a comprehensive REST interface for integrating AI-powered document processing, chat, and content generation capabilities into your applications.
Base URL
https://spherechat.sphereskill.tech:1082
API Version
Current Version: v1
Key Features
- PDF Document Processing: Extract data from invoices, purchase orders, delivery challans, and e-way bills
- Excel Export: Convert PDF documents to structured Excel files
- AES 256-bit Encryption: Secure API keys and optional request/response payload encryption
- AI Chat Integration: Multi-modal AI chat with various models
- Content Generation: Generate images, videos, voice, music, and presentations
- Batch Processing: Process multiple documents simultaneously
Response Format
All API responses are in JSON format unless specified otherwise. File downloads return binary content with appropriate MIME types.
Rate Limiting
API requests are rate-limited to ensure fair usage. Current limits:
- PDF Processing: 100 requests per hour per API key
- Chat API: 1000 requests per hour per API key
- Generation API: 50 requests per hour per API key
Authentication
SphereChat API uses Bearer token authentication with optional AES 256-bit encryption for enhanced security.
Bearer Token Authentication
Include your API token in the Authorization header:
Authorization: Bearer YOUR_API_TOKEN
AES 256-bit Encryption
For enhanced security, API keys are encrypted using AES-256-CBC encryption before storage. The encryption service provides:
- Key Encryption: API keys are encrypted at rest using AES-256-CBC
- Request Encryption: Optional end-to-end encryption for request payloads
- Response Encryption: Optional encryption for response payloads
- IV Generation: Unique Initialization Vector for each encryption
- HMAC Verification: SHA256-based integrity verification
Getting Your API Key
- Register an account on SphereChat platform
- Navigate to API Settings in your dashboard
- Generate a new API key
- The key will be encrypted and stored securely
- Use the key in your Authorization header
Example Request with Authentication
curl -X POST https://spherechat.sphereskill.tech:1082/api/pdf/invoice \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file=@invoice.pdf"
POST
/api/pdf/invoice
Upload and process a PDF invoice. Extracts data and converts to Excel format.
Request
Content-Type: multipart/form-data
Parameters:
file (required): PDF invoice file
Response
{
"success": true,
"message": "PDF processed successfully",
"fileId": "abc123xyz",
"fileName": "invoice_extracted.xlsx",
"excelPath": "/path/to/excel",
"fileSize": 45678
}
Use Cases
- Automated invoice processing for accounting systems
- Data extraction for ERP integration
- Bulk invoice processing workflows
- Document management system integration
Integration Examples
JavaScript/Fetch:
const formData = new FormData();
formData.append('file', fileInput.files[0]);
fetch('https://spherechat.sphereskill.tech:1082/api/pdf/invoice', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
},
body: formData
})
.then(response => response.json())
.then(data => console.log(data));
GET
/api/pdf/download/{fileId}
Download the processed Excel file using the fileId returned from the upload endpoint.
Parameters
fileId (path parameter, required): The file ID returned from the upload endpoint
Response
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Returns the Excel file as a binary download.
Use Cases
- Retrieve extracted data for further processing
- Integrate with workflow automation systems
- Download processed files for user access
- Webhook-triggered file downloads
Integration Examples
cURL:
curl -X GET \
"https://spherechat.sphereskill.tech:1082/api/pdf/download/abc123xyz" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-o invoice_extracted.xlsx
POST
/api/pdf/po
Process Purchase Order PDF documents. Similar to invoice processing.
POST
/api/pdf/dc
Process Delivery Challan PDF documents.
POST
/api/pdf/ewaybill
Process E-Way Bill PDF documents.
Integration Guide
Use Cases
Automated Invoice Processing
Integrate with accounting systems to automatically process invoices and extract data for bookkeeping.
ERP System Integration
Connect with ERP systems to import invoice data directly into your business management platform.
Document Workflow Automation
Automate document processing workflows with webhook notifications and batch processing.
Bulk Data Extraction
Process multiple documents simultaneously and extract structured data for analysis.
Real-time Processing
Process documents in real-time with synchronous API calls for immediate results.
Cloud Integration
Integrate with cloud storage services for seamless document processing pipelines.
Collaboration Possibilities
- Webhook Integration: Receive notifications when document processing is complete
- REST API: Synchronous processing with immediate response
- Batch Processing: Process multiple files in a single request
- SDK Support: Client libraries for popular programming languages (coming soon)
- Rate Limiting: Fair usage quotas to ensure service availability
- Error Handling: Comprehensive error codes and retry logic
Online Integration Examples
Python Example
import requests
url = "https://spherechat.sphereskill.tech:1082/api/pdf/invoice"
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
with open("invoice.pdf", "rb") as f:
files = {"file": f}
response = requests.post(url, headers=headers, files=files)
data = response.json()
print(f"File ID: {data['fileId']}")
# Download the Excel file
download_url = f"https://spherechat.sphereskill.tech:1082/api/pdf/download/{data['fileId']}"
excel_response = requests.get(download_url, headers=headers)
with open("invoice_extracted.xlsx", "wb") as f:
f.write(excel_response.content)
cURL Example
# Upload invoice
curl -X POST \
"https://spherechat.sphereskill.tech:1082/api/pdf/invoice" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file=@invoice.pdf"
# Download Excel
curl -X GET \
"https://spherechat.sphereskill.tech:1082/api/pdf/download/FILE_ID" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-o invoice.xlsx
Error Handling
All API errors follow a consistent format:
{
"success": false,
"message": "Error description",
"error": "Detailed error information"
}
Common HTTP status codes:
- 200: Success
- 400: Bad Request (invalid parameters)
- 401: Unauthorized (invalid or missing API key)
- 404: Not Found (file or resource not found)
- 500: Internal Server Error
Postman Collection
Import our Postman collection for easy API testing:
https://spherechat.sphereskill.tech/api/postman-collection.json
OpenAPI Specification
Download the complete OpenAPI 3.0 specification:
https://spherechat.sphereskill.tech:1082/swagger/v1/swagger.json