Documentación API
Acceso programático a los servicios de conversión de archivos de Convertastic
Descripción General
La API de Convertastic proporciona endpoints RESTful para convertir archivos entre varios formatos. Todas las solicitudes deben incluir encabezados de autenticación apropiados y seguir el formato de solicitud/respuesta documentado.
URL Base
https://convertastic.replit.app/api/v1
Tipo de Contenido
multipart/form-data
Endpoints de API
GET Verificación de Estado
/api/v1/health
Check API status and availability
Example Response
{
"success": true,
"message": "API is healthy",
"data": {
"version": "1.0",
"timestamp": "2025-07-21T16:00:00Z",
"status": "operational"
},
"timestamp": "2025-07-21T16:00:00Z"
}
GET Supported Formats
/api/v1/formats
Get list of all supported file formats and conversion options
Example Response
{
"success": true,
"message": "Supported formats retrieved successfully",
"data": {
"formats": [
{
"format": "png",
"category": "image",
"description": "Image format",
"can_convert_to": ["jpg", "webp", "pdf", "bmp"],
"can_convert_from": ["png", "jpg", "jpeg", "webp"]
}
]
}
}
POST Convert File
/api/v1/convert
Convert a file from one format to another
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file |
File | Yes | The file to convert (max 100MB) |
target_format |
String | Yes | Target format (e.g., "jpg", "pdf", "mp3") |
quality |
String | No | Quality setting: "low", "medium", "high" (default: "medium") |
Example Request
curl -X POST https://convertastic.replit.app/api/v1/convert \
-F "file=@image.png" \
-F "target_format=jpg" \
-F "quality=high"
Example Response
{
"success": true,
"message": "File converted successfully",
"data": {
"conversion_id": "abc123-def456-ghi789",
"original_filename": "image.png",
"original_format": "png",
"target_format": "jpg",
"file_size": 245760,
"conversion_time": 1.23,
"download_url": "/api/v1/download/abc123-def456-ghi789",
"expires_at": "2025-07-21T16:30:00Z"
}
}
GET Download Converted File
/api/v1/download/{conversion_id}
Download the converted file using the conversion ID
Example Request
curl -X GET https://convertastic.replit.app/api/v1/download/abc123-def456-ghi789 \
-o converted_file.jpg
GET Conversion Status
/api/v1/status/{conversion_id}
Check the status of a conversion
Example Response
{
"success": true,
"message": "Status retrieved successfully",
"data": {
"conversion_id": "abc123-def456-ghi789",
"status": "ready",
"expires_at": "2025-07-21T16:30:00Z",
"download_url": "/api/v1/download/abc123-def456-ghi789"
}
}
Status Values
processing
- Conversion in progressready
- File ready for downloadexpired
- File has expirednot_found
- Conversion not found
Error Handling
All API responses follow a consistent format. Errors include appropriate HTTP status codes and descriptive messages.
Error Response Format
{
"success": false,
"message": "Error description",
"error": "Detailed error message",
"timestamp": "2025-07-21T16:00:00Z"
}
Common HTTP Status Codes
Code | Description |
---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
404 | Not Found - Resource not found |
413 | Payload Too Large - File exceeds 100MB |
500 | Internal Server Error |
SDK Examples
Python
import requests
# Convert a file
with open('image.png', 'rb') as f:
response = requests.post('https://convertastic.replit.app/api/v1/convert',
files={'file': f},
data={'target_format': 'jpg', 'quality': 'high'})
if response.status_code == 200:
result = response.json()
conversion_id = result['data']['conversion_id']
# Download converted file
download_response = requests.get(f'https://convertastic.replit.app/api/v1/download/{conversion_id}')
with open('converted_image.jpg', 'wb') as f:
f.write(download_response.content)
JavaScript
// Convert a file
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('target_format', 'jpg');
formData.append('quality', 'high');
fetch('https://convertastic.replit.app/api/v1/convert', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
const downloadUrl = data.data.download_url;
// Create download link
const a = document.createElement('a');
a.href = 'https://convertastic.replit.app/' + downloadUrl;
a.download = 'converted_file';
a.click();
}
});