API งานการแปล
แปลข้อความ
แปลข้อความและส่งคืนผลลัพธ์การแปลพร้อมกัน
- ที่อยู่แบบเต็ม
- https://dltranslator.com/api/v1/translation/translateTexts
- การรับรอง
- ต้องส่งผ่าน API Key ในส่วนหัวคำขอ Authorization
- Content-Type
- application/json
- รูปแบบผิดพลาด
- { "error": "Invalid API key." }
ข้อควรระวัง
อินเทอร์เฟซนี้จะบันทึกข้อความที่ส่งเข้ามาเป็นเอกสาร JSON ชั่วคราวและประมวลผลแบบซิงโครนัส เหมาะสำหรับการแปลข้อความทันทีในปริมาณน้อย
ยอดคงเหลือคะแนนในบัญชีต้องมีอย่างน้อย 2 creditsหากค่าใช้จ่ายจริงเกินยอดคงเหลือ API จะส่งคืน taskId และ price พร้อมแจ้งเตือนว่ายอดคงเหลือไม่เพียงพอ
ตัวอย่าง
1curl -X POST 'https://dltranslator.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}'พารามิเตอร์ของคำขอ
| พารามิเตอร์ | ประเภท | ค่าเริ่มต้น | คำอธิบาย | ตัวอย่าง |
|---|---|---|---|---|
| *texts | String[] | - | ข้อความที่ต้องการแปล | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | คำอธิบายเอกสาร ปรับปรุงคุณภาพการแปลด้วยการให้ข้อมูลเพิ่มเติม เช่น การเพิ่มข้อมูลพื้นหลังของเอกสารและความต้องการด้านการแปลอื่นๆ | - |
การตอบสนอง
| พารามิเตอร์ | ประเภท | ค่าเริ่มต้น | คำอธิบาย | ตัวอย่าง |
|---|---|---|---|---|
| taskId | String | - | รหัสงาน | - |
| translatedTexts | String[] | - | ข้อความที่ได้รับการแปลแล้ว | - |
| price | Integer | - | จำนวน Credits ที่จำเป็นสำหรับการแปลทั้งหมด | - |
| usedCredits | Integer | - | จำนวน 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.