v2.1 Stable

CoreNexis Image CDN API

Seamlessly upload and manage images through our global content delivery network with flexible storage options, fast delivery, and secure management.

Simple Uploads
Flexible Storage Options
Fast Delivery
Secure Storage
Social Sharing
Beta Version Notice

This API is currently in beta. For production access with higher limits and SLA guarantees, please contact our team for a dedicated API key.

CoreNexis Image CDN API

The CoreNexis Image CDN API allows you to seamlessly upload and manage and share images through our content delivery network. We provides different storage durations and plan options to fit your needs.

Features

  • Simple image uploads using direct file or URL
  • Multiple storage duration options (7 days, 1 month, 3 months, lifetime)
  • Fast, reliable content delivery through our global CDN
  • Secure storage with automatic expiration
  • Image viewer page with social sharing (free plan)
  • Direct CDN URLs (paid plans)

Base URL

https://cdn.corenexis.com/image/v2/

Authentication

All API requests require authentication using a client ID and client token. These credentials are plan-specific and determine your access level, storage options, and usage limits.

Test API Credentials

For testing purposes, you can use the following API credentials:

Free Plan

3-Month Plan

Lifetime Plan

Important Notice

These test credentials have limited quota and are for testing only. For production use, please contact us to obtain your own API credentials.

Rate Limits

API usage is subject to rate limits based on your plan. When you exceed your daily limit, requests will be rejected with a 429 status code.

Plan Limits

Plan Daily Upload Limit Max File Size Storage Options URL Type
Free Plan 50 uploads 2 MB 7 days, 1 month Viewer page
3-Month Plan 1,000 uploads 5 MB 7 days, 1 month, 3 months Direct CDN URL
Lifetime Plan 3,000 uploads 10 MB 7 days, 1 month, 3 months, lifetime Direct CDN URL

Endpoints

Upload Image

POST https://cdn.corenexis.com/image/v2/

This endpoint allows you to upload an image either directly via a file upload or by providing a URL to an existing image.

Request Parameters

Parameter Type Description
client_id Required String Your client ID for authentication
client_token Required String Your client token for authentication
store_duration Required String Duration to store the image. One of:
  • 7D - 7 days
  • 1M - 1 month
  • 3M - 3 months (paid plans only)
  • LTF - Lifetime (Lifetime plan only)
image Optional* File The image file to upload (Required if image_url is not provided)
image_url Optional* String URL of an image to download and store (Required if image is not provided)

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

Response

A successful response will return a 200 status code and a JSON object with the following properties:

Success Response
{
  "status": "success",
  "url": "https://cdn.corenexis.com/view/?img=d/ap5/AbCdEf.png", // Free plan (viewer URL)
  // OR
  "url": "https://cdn.corenexis.com/p/d/ap5/AbCdEf.png", // Paid plan (direct CDN URL)
  "expires_at": "2025-05-12" // OR "Never (Lifetime)" for LTF duration
}

Client Libraries

You can integrate with our API using various programming languages. Below are examples of how to use the API with common tools and languages.

File Upload
URL Upload

cURL

cURL Example
curl -X POST \
  -F "client_id=client_3m_plan" \
  -F "client_token=8b5d24c7e3af9d87156a40b1c3e92f67" \
  -F "store_duration=7D" \
  -F "image=@/path/to/your/image.jpg" \
  https://cdn.corenexis.com/image/v2/

JavaScript

JavaScript Example
// Example using HTML form with JavaScript fetch
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
  e.preventDefault();
  
  const formData = new FormData();
  formData.append('client_id', 'client_3m_plan');
  formData.append('client_token', '8b5d24c7e3af9d87156a40b1c3e92f67');
  formData.append('store_duration', '7D');
  
  // Get file from an input element
  const fileInput = document.getElementById('imageFile');
  formData.append('image', fileInput.files[0]);
  
  try {
    const response = await fetch('https://cdn.corenexis.com/image/v2/', {
      method: 'POST',
      body: formData
    });
    
    const data = await response.json();
    console.log('Success:', data);
    
    // Use the returned URL
    if (data.status === 'success') {
      console.log('Image URL:', data.url);
      console.log('Expires at:', data.expires_at);
    }
  } catch (error) {
    console.error('Error:', error);
  }
});

Python

Python Example
import requests

def upload_image(file_path, client_id, client_token, duration):
    """
    Upload an image to CoreNexis CDN
    
    Args:
        file_path (str): Path to the local image file
        client_id (str): Your client ID
        client_token (str): Your client token
        duration (str): Storage duration ('7D', '1M', '3M', or 'LTF')
    
    Returns:
        dict: API response
    """
    url = "https://cdn.corenexis.com/image/v2/"
    
    # Prepare form data
    files = {
        'image': open(file_path, 'rb')
    }
    
    data = {
        'client_id': client_id,
        'client_token': client_token,
        'store_duration': duration
    }
    
    # Make the request
    response = requests.post(url, files=files, data=data)
    
    # Check if the request was successful
    if response.status_code == 200:
        result = response.json()
        return result
    else:
        return {
            'error': f"Request failed with status code {response.status_code}",
            'message': response.text
        }

# Example usage
if __name__ == "__main__":
    result = upload_image(
        file_path="path/to/image.jpg",
        client_id="client_3m_plan",
        client_token="8b5d24c7e3af9d87156a40b1c3e92f67",
        duration="7D"
    )
    
    print(f"Status: {result.get('status', 'error')}")
    if 'url' in result:
        print(f"Image URL: {result['url']}")
        print(f"Expires at: {result['expires_at']}")
    else:
        print(f"Error: {result.get('error', 'Unknown error')}")

PHP

PHP Example
<?php
/**
 * Upload an image to CoreNexis CDN
 *
 * @param string $filePath Path to the local image file
 * @param string $clientId Your client ID
 * @param string $clientToken Your client token
 * @param string $duration Storage duration ('7D', '1M', '3M', or 'LTF')
 * @return array API response
 */
function uploadImage($filePath, $clientId, $clientToken, $duration) {
    $url = "https://cdn.corenexis.com/image/v2/";
    
    // Initialize cURL session
    $ch = curl_init();
    
    // Prepare form data
    $postFields = [
        'client_id' => $clientId,
        'client_token' => $clientToken,
        'store_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);
    
    // Execute the request
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    // Check for errors
    if (curl_errno($ch)) {
        $result = [
            'error' => 'cURL Error: ' . curl_error($ch)
        ];
    } else if ($httpCode != 200) {
        $result = [
            'error' => "Request failed with status code {$httpCode}",
            'message' => $response
        ];
    } else {
        $result = json_decode($response, true);
    }
    
    // Close cURL session
    curl_close($ch);
    
    return $result;
}

// Example usage
$result = uploadImage(
    '/path/to/image.jpg',
    'client_3m_plan',
    '8b5d24c7e3af9d87156a40b1c3e92f67',
    '7D'
);

// Display the result
if (isset($result['status']) && $result['status'] === 'success') {
    echo "Upload successful!\n";
    echo "Image URL: {$result['url']}\n";
    echo "Expires at: {$result['expires_at']}\n";
} else {
    echo "Upload failed: " . ($result['error'] ?? 'Unknown error') . "\n";
}

cURL

cURL Example
curl -X POST \
  -F "client_id=client_3m_plan" \
  -F "client_token=8b5d24c7e3af9d87156a40b1c3e92f67" \
  -F "store_duration=7D" \
  -F "image_url=https://example.com/image.jpg" \
  https://cdn.corenexis.com/image/v2/

JavaScript

JavaScript Example
async function uploadImageFromUrl(imageUrl, clientId, clientToken, duration) {
  const formData = new FormData();
  formData.append('client_id', clientId);
  formData.append('client_token', clientToken);
  formData.append('store_duration', duration);
  formData.append('image_url', imageUrl);
  
  try {
    const response = await fetch('https://cdn.corenexis.com/image/v2/', {
      method: 'POST',
      body: formData
    });
    
    return await response.json();
  } catch (error) {
    console.error('Error:', error);
    return { error: error.message };
  }
}

// Example usage
uploadImageFromUrl(
  'https://example.com/image.jpg',
  'client_3m_plan',
  '8b5d24c7e3af9d87156a40b1c3e92f67',
  '7D'
).then(result => {
  if (result.status === 'success') {
    console.log('Upload successful!');
    console.log('Image URL:', result.url);
    console.log('Expires at:', result.expires_at);
  } else {
    console.error('Upload failed:', result.error || 'Unknown error');
  }
});

Python

Python Example
import requests

def upload_image_from_url(image_url, client_id, client_token, duration):
    """
    Upload an image from URL to CoreNexis CDN
    
    Args:
        image_url (str): URL of the image to upload
        client_id (str): Your client ID
        client_token (str): Your client token
        duration (str): Storage duration ('7D', '1M', '3M', or 'LTF')
    
    Returns:
        dict: API response
    """
    url = "https://cdn.corenexis.com/image/v2/"
    
    # Prepare form data
    data = {
        'client_id': client_id,
        'client_token': client_token,
        'store_duration': duration,
        'image_url': image_url
    }
    
    # Make the request
    response = requests.post(url, data=data)
    
    # Check if the request was successful
    if response.status_code == 200:
        result = response.json()
        return result
    else:
        return {
            'error': f"Request failed with status code {response.status_code}",
            'message': response.text
        }

# Example usage
if __name__ == "__main__":
    result = upload_image_from_url(
        image_url="https://example.com/image.jpg",
        client_id="client_3m_plan",
        client_token="8b5d24c7e3af9d87156a40b1c3e92f67",
        duration="7D"
    )
    
    print(f"Status: {result.get('status', 'error')}")
    if 'url' in result:
        print(f"Image URL: {result['url']}")
        print(f"Expires at: {result['expires_at']}")
    else:
        print(f"Error: {result.get('error', 'Unknown error')}")

PHP

PHP Example
<?php
/**
 * Upload an image from URL to CoreNexis CDN
 *
 * @param string $imageUrl URL of the image to upload
 * @param string $clientId Your client ID
 * @param string $clientToken Your client token
 * @param string $duration Storage duration ('7D', '1M', '3M', or 'LTF')
 * @return array API response
 */
function uploadImageFromUrl($imageUrl, $clientId, $clientToken, $duration) {
    $url = "https://cdn.corenexis.com/image/v2/";
    
    // Initialize cURL session
    $ch = curl_init();
    
    // Prepare form data
    $postFields = [
        'client_id' => $clientId,
        'client_token' => $clientToken,
        'store_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);
    
    // Execute the request
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    // Check for errors
    if (curl_errno($ch)) {
        $result = [
            'error' => 'cURL Error: ' . curl_error($ch)
        ];
    } else if ($httpCode != 200) {
        $result = [
            'error' => "Request failed with status code {$httpCode}",
            'message' => $response
        ];
    } else {
        $result = json_decode($response, true);
    }
    
    // Close cURL session
    curl_close($ch);
    
    return $result;
}

// Example usage
$result = uploadImageFromUrl(
    'https://example.com/image.jpg',
    'client_3m_plan',
    '8b5d24c7e3af9d87156a40b1c3e92f67',
    '7D'
);

// Display the result
if (isset($result['status']) && $result['status'] === 'success') {
    echo "Upload successful!\n";
    echo "Image URL: {$result['url']}\n";
    echo "Expires at: {$result['expires_at']}\n";
} else {
    echo "Upload failed: " . ($result['error'] ?? 'Unknown error') . "\n";
}

Error Handling

The API uses standard HTTP status codes to indicate the success or failure of a request. Here are the common error responses you might encounter:

Status Code Description Example Response
400 Bad Request - Invalid parameters or missing required fields {"error": "Missing required parameters"}
400 Invalid file type {"error": "Invalid file type", "allowed": ["image/jpeg", "image/png", "image/gif", "image/webp"]}
400 File too large {"error": "File too large", "max_size": 5242880}
400 Invalid storage duration {"error": "Invalid storage duration", "allowed": ["7D", "1M", "3M"]}
403 Forbidden - Invalid client ID or token {"error": "Invalid client ID"} or {"error": "Invalid client token"}
429 Too Many Requests - Daily upload limit reached {"error": "Daily upload limit reached"}
500 Internal Server Error - Something went wrong on our end {"error": "Failed to create directory"}

Error Handling Best Practices

Here are some recommendations for handling errors in your application:

Always check the status code of the API response
Implement retry logic for server errors (5xx) but not for client errors (4xx)
Respect rate limits and implement backoff mechanisms when you receive a 429 status code
Validate files before uploading to avoid unnecessary API calls
Display meaningful error messages to your users

Using Postman

Postman is a popular API testing tool that can help you quickly test and understand our API. Here's how to set up a test in Postman:

Postman Collection

You can download our Postman collection to get started quickly:

Download Postman Collection
OR

File Upload Test

  1. Open Postman and create a new request
  2. Set the request type to POST
  3. Enter the API URL: https://cdn.corenexis.com/image/v2/
  4. Select the Body tab
  5. Choose form-data as the input type
  6. Add the following key-value pairs:
    • client_id: client_3m_plan
    • client_token: 8b5d24c7e3af9d87156a40b1c3e92f67
    • store_duration: 7D
    • image: Select 'File' from the dropdown and choose an image from your computer
  7. Click Send and check the response

URL Upload Test

  1. Create another request with the same settings, but instead of the image file, add:
    • image_url: https://example.com/image.jpg (use a real image URL)
  2. Click Send and check the response
Pro Tip

You can save these requests in a Postman collection for future use. This makes testing different API parameters and scenarios much easier.

Contact & Support

If you need help with our API or want to upgrade to a production plan, we're here to help.

Getting Help

Email Support: [email protected]
General Inquiries: Contact Page

Production API Access

The API is currently in beta. For production access with higher limits and SLA guarantees, please contact our team to discuss your needs and get a dedicated API key.