CloudTranslateAPI
CloudTranslateAPI Reference
CloudTranslateAPI は、高性能なテキスト翻訳を提供する RESTful API です。シンプルなインターフェースで、多言語間の翻訳を簡単に統合できます。機械学習モデルを活用して、正確かつ効率的な翻訳を実現します。
導入用途
ウェブアプリケーションの多言語化 Web サイトや SaaS アプリケーションに CloudTranslateAPI を統合することで、多言語対応を効率的に行えます。ユーザーの言語設定に応じた動的なコンテンツ翻訳が可能です。
カスタマーサポートの強化 サポートチャットやメール翻訳に利用することで、異なる言語を話す顧客との円滑なコミュニケーションを実現します。
Eコマースサイトの国際化 商品説明やレビューを自動翻訳することで、国際市場での競争力を高めます。
教育分野での活用 学習プラットフォームで教材や質問の翻訳に使用し、多文化対応の学習環境を提供します。
ドキュメント管理の効率化 翻訳されたドキュメントを作成・管理し、グローバルチーム間の情報共有を容易にします。
Base URL
https://cloudtranslate-mixederapi.mixeder.com/
Endpoints
POST /
指定されたテキストを翻訳するメインエンドポイントです。
Headers
ヘッダー名
必須
説明
Content-Type
はい
application/json
Request Body
パラメーター名
必須
説明
key
はい
使用する API キー
text
はい
翻訳対象のテキスト
source
はい
翻訳元言語コード(例: en
)
target
はい
翻訳先言語コード(例: fr
)
Response
成功時: HTTP Status: 200 Body:
{ "message": "API authentication, translation, and billing completed successfully", "username": "username", "inputs": { "text": "Welcome to MixederCloud!", "source_lang": "en", "target_lang": "ja" }, "translation": { "translated_text": "MixederCloudへようこそ!" }, "billingResponse": "{\"status\":\"success\"}" }
エラー時: HTTP Status: 400 または 500 Body:
{ "error": "Error message" }
サンプルコード
JavaScript Fetch Example
async function translateText(apiKey, text, sourceLang, targetLang) {
const apiUrl = 'https://cloudtranslate-mixederapi.mixeder.com/';
const body = {
key: apiKey,
text: text || 'Tell me a joke about Cloudflare',
source: sourceLang || 'en',
target: targetLang || 'fr',
};
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}
const data = await response.json();
console.log('Translation:', data.translation.result);
return data.translation.result;
} catch (error) {
console.error('Error during translation:', error.message);
throw error;
}
}
// 使用例
translateText('your-api-key', 'Hello, world!', 'en', 'es')
.then((result) => console.log('Translated text:', result))
.catch((err) => console.error('Translation failed:', err));
Python Requests Example
import requests
def translate_text(api_key, text, source_lang, target_lang):
api_url = 'https://cloudtranslate-mixederapi.mixeder.com/'
payload = {
"key": api_key,
"text": text or "Tell me a joke about Cloudflare",
"source": source_lang or "en",
"target": target_lang or "fr",
}
try:
response = requests.post(api_url, json=payload)
response.raise_for_status()
data = response.json()
print("Translation:", data["translation"]["result"])
return data["translation"]["result"]
except requests.exceptions.RequestException as e:
print("Error during translation:", e)
raise
# 使用例
translate_text("your-api-key", "Hello, world!", "en", "es")
cURL Example
curl -X POST https://cloudtranslate-mixederapi.mixeder.com/ \
-H "Content-Type: application/json" \
-d '{
"key": "your-api-key",
"text": "Hello, world!",
"source": "en",
"target": "es"
}'
最終更新
役に立ちましたか?