สารบัญเอกสาร

API งานการแปล

แปลข้อความ

POST/v1/translation/translateTexts

แปลข้อความและส่งคืนผลลัพธ์การแปลพร้อมกัน

ที่อยู่แบบเต็ม
https://otranslator.com/api/v1/translation/translateTexts
การรับรอง
ต้องส่งผ่าน API Key ในส่วนหัวคำขอ Authorization
Content-Type
application/json
รูปแบบผิดพลาด
{ "error": "Invalid API key." }

ข้อควรระวัง

อินเทอร์เฟซนี้จะบันทึกข้อความที่ส่งเข้ามาเป็นเอกสาร JSON ชั่วคราวและประมวลผลแบบซิงโครนัส เหมาะสำหรับการแปลข้อความทันทีในปริมาณน้อย

ยอดคงเหลือคะแนนในบัญชีต้องมีอย่างน้อย 2 creditsหากค่าใช้จ่ายจริงเกินยอดคงเหลือ API จะส่งคืน taskId และ price พร้อมแจ้งเตือนว่ายอดคงเหลือไม่เพียงพอ

ตัวอย่าง

curl
1curl -X POST 'https://otranslator.com/api/v1/translation/translateTexts' \
2--header 'Authorization: [yourSecretKey]' \
3--header 'Content-Type: application/json' \
4--data '{
5  "texts": [
6    "string"
7  ],
8  "fromLang": "[string]",
9  "toLang": "[string]"
10}'

พารามิเตอร์ของคำขอ

พารามิเตอร์ประเภทค่าเริ่มต้นคำอธิบายตัวอย่าง
*textsString[]-

ข้อความที่ต้องการแปล

-
*fromLangString-
  • ภาษาต้นฉบับ ภาษาต้นฉบับต้องไม่เหมือนกับภาษาปลายทาง
  • ภาษาที่รองรับ: สอบถาม
-
*toLangString-
  • ภาษาปลายทาง ภาษาปลายทางต้องไม่เหมือนกับภาษาต้นทาง
  • ภาษาที่รองรับ:สอบถาม
-
modelString-
  • โมเดล AI สำหรับการแปล
  • โมเดลที่รองรับ:สอบถาม
-
fileDescriptionString-

คำอธิบายเอกสาร ปรับปรุงคุณภาพการแปลด้วยการให้ข้อมูลเพิ่มเติม เช่น การเพิ่มข้อมูลพื้นหลังของเอกสารและความต้องการด้านการแปลอื่นๆ

-

การตอบสนอง

พารามิเตอร์ประเภทค่าเริ่มต้นคำอธิบายตัวอย่าง
taskIdString-

รหัสงาน

-
translatedTextsString[]-

ข้อความที่ได้รับการแปลแล้ว

-
priceInteger-

จำนวน Credits ที่จำเป็นสำหรับการแปลทั้งหมด

-
usedCreditsInteger-

จำนวน Credits ที่ใช้ไปแล้วในงานแปล

-

ข้อผิดพลาดทั่วไป

401 Missing API key.

The Authorization request header is required.

401 Invalid API key.

The API key does not exist, has been deleted, or is no longer valid.

402 Insufficient credits balance.

The account does not have enough credits to translate the texts.

400 Missing required parameter: fromLang.

Provide fromLang using a language returned by /api/v1/languages.

400 Missing required parameter: toLang.

Provide toLang using a language returned by /api/v1/languages.

400 Missing required parameter: texts.

Provide a non-empty texts array.

400 Failed to translate texts.

The text translation task could not be processed.