API Documentation

Kiteworks Translation API (Version 2)

This API provides advanced AI-powered translation services for English content, converting it to various target languages (German, French, Spanish, Japanese, and Dutch) while preserving HTML structure and formatting. This is an updated version of the original API with enhanced features and optimizations.

Endpoint

POST

https://api.exponode.com/gpt-en-to-other-languages-api2.php

Overview

The Kiteworks Translation API (Version 2) leverages OpenAI's advanced models for high-quality translations tailored for B2B cybersecurity content. It ensures that HTML formatting is maintained and includes language-specific prompts for improved accuracy and context.

Authentication

Authentication is required via an API key parameter.

Parameter Value
api_key kw-T3BlbkFJpRxIaqKGOj

Request Parameters

Parameter Type Required Description
content string Yes The English content to translate. Can be HTML or plain text.
target_language string Yes The language to translate to. Must be one of: "German", "French", "Spanish", "Japanese", "Dutch".
api_key string Yes Authentication key for using this API.

Response Format

Successful Response (HTTP 200)

{
  "success": true,
  "source_language": "English",
  "target_language": "German",
  "translated_content": "<p>Willkommen auf unserer Cybersicherheitsplattform...</p>",
  "usage": {
    "prompt_tokens": 1245,
    "completion_tokens": 532,
    "total_tokens": 1777
  }
}

Error Response

{
  "error": "Error message describing what went wrong",
  "details": {
    // Additional error details if available
  }
}

Error Codes

HTTP Status Description
400 Bad Request - Missing required parameters or invalid target language.
401 Unauthorized - Invalid API key.
405 Method Not Allowed - Only POST requests are supported.
500 Internal Server Error - Error connecting to translation service or configuration issues.
502 Bad Gateway - Error from translation service or unexpected response format.

Notes

  • The API uses an advanced OpenAI model (GPT-4.1-2025-04-14) for superior translation quality.
  • HTML structure and formatting are preserved in the translated content through language-specific HTML instructions.
  • The translation is optimized for B2B cybersecurity content with a focus on SEO (Search Engine Optimization).
  • Language-specific prompts are used to ensure cultural and contextual accuracy.
  • Large content may take longer to process due to token limitations and timeouts (connection timeout: 30 seconds, total operation timeout: 600 seconds).
  • This version includes enhanced error handling and timeout configurations compared to the previous API.

Example Usage

Below are code examples for consuming this API in PHP, Python, and JavaScript/Node.js.

PHP Example

<?php
/**
 * Example code for using the Kiteworks Translation API (Version 2)
 * This script demonstrates how to send English content for translation
 * and receive the translated content in the target language.
 */

// API endpoint URL
$apiUrl = 'https://api.exponode.com/gpt-en-to-other-languages-api2.php';

// Your API key for authentication
$apiKey = 'kw-T3BlbkFJpRxIaqKGOj';

// English content to translate (can be HTML or plain text)
$englishContent = '<p>Welcome to our cybersecurity platform. We provide advanced threat protection for your organization.</p>';

// Target language for translation
$targetLanguage = 'German'; // Options: German, French, Spanish, Japanese, Dutch

// Set up the POST request
$postData = [
    'api_key' => $apiKey,
    'content' => $englishContent,
    'target_language' => $targetLanguage
];

// Initialize cURL session
$ch = curl_init($apiUrl);

// Set cURL options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the request
$response = curl_exec($ch);

// Check for errors
if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
    exit;
}

// Close cURL session
curl_close($ch);

// Process the response
$responseData = json_decode($response, true);

if (isset($responseData['success']) && $responseData['success'] === true) {
    // Translation successful
    echo "Original Language: English\n";
    echo "Target Language: " . $responseData['target_language'] . "\n\n";
    echo "Translated Content:\n" . $responseData['translated_content'] . "\n\n";
    echo "Token Usage:\n";
    echo "- Prompt Tokens: " . $responseData['usage']['prompt_tokens'] . "\n";
    echo "- Completion Tokens: " . $responseData['usage']['completion_tokens'] . "\n";
    echo "- Total Tokens: " . $responseData['usage']['total_tokens'] . "\n";
} else {
    // Translation failed
    echo "Translation Error: " . ($responseData['error'] ?? 'Unknown error') . "\n";
    if (isset($responseData['details'])) {
        echo "Details: " . print_r($responseData['details'], true) . "\n";
    }
}
?>

Python Example

import requests

def translate_content(content, target_language):
    """
    Translate English content to the specified target language using the Kiteworks Translation API (Version 2)
    
    Parameters:
    content (str): The English content to translate (HTML or plain text)
    target_language (str): The target language for translation (German, French, Spanish, Japanese, Dutch)
    
    Returns:
    dict: The API response containing the translated content
    """
    # API endpoint URL
    api_url = 'https://api.exponode.com/gpt-en-to-other-languages-api2.php'
    
    # Your API key for authentication
    api_key = 'kw-T3BlbkFJpRxIaqKGOj'
    
    # Prepare the request data
    data = {
        'api_key': api_key,
        'content': content,
        'target_language': target_language
    }
    
    # Send the POST request
    response = requests.post(api_url, data=data)
    
    # Check if the request was successful
    if response.status_code == 200:
        return response.json()
    else:
        print(f"Error: HTTP {response.status_code}")
        try:
            return response.json()
        except:
            return {"error": "Failed to parse response"}

# Example usage
if __name__ == "__main__":
    # English content to translate
    english_content = """
    <h1>Cybersecurity Best Practices</h1>
    <p>Implementing strong security measures is essential for protecting your organization's data.</p>
    <ul>
        <li>Use multi-factor authentication</li>
        <li>Regularly update your software</li>
        <li>Train employees on security awareness</li>
    </ul>
    """
    
    # Target language
    target_language = "French"  # Options: German, French, Spanish, Japanese, Dutch
    
    # Call the translation function
    result = translate_content(english_content, target_language)
    
    # Process the result
    if "success" in result and result["success"]:
        print(f"Original Language: English")
        print(f"Target Language: {result['target_language']}")
        print("\nTranslated Content:")
        print(result['translated_content'])
        print("\nToken Usage:")
        print(f"- Prompt Tokens: {result['usage']['prompt_tokens']}")
        print(f"- Completion Tokens: {result['usage']['completion_tokens']}")
        print(f"- Total Tokens: {result['usage']['total_tokens']}")
    else:
        print(f"Translation Error: {result.get('error', 'Unknown error')}")
        if "details" in result:
            print(f"Details: {result['details']}")

JavaScript/Node.js Example

const axios = require('axios');
const FormData = require('form-data');

/**
 * Translate English content to the specified target language
 * @param {string} content - The English content to translate (HTML or plain text)
 * @param {string} targetLanguage - The target language (German, French, Spanish, Japanese, Dutch)
 * @returns {Promise<object>} - The API response containing the translated content
 */
async function translateContent(content, targetLanguage) {
    // API endpoint URL
    const apiUrl = 'https://api.exponode.com/gpt-en-to-other-languages-api2.php';
    
    // Your API key for authentication
    const apiKey = 'kw-T3BlbkFJpRxIaqKGOj';
    
    // Create form data
    const formData = new FormData();
    formData.append('api_key', apiKey);
    formData.append('content', content);
    formData.append('target_language', targetLanguage);
    
    try {
        // Send the POST request
        const response = await axios.post(apiUrl, formData, {
            headers: {
                ...formData.getHeaders()
            }
        });
        
        // Return the response data
        return response.data;
    } catch (error) {
        if (error.response) {
            // The request was made and the server responded with a status code
            // that falls out of the range of 2xx
            console.error(`Error: HTTP ${error.response.status}`);
            return error.response.data;
        } else if (error.request) {
            // The request was made but no response was received
            console.error('Error: No response received');
            return { error: 'No response received from the server' };
        } else {
            // Something happened in setting up the request that triggered an Error
            console.error('Error:', error.message);
            return { error: error.message };
        }
    }
}

// Example usage
async function main() {
    // English content to translate
    const englishContent = `
    <div class="content-section">
        <h2>Data Protection Solutions</h2>
        <p>Our platform provides comprehensive data protection for sensitive information.</p>
        <p>Key features include:</p>
        <ul>
            <li>End-to-end encryption</li>
            <li>Access control management</li>
            <li>Audit logging and reporting</li>
        </ul>
    </div>
    `;
    
    // Target language
    const targetLanguage = 'Spanish'; // Options: German, French, Spanish, Japanese, Dutch
    
    try {
        // Call the translation function
        const result = await translateContent(englishContent, targetLanguage);
        
        // Process the result
        if (result.success) {
            console.log(`Original Language: English`);
            console.log(`Target Language: ${result.target_language}`);
            console.log('\nTranslated Content:');
            console.log(result.translated_content);
            console.log('\nToken Usage:');
            console.log(`- Prompt Tokens: ${result.usage.prompt_tokens}`);
            console.log(`- Completion Tokens: ${result.usage.completion_tokens}`);
            console.log(`- Total Tokens: ${result.usage.total_tokens}`);
        } else {
            console.log(`Translation Error: ${result.error || 'Unknown error'}`);
            if (result.details) {
                console.log(`Details:`, result.details);
            }
        }
    } catch (error) {
        console.error('Execution error:', error);
    }
}

main();

Additional Information