v3.0 Latest

CoreNexis Image CDN API V3

Advanced image processing and delivery through our global CDN with flexible storage options, intelligent compression, and multiple service types including Basic and CDN delivery modes.

File & URL Upload
Flexible Duration
Basic & CDN Types
Smart Compression
Image Resizing
Rate Limiting
Global CDN
All Formats
API V3 Features

This is the latest version of our Image CDN API with enhanced features including intelligent rate limiting, flexible duration options, and advanced image processing capabilities.

CoreNexis Image CDN API V3

The CoreNexis Image CDN API V3 provides advanced image processing and delivery capabilities through our global content delivery network. This latest version introduces enhanced features including intelligent rate limiting, flexible duration options, and multiple service types.

Key Features

  • Dual Upload Methods - Direct file upload or URL-based image processing
  • Service Types - Basic and CDN delivery modes for different use cases
  • Flexible Duration - From 1 hour to permanent storage (0H) based on your plan
  • Intelligent Rate Limiting - Per-client rate control with customizable limits
  • Advanced Image Processing - Smart resizing and compression with quality control
  • Universal Format Support - JPEG, PNG, WebP, GIF, and more
  • Plan-Based Access - Free, trial, and paid plans with different capabilities
  • Global CDN Delivery - Fast content delivery worldwide

Base URL

https://api.corenexis.com/image/cdn/V3

Authentication

All API requests require authentication using a client ID and API key. These credentials determine your access level, plan type, available service types, and usage limits.

Test API Credentials

For testing and development, you can use these sample credentials:

Free Plan (Basic Type Only)

Trial Plan (Basic + CDN Types)

Paid Plan (All Features)

Test Credentials Notice

These are demo credentials with limited quotas for testing only. For production use, contact us to obtain your dedicated API credentials with full access.

Plans & Service Types

Our API offers different plans and service types to meet various needs. Each plan provides different capabilities, storage durations, and access to service types.

Service Types

Type Description Use Case Availability
basic Standard image processing and storage General purpose image hosting, basic web applications All plans
cdn Enhanced CDN delivery with optimized performance High-traffic websites, professional applications Trial & Paid plans only

Plan Comparison

Feature Free Plan Trial Plan Paid Plan
Rate Limit 5 requests/minute 10 requests/minute 20+ requests/minute
Daily Uploads 20 images 50 images 100+ images
Max File Size 24MB 24MB 24MB
Service Types basic only basic, cdn basic, cdn
Duration Options 1H - 48H 1H - 720H 1H - 2160H, 0H
Image Processing βœ… Available βœ… Available βœ… Available
Permanent Storage (0H) ❌ Not available ❌ Not available βœ… Available

Duration Options

Choose how long your images should be stored based on your plan:

  • 1H - 2160H: Hourly storage from 1 hour to 90 days. Custom also available please contact support to increase durations
  • 0H: Permanent storage (no expiry) - Paid plans only
Duration Format

Use format like 1H, 24H, 168H (1 week), or 0H for permanent storage. Decimal values like 0.5H are not supported.

Rate Limits

Our API implements intelligent rate limiting based on your plan and API configuration. Rate limits help ensure fair usage and optimal performance for all users.

Rate Limit Details

Plan Requests per Minute Daily Upload Limit Behavior on Limit
Free Plan 2 requests 20 uploads 429 error with wait time
Trial Plan 5 requests 50 uploads 429 error with wait time
Paid Plan 10+ requests 100+ uploads 429 error with wait time

Rate Limit Headers

When you hit rate limits, the API returns a 429 status with detailed information:

Rate Limit Response
{
    "success": false,
    "message": "Rate limit exceeded. Please wait 14 seconds before making another request. Current limit: 5 requests per minute.",
    "timestamp": "2025-07-05 05:49:05",
    "api_version": "V3",
    "error_code": "RATE_LIMIT_EXCEEDED"
}
Best Practices

Implement exponential backoff when receiving 429 errors. The response includes the exact wait time needed before your next request.

Endpoints

Upload Image

POST https://api.corenexis.com/image/cdn/V3

Upload and process images using either direct file upload or URL-based processing. Supports multiple service types, flexible storage durations, and advanced image processing options.

Request Parameters

Parameter Type Description
client_id Required String Your client ID for authentication
apikey Required String Your API key for authentication
type Required String Service type for processing:
  • basic - Standard processing (all plans)
  • cdn - Enhanced CDN delivery (trial/paid only)
duration Required String Storage duration:
  • 1H to 2160H - Hours (plan-dependent max)
  • 0H - Permanent storage (paid plans only)
image Optional* File Image file to upload (Required if image_url not provided)
image_url Optional* String URL of image to process (Required if image not provided)
width Optional Integer Target width in pixels. Will only resize if target is smaller than original
height Optional Integer Target height in pixels. Will only resize if target is smaller than original
quality Optional Integer Compression quality 40-100. Lower = more compression. Default: 90

* Either image or image_url must be provided, but not both.

Response

Successful requests return a 200 status with detailed processing information:

Success Response Example
{
    "success": true,
    "message": "Image processed successfully",
    "timestamp": "2025-07-05 05:47:06",
    "api_version": "V3",
    "data": {
        "success_id": "rwij48&2H&p&c&i3n9.jpg",
        "dimension": "800*533",
        "compression_applied": true,
        "compression_level": 80,
        "width_apply": true,
        "height_apply": true,
        "plan": "paid",
        "url": "https://cdn.corenexis.com/media/c/rwij48&2H&p&c&i3n9.jpg"
    }
}
No Processing Applied Response
{
    "success": true,
    "message": "Image processed successfully",
    "timestamp": "2025-07-05 05:50:39",
    "api_version": "V3",
    "data": {
        "success_id": "z0peaf&1H&f&c&u0k9.jpg",
        "dimension": "8192*5461",
        "compression_applied": false,
        "compression_level": 0,
        "width_apply": false,
        "height_apply": false,
        "plan": "free",
        "url": "https://cdn.corenexis.com/media/c/z0peaf&1H&f&c&u0k9.jpg"
    }
}

Response Fields Explained

Field Description
success_id Unique identifier for the uploaded image
dimension Final image dimensions in "width*height" format
compression_applied Boolean indicating if compression was applied
compression_level Quality level used (0 if no compression applied)
width_apply Boolean indicating if width resizing was applied
height_apply Boolean indicating if height resizing was applied
plan Plan type used for processing (free/paid)
url Direct CDN URL to access the processed image

Image Processing

Our API provides intelligent image processing capabilities that automatically optimize your images while maintaining quality. All processing supports major image formats including JPEG, PNG, WebP, GIF, and more.

Intelligent Resizing

Smart resizing that only reduces image dimensions when the target size is smaller than the original. This prevents unnecessary quality loss from upscaling.

Key Features:

  • Smart Logic: Only resizes when target is smaller than original
  • Aspect Ratio: Maintains proportions automatically
  • Quality Preservation: Uses advanced algorithms for best results
  • Format Support: Works with all supported image formats
Resize Behavior

If you request 1200px width but the original is only 800px, the API will keep the original size to preserve quality. The response will show width_apply: false.

Resize Example
curl -X POST \
  -F "client_id=000003" \
  -F "apikey=paid_plan_test_key_2024" \
  -F "type=cdn" \
  -F "duration=24H" \
  -F "width=800" \
  -F "height=600" \
  -F "image=@/path/to/large-image.jpg" \
  https://api.corenexis.com/image/cdn/V3

Smart Compression

Advanced compression system that balances file size and quality. The quality parameter ranges from 40 (maximum compression) to 100 (best quality).

Quality Levels Guide:

  • 40-50: Maximum compression, smallest files - Good for thumbnails
  • 60-70: High compression - Good for web previews and social media
  • 75-85: Balanced compression - Recommended for most web use
  • 90-100: Minimal compression, best quality - For professional use

Format-Specific Processing:

  • JPEG: Direct quality control with optimized encoding
  • PNG: Smart compression with alpha channel preservation
  • WebP: Advanced WebP compression for modern browsers
  • GIF: Preserved as-is with animation support
Compression Example
curl -X POST \
  -F "client_id=000002" \
  -F "apikey=trial_plan_test_key_2024" \
  -F "type=basic" \
  -F "duration=48H" \
  -F "quality=70" \
  -F "image_url=https://example.com/large-image.png" \
  https://api.corenexis.com/image/cdn/V3
Combined Processing Example
curl -X POST \
  -F "client_id=000003" \
  -F "apikey=paid_plan_test_key_2024" \
  -F "type=cdn" \
  -F "duration=0H" \
  -F "width=1200" \
  -F "height=800" \
  -F "quality=80" \
  -F "image=@/path/to/image.jpg" \
  https://api.corenexis.com/image/cdn/V3

Client Libraries

Integrate with our API using various programming languages and tools. Below are comprehensive examples showing different upload methods and processing options.

File Upload
URL Upload
With Processing

cURL

Basic File Upload
curl -X POST \
  -F "client_id=000002" \
  -F "apikey=trial_plan_test_key_2024" \
  -F "type=basic" \
  -F "duration=24H" \
  -F "image=@/path/to/your/image.jpg" \
  https://api.corenexis.com/image/cdn/V3

JavaScript

JavaScript File Upload
// File upload with JavaScript
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
  e.preventDefault();
  
  const formData = new FormData();
  formData.append('client_id', '000002');
  formData.append('apikey', 'trial_plan_test_key_2024');
  formData.append('type', 'cdn');
  formData.append('duration', '168H'); // 1 week
  
  // Get file from input element
  const fileInput = document.getElementById('imageFile');
  formData.append('image', fileInput.files[0]);
  
  try {
    const response = await fetch('https://api.corenexis.com/image/cdn/V3', {
      method: 'POST',
      body: formData
    });
    
    const data = await response.json();
    console.log('Upload result:', data);
    
    if (data.success) {
      console.log('βœ… Upload successful!');
      console.log('πŸ”— Image URL:', data.data.url);
      console.log('πŸ“ Dimensions:', data.data.dimension);
      console.log('πŸ—œοΈ Compression applied:', data.data.compression_applied);
      console.log('πŸ“‹ Plan:', data.data.plan);
    } else {
      console.error('❌ Upload failed:', data.message);
    }
  } catch (error) {
    console.error('🚨 Error:', error);
  }
});

Python

Python File Upload
import requests

def upload_image(file_path, client_id, apikey, service_type, duration):
    """
    Upload an image to CoreNexis CDN API V3
    
    Args:
        file_path (str): Path to the local image file
        client_id (str): Your client ID
        apikey (str): Your API key
        service_type (str): 'basic' or 'cdn'
        duration (str): Storage duration (e.g., '24H', '0H')
    
    Returns:
        dict: API response
    """
    url = "https://api.corenexis.com/image/cdn/V3"
    
    # Prepare form data
    files = {
        'image': open(file_path, 'rb')
    }
    
    data = {
        'client_id': client_id,
        'apikey': apikey,
        'type': service_type,
        'duration': duration
    }
    
    try:
        # Make the request
        response = requests.post(url, files=files, data=data)
        
        if response.status_code == 200:
            result = response.json()
            if result['success']:
                print(f"βœ… Upload successful!")
                print(f"πŸ”— Image URL: {result['data']['url']}")
                print(f"πŸ“ Dimensions: {result['data']['dimension']}")
                print(f"πŸ—œοΈ Compression: {result['data']['compression_applied']}")
                print(f"πŸ“‹ Plan: {result['data']['plan']}")
            return result
        else:
            return {
                'success': False,
                'error': f"HTTP {response.status_code}",
                'message': response.text
            }
    except Exception as e:
        return {
            'success': False,
            'error': 'Request failed',
            'message': str(e)
        }
    finally:
        files['image'].close()

# Example usage
if __name__ == "__main__":
    result = upload_image(
        file_path="path/to/image.jpg",
        client_id="000002",
        apikey="trial_plan_test_key_2024",
        service_type="cdn",
        duration="72H"
    )
    
    if not result['success']:
        print(f"❌ Upload failed: {result.get('message', 'Unknown error')}")

PHP

PHP File Upload
<?php
/**
 * Upload an image to CoreNexis CDN API V3
 *
 * @param string $filePath Path to the local image file
 * @param string $clientId Your client ID
 * @param string $apikey Your API key
 * @param string $type Service type ('basic' or 'cdn')
 * @param string $duration Storage duration (e.g., '24H', '0H')
 * @return array API response
 */
function uploadImage($filePath, $clientId, $apikey, $type, $duration) {
    $url = "https://api.corenexis.com/image/cdn/V3";
    
    // Initialize cURL session
    $ch = curl_init();
    
    // Prepare form data
    $postFields = [
        'client_id' => $clientId,
        'apikey' => $apikey,
        'type' => $type,
        'duration' => $duration,
        'image' => new CURLFile($filePath)
    ];
    
    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    
    // Execute the request
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    // Check for errors
    if (curl_errno($ch)) {
        $result = [
            'success' => false,
            'error' => 'cURL Error: ' . curl_error($ch)
        ];
    } else if ($httpCode != 200) {
        $result = [
            'success' => false,
            'error' => "HTTP {$httpCode}",
            'message' => $response
        ];
    } else {
        $result = json_decode($response, true);
        
        if ($result && $result['success']) {
            echo "βœ… Upload successful!\n";
            echo "πŸ”— Image URL: {$result['data']['url']}\n";
            echo "πŸ“ Dimensions: {$result['data']['dimension']}\n";
            echo "πŸ—œοΈ Compression: " . ($result['data']['compression_applied'] ? 'Yes' : 'No') . "\n";
            echo "πŸ“‹ Plan: {$result['data']['plan']}\n";
        }
    }
    
    // Close cURL session
    curl_close($ch);
    
    return $result;
}

// Example usage
$result = uploadImage(
    '/path/to/image.jpg',
    '000002',
    'trial_plan_test_key_2024',
    'cdn',
    '48H'
);

if (!$result['success']) {
    echo "❌ Upload failed: " . ($result['message'] ?? 'Unknown error') . "\n";
}
?>

cURL

URL Upload
curl -X POST \
  -F "client_id=000003" \
  -F "apikey=paid_plan_test_key_2024" \
  -F "type=cdn" \
  -F "duration=720H" \
  -F "image_url=https://example.com/image.jpg" \
  https://api.corenexis.com/image/cdn/V3

JavaScript

JavaScript URL Upload
async function uploadImageFromUrl(imageUrl, clientId, apikey, type, duration) {
  const formData = new FormData();
  formData.append('client_id', clientId);
  formData.append('apikey', apikey);
  formData.append('type', type);
  formData.append('duration', duration);
  formData.append('image_url', imageUrl);
  
  try {
    const response = await fetch('https://api.corenexis.com/image/cdn/V3', {
      method: 'POST',
      body: formData
    });
    
    const result = await response.json();
    
    if (result.success) {
      console.log('βœ… URL upload successful!');
      console.log('πŸ”— CDN URL:', result.data.url);
      console.log('πŸ“ Dimensions:', result.data.dimension);
      console.log('πŸ—œοΈ Compression applied:', result.data.compression_applied);
      console.log('⏱️ API Version:', result.api_version);
    } else {
      console.error('❌ Upload failed:', result.message);
      console.error('🚨 Error Code:', result.error_code);
    }
    
    return result;
  } catch (error) {
    console.error('🚨 Request error:', error);
    return { success: false, error: error.message };
  }
}

// Example usage
uploadImageFromUrl(
  'https://example.com/large-image.jpg',
  '000003',
  'paid_plan_test_key_2024',
  'cdn',
  '0H' // Permanent storage
).then(result => {
  console.log('Final result:', result);
});

Python

Python URL Upload
import requests

def upload_image_from_url(image_url, client_id, apikey, service_type, duration):
    """
    Upload an image from URL to CoreNexis CDN API V3
    
    Args:
        image_url (str): URL of the image to upload
        client_id (str): Your client ID
        apikey (str): Your API key
        service_type (str): 'basic' or 'cdn'
        duration (str): Storage duration
    
    Returns:
        dict: API response
    """
    url = "https://api.corenexis.com/image/cdn/V3"
    
    # Prepare form data
    data = {
        'client_id': client_id,
        'apikey': apikey,
        'type': service_type,
        'duration': duration,
        'image_url': image_url
    }
    
    try:
        # Make the request
        response = requests.post(url, data=data, timeout=30)
        
        if response.status_code == 200:
            result = response.json()
            
            if result['success']:
                print(f"βœ… URL upload successful!")
                print(f"πŸ”— CDN URL: {result['data']['url']}")
                print(f"πŸ“ Dimensions: {result['data']['dimension']}")
                print(f"πŸ—œοΈ Compression: {result['data']['compression_applied']}")
                print(f"πŸ“‹ Plan: {result['data']['plan']}")
                print(f"⏱️ Timestamp: {result['timestamp']}")
            else:
                print(f"❌ Upload failed: {result['message']}")
                if 'error_code' in result:
                    print(f"🚨 Error Code: {result['error_code']}")
                    
            return result
        else:
            return {
                'success': False,
                'error': f"HTTP {response.status_code}",
                'message': response.text
            }
    except requests.RequestException as e:
        return {
            'success': False,
            'error': 'Request failed',
            'message': str(e)
        }

# Example usage
if __name__ == "__main__":
    result = upload_image_from_url(
        image_url="https://example.com/sample-image.png",
        client_id="000002",
        apikey="trial_plan_test_key_2024",
        service_type="basic",
        duration="168H"  # 1 week
    )
    
    if not result['success']:
        print(f"❌ Error: {result.get('message', 'Unknown error')}")

PHP

PHP URL Upload
<?php
/**
 * Upload an image from URL to CoreNexis CDN API V3
 *
 * @param string $imageUrl URL of the image to upload
 * @param string $clientId Your client ID
 * @param string $apikey Your API key
 * @param string $type Service type ('basic' or 'cdn')
 * @param string $duration Storage duration
 * @return array API response
 */
function uploadImageFromUrl($imageUrl, $clientId, $apikey, $type, $duration) {
    $url = "https://api.corenexis.com/image/cdn/V3";
    
    // Initialize cURL session
    $ch = curl_init();
    
    // Prepare form data
    $postFields = [
        'client_id' => $clientId,
        'apikey' => $apikey,
        'type' => $type,
        'duration' => $duration,
        'image_url' => $imageUrl
    ];
    
    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    
    // Execute the request
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    // Check for errors
    if (curl_errno($ch)) {
        $result = [
            'success' => false,
            'error' => 'cURL Error: ' . curl_error($ch)
        ];
    } else if ($httpCode != 200) {
        $result = [
            'success' => false,
            'error' => "HTTP {$httpCode}",
            'message' => $response
        ];
    } else {
        $result = json_decode($response, true);
        
        if ($result && $result['success']) {
            echo "βœ… URL upload successful!\n";
            echo "πŸ”— CDN URL: {$result['data']['url']}\n";
            echo "πŸ“ Dimensions: {$result['data']['dimension']}\n";
            echo "πŸ—œοΈ Compression: " . ($result['data']['compression_applied'] ? 'Yes' : 'No') . "\n";
            echo "πŸ“‹ Plan: {$result['data']['plan']}\n";
            echo "⏱️ Timestamp: {$result['timestamp']}\n";
        } else {
            echo "❌ Upload failed: " . ($result['message'] ?? 'Unknown error') . "\n";
            if (isset($result['error_code'])) {
                echo "🚨 Error Code: {$result['error_code']}\n";
            }
        }
    }
    
    // Close cURL session
    curl_close($ch);
    
    return $result;
}

// Example usage
$result = uploadImageFromUrl(
    'https://example.com/sample-image.jpg',
    '000003',
    'paid_plan_test_key_2024',
    'cdn',
    '0H'  // Permanent storage
);

if (!$result['success']) {
    echo "❌ Error: " . ($result['message'] ?? 'Unknown error') . "\n";
}
?>

cURL with Advanced Processing

Full Processing Example
# Resize + Compression + CDN delivery
curl -X POST \
  -F "client_id=000003" \
  -F "apikey=paid_plan_test_key_2024" \
  -F "type=cdn" \
  -F "duration=2160H" \
  -F "width=1200" \
  -F "height=800" \
  -F "quality=75" \
  -F "image=@/path/to/large-image.jpg" \
  https://api.corenexis.com/image/cdn/V3
# High compression for thumbnails
curl -X POST \
  -F "client_id=000002" \
  -F "apikey=trial_plan_test_key_2024" \
  -F "type=basic" \
  -F "duration=24H" \
  -F "width=300" \
  -F "quality=50" \
  -F "image_url=https://example.com/original.png" \
  https://api.corenexis.com/image/cdn/V3
# Professional quality with minimal compression
curl -X POST \
  -F "client_id=000003" \
  -F "apikey=paid_plan_test_key_2024" \
  -F "type=cdn" \
  -F "duration=0H" \
  -F "width=1920" \
  -F "height=1080" \
  -F "quality=95" \
  -F "image=@/path/to/professional-photo.jpg" \
  https://api.corenexis.com/image/cdn/V3

JavaScript with Advanced Processing

JavaScript Processing Example
async function uploadWithAdvancedProcessing(file, options = {}) {
  const formData = new FormData();
  formData.append('client_id', options.clientId || '000003');
  formData.append('apikey', options.apikey || 'paid_plan_test_key_2024');
  formData.append('type', options.type || 'cdn');
  formData.append('duration', options.duration || '168H');
  formData.append('image', file);
  
  // Add processing options
  if (options.width) formData.append('width', options.width);
  if (options.height) formData.append('height', options.height);
  if (options.quality) formData.append('quality', options.quality);
  
  try {
    console.log('πŸš€ Starting upload with processing...');
    const response = await fetch('https://api.corenexis.com/image/cdn/V3', {
      method: 'POST',
      body: formData
    });
    
    const result = await response.json();
    
    if (result.success) {
      console.log('βœ… Upload and processing successful!');
      console.log('πŸ”— CDN URL:', result.data.url);
      console.log('πŸ“ Final dimensions:', result.data.dimension);
      
      // Show processing details
      const data = result.data;
      console.log('πŸ“Š Processing Results:');
      console.log(`   πŸ“ Width applied: ${data.width_apply ? 'Yes' : 'No'}`);
      console.log(`   πŸ“ Height applied: ${data.height_apply ? 'Yes' : 'No'}`);
      console.log(`   πŸ—œοΈ Compression applied: ${data.compression_applied ? 'Yes' : 'No'}`);
      if (data.compression_applied) {
        console.log(`   🎚️ Quality level used: ${data.compression_level}`);
      }
      console.log(`   πŸ“‹ Plan: ${data.plan}`);
      console.log(`   πŸ†” Success ID: ${data.success_id}`);
    } else {
      console.error('❌ Upload failed:', result.message);
      if (result.error_code) {
        console.error('🚨 Error Code:', result.error_code);
      }
    }
    
    return result;
  } catch (error) {
    console.error('🚨 Request failed:', error);
    return { success: false, error: error.message };
  }
}

// Usage examples for different scenarios
document.getElementById('fileInput').addEventListener('change', async (e) => {
  const file = e.target.files[0];
  if (!file) return;
  
  // Example 1: Web optimization
  await uploadWithAdvancedProcessing(file, {
    type: 'cdn',
    duration: '720H',
    width: 1200,
    quality: 80
  });
  
  // Example 2: Thumbnail creation
  await uploadWithAdvancedProcessing(file, {
    type: 'basic',
    duration: '24H',
    width: 300,
    height: 300,
    quality: 60
  });
  
  // Example 3: High-quality permanent storage
  await uploadWithAdvancedProcessing(file, {
    type: 'cdn',
    duration: '0H',
    quality: 95
  });
});

Python with Advanced Processing

Python Processing Example
import requests
from typing import Optional

def upload_with_processing(
    file_path: str,
    client_id: str,
    apikey: str,
    service_type: str = 'cdn',
    duration: str = '168H',
    width: Optional[int] = None,
    height: Optional[int] = None,
    quality: Optional[int] = None
):
    """
    Upload image with advanced processing options
    
    Args:
        file_path: Path to the image file
        client_id: Your client ID
        apikey: Your API key
        service_type: 'basic' or 'cdn'
        duration: Storage duration (e.g., '24H', '0H')
        width: Target width for resizing
        height: Target height for resizing
        quality: Compression quality (40-100)
    """
    url = "https://api.corenexis.com/image/cdn/V3"
    
    files = {'image': open(file_path, 'rb')}
    data = {
        'client_id': client_id,
        'apikey': apikey,
        'type': service_type,
        'duration': duration
    }
    
    # Add processing parameters if specified
    if width: data['width'] = width
    if height: data['height'] = height
    if quality: data['quality'] = quality
    
    try:
        print(f"πŸš€ Uploading {file_path} with processing...")
        response = requests.post(url, files=files, data=data, timeout=30)
        
        if response.status_code == 200:
            result = response.json()
            
            if result['success']:
                data_obj = result['data']
                print(f"βœ… Upload successful!")
                print(f"πŸ”— CDN URL: {data_obj['url']}")
                print(f"πŸ“ Final dimensions: {data_obj['dimension']}")
                print(f"πŸ“Š Processing Results:")
                print(f"   πŸ“ Width applied: {'Yes' if data_obj['width_apply'] else 'No'}")
                print(f"   πŸ“ Height applied: {'Yes' if data_obj['height_apply'] else 'No'}")
                print(f"   πŸ—œοΈ Compression applied: {'Yes' if data_obj['compression_applied'] else 'No'}")
                
                if data_obj['compression_applied']:
                    print(f"   🎚️ Quality level: {data_obj['compression_level']}")
                
                print(f"   πŸ“‹ Plan: {data_obj['plan']}")
                print(f"   πŸ†” Success ID: {data_obj['success_id']}")
                print(f"   ⏱️ Timestamp: {result['timestamp']}")
            else:
                print(f"❌ Upload failed: {result['message']}")
                if 'error_code' in result:
                    print(f"🚨 Error Code: {result['error_code']}")
            
            return result
        else:
            error_result = {
                'success': False,
                'error': f"HTTP {response.status_code}",
                'message': response.text
            }
            print(f"❌ HTTP Error {response.status_code}")
            return error_result
            
    except Exception as e:
        error_result = {
            'success': False,
            'error': 'Request failed',
            'message': str(e)
        }
        print(f"🚨 Exception: {e}")
        return error_result
    finally:
        files['image'].close()

# Example usage scenarios
if __name__ == "__main__":
    # Scenario 1: Web optimization
    print("=== Web Optimization ===")
    upload_with_processing(
        file_path="large_photo.jpg",
        client_id="000003",
        apikey="paid_plan_test_key_2024",
        service_type="cdn",
        duration="720H",
        width=1200,
        quality=80
    )
    
    print("\n=== Thumbnail Creation ===")
    # Scenario 2: Thumbnail creation
    upload_with_processing(
        file_path="large_photo.jpg",
        client_id="000002",
        apikey="trial_plan_test_key_2024",
        service_type="basic",
        duration="48H",
        width=300,
        height=300,
        quality=50
    )
    
    print("\n=== Professional Archive ===")
    # Scenario 3: Professional quality permanent storage
    upload_with_processing(
        file_path="professional_photo.jpg",
        client_id="000003",
        apikey="paid_plan_test_key_2024",
        service_type="cdn",
        duration="0H",  # Permanent
        quality=95      # High quality
    )

PHP with Advanced Processing

PHP Processing Example
<?php
/**
 * Upload image with advanced processing options
 */
function uploadWithProcessing($filePath, $clientId, $apikey, $options = []) {
    $url = "https://api.corenexis.com/image/cdn/V3";
    
    $ch = curl_init();
    
    $postFields = [
        'client_id' => $clientId,
        'apikey' => $apikey,
        'type' => $options['type'] ?? 'cdn',
        'duration' => $options['duration'] ?? '168H',
        'image' => new CURLFile($filePath)
    ];
    
    // Add processing options
    if (isset($options['width'])) $postFields['width'] = $options['width'];
    if (isset($options['height'])) $postFields['height'] = $options['height'];
    if (isset($options['quality'])) $postFields['quality'] = $options['quality'];
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    
    echo "πŸš€ Uploading " . basename($filePath) . " with processing...\n";
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($httpCode == 200) {
        $result = json_decode($response, true);
        
        if ($result && $result['success']) {
            $data = $result['data'];
            echo "βœ… Upload successful!\n";
            echo "πŸ”— CDN URL: {$data['url']}\n";
            echo "πŸ“ Final dimensions: {$data['dimension']}\n";
            echo "πŸ“Š Processing Results:\n";
            echo "   πŸ“ Width applied: " . ($data['width_apply'] ? 'Yes' : 'No') . "\n";
            echo "   πŸ“ Height applied: " . ($data['height_apply'] ? 'Yes' : 'No') . "\n";
            echo "   πŸ—œοΈ Compression applied: " . ($data['compression_applied'] ? 'Yes' : 'No') . "\n";
            
            if ($data['compression_applied']) {
                echo "   🎚️ Quality level: {$data['compression_level']}\n";
            }
            
            echo "   πŸ“‹ Plan: {$data['plan']}\n";
            echo "   πŸ†” Success ID: {$data['success_id']}\n";
            echo "   ⏱️ Timestamp: {$result['timestamp']}\n";
        } else {
            echo "❌ Upload failed: " . ($result['message'] ?? 'Unknown error') . "\n";
            if (isset($result['error_code'])) {
                echo "🚨 Error Code: {$result['error_code']}\n";
            }
        }
        
        return $result;
    } else {
        echo "❌ HTTP Error {$httpCode}\n";
        return ['success' => false, 'error' => "HTTP {$httpCode}"];
    }
}

// Example usage scenarios
echo "=== Web Optimization ===\n";
$result1 = uploadWithProcessing(
    '/path/to/large-image.jpg',
    '000003',
    'paid_plan_test_key_2024',
    [
        'type' => 'cdn',
        'duration' => '720H',
        'width' => 1200,
        'quality' => 80
    ]
);

echo "\n=== Thumbnail Creation ===\n";
$result2 = uploadWithProcessing(
    '/path/to/large-image.jpg',
    '000002',
    'trial_plan_test_key_2024',
    [
        'type' => 'basic',
        'duration' => '48H',
        'width' => 300,
        'height' => 300,
        'quality' => 50
    ]
);

echo "\n=== Professional Archive ===\n";
$result3 = uploadWithProcessing(
    '/path/to/professional-photo.jpg',
    '000003',
    'paid_plan_test_key_2024',
    [
        'type' => 'cdn',
        'duration' => '0H',  // Permanent storage
        'quality' => 95      // High quality
    ]
);
?>

Error Handling

The API uses standard HTTP status codes and provides detailed error information to help you handle different scenarios effectively.

Status Code Error Type Example Response
400 Missing Required Fields {"success": false, "error_code": "MISSING_CLIENT_ID", "message": "Client ID is required"}
400 Invalid Duration Format {"success": false, "error_code": "INVALID_DURATION_FORMAT", "message": "Invalid duration format. Use format like 1H, 2H, or 0H"}
401 Invalid API Key {"success": false, "error_code": "INVALID_API_KEY", "message": "Invalid API key"}
403 Account Suspended {"success": false, "error_code": "ACCOUNT_SUSPENDED", "message": "Account suspended: Payment overdue. Please contact support."}
403 API Not Enabled {"success": false, "error_code": "API_NOT_ENABLED", "message": "Image CDN API not enabled. Please contact support or upgrade your plan."}
403 Type Not Allowed {"success": false, "error_code": "TYPE_NOT_ALLOWED", "message": "CDN type not allowed. Please upgrade your plan."}
403 Duration Not Allowed {"success": false, "error_code": "DURATION_NOT_ALLOWED", "message": "Maximum 48 hours allowed on your plan"}
404 Client Not Found {"success": false, "error_code": "CLIENT_NOT_FOUND", "message": "Client not found"}
429 Rate Limit Exceeded {"success": false, "error_code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Please wait 14 seconds before making another request. Current limit: 5 requests per minute."}
500 Internal Server Error {"success": false, "error_code": "INTERNAL_ERROR", "message": "Internal server error"}

Error Response Format

All error responses follow a consistent format for easy parsing:

Error Response Structure
{
    "success": false,
    "message": "Human-readable error message",
    "timestamp": "2025-07-05 05:49:05",
    "api_version": "V3",
    "error_code": "MACHINE_READABLE_ERROR_CODE"
}

Best Practices for Error Handling

Always check the success field before processing response data
Use error_code for programmatic error handling
Display message field to users for context
Implement retry logic with exponential backoff for 5xx errors
Respect rate limits and wait time specified in 429 responses

Using Postman

Test our API V3 quickly using Postman with these pre-configured examples. Postman makes it easy to test different scenarios and understand the API behavior.

Postman Collection V3

Download our comprehensive Postman collection with all V3 endpoints and examples:

Download V3 Collection
OR SETUP MANUALLY

Manual Setup Instructions

1. Basic File Upload Test

  1. Create a new POST request in Postman
  2. Set URL to: https://api.corenexis.com/image/cdn/V3
  3. Go to Body β†’ form-data
  4. Add these parameters:
    • client_id: 000002
    • apikey: trial_plan_test_key_2024
    • type: basic
    • duration: 24H
    • image: [Select File] β†’ Choose an image
  5. Click Send

2. URL Upload with Processing Test

  1. Create another POST request
  2. Add these parameters:
    • client_id: 000003
    • apikey: paid_plan_test_key_2024
    • type: cdn
    • duration: 720H
    • image_url: https://example.com/large-image.jpg
    • width: 800
    • quality: 75
  3. Send and compare original vs processed results

3. Rate Limit Testing

  1. Use the free plan credentials
  2. Send multiple requests quickly to test rate limiting
  3. Observe the 429 error with wait time

4. Error Testing

  1. Test with invalid client_id to see 404 error
  2. Test with wrong apikey to see 401 error
  3. Try type=cdn with free plan to see 403 error
  4. Test invalid duration like 0.5H to see validation error
Pro Tips
  • Set up environment variables for different plan credentials
  • Save test responses to compare API behavior
  • Use the Tests tab to create automated validations
  • Try different image formats and sizes to understand processing

Contact & Support

Need help with our API V3 or want to upgrade to a production plan with higher limits? We're here to assist you with integration and scaling.

Getting Help

API Support: [email protected]
Technical Support: [email protected]
General Inquiries: Contact Page
Code Examples: GitHub Repository

Production API Access

Ready to use our API V3 in production? Get dedicated credentials with higher limits, priority support, and SLA guarantees.

Feature Test/Demo Production
Rate Limits 5-20 req/min Custom limits
Daily Uploads 100-1000 Unlimited
Storage Limited duration Flexible options
Support Community Priority + SLA
Analytics Basic Advanced reporting
Migration from V2

If you're using our previous API version, we provide free migration assistance to V3 with enhanced features and better performance. Contact us for a migration guide and support.