บทนำ
ยินดีต้อนรับสู่ API การแปลของ i18n-agent! บริการแปลภาษาด้วย AI พร้อมการปรับให้เข้ากับวัฒนธรรม
เอกสารประกอบ API นี้ให้ข้อมูลที่ครอบคลุมเกี่ยวกับจุดสิ้นสุดที่มีทั้งหมด วิธีการตรวจสอบสิทธิ์ รูปแบบคำขอ/การตอบสนอง และรหัสข้อผิดพลาด
ฐาน URLs
| สภาพแวดล้อม | URL |
|---|---|
| การพัฒนา | http://localhost:8000 |
| การผลิต | https://api.i18nagent.ai |
คุณสมบัติหลัก
- 🌐 รองรับหลายภาษา - แปลเนื้อหาเป็น 10+ ภาษาพร้อมการปรับให้เข้ากับวัฒนธรรม
- 🚀 การสตรีมแบบเรียลไทม์ - ServerSent Events สำหรับการอัปเดตความคืบหน้า
- 📁 การแปลไฟล์ - รองรับ JSON, YAML, XML, CSV และอื่นๆ
- 🔐 การรับรองความปลอดภัย - การรับรองตัวตนด้วยคีย์ API
- 💳 ระบบเครดิต - รูปแบบการคิดราคาแบบจ่ายตามการใช้งาน
- 🤖 ขับเคลื่อนด้วย AI - ใช้ LLMs ขั้นสูงสำหรับการแปลที่แม่นยำ
การรับรองตัวตน
ในการรับรองตัวตน ใช้โค้ดนี้:
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here" \
-H "Authorization: Bearer i18n_your_api_key_here"
const headers = {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
};
fetch('api_endpoint_here', { headers })
.then(response => response.json())
.then(data => console.log(data));
import requests
headers = {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.get('api_endpoint_here', headers=headers)
print(response.json())
package main
import (
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "api_endpoint_here", nil)
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
ตรวจสอบให้แน่ใจว่าได้แทนที่
i18n_your_api_key_hereด้วยคีย์ API ของคุณ
API i18n-agent ใช้คีย์ API เพื่ออนุญาตการเข้าถึง API คุณสามารถรับคีย์ API ของคุณได้จาก แดชบอร์ดบัญชี.
คีย์ API ต้องรวมอยู่ในคำขอ API ทั้งหมดไปยังเซิร์ฟเวอร์ในส่วนหัวที่มีลักษณะดังต่อไปนี้:
Authorization: Bearer i18n_your_api_key_here
จุดปลายทาง
เครดิต
รับเครดิตทีม
GET /credits
รับยอดคงเหลือเครดิตปัจจุบันสำหรับทีมที่ได้รับการรับรอง
curl -X GET "https://api.i18nagent.ai/credits" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/credits', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/credits',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/credits", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
ภาษา
รายการภาษาที่รองรับ
GET /languages
รับรายการภาษาที่รองรับทั้งหมดพร้อมคะแนนคุณภาพ
curl -X GET "https://api.i18nagent.ai/languages" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/languages', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/languages',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/languages", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
งานแปล
รับประวัติการแปล
GET /translations
รับรายการงานแปลแบบแบ่งหน้าพร้อมตัวกรองตามสถานะ ประเภท ภาษาเป้าหมาย และช่วงวันที่
curl -X GET "https://api.i18nagent.ai/translations" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสอบถาม
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| page | ไม่ | หมายเลขหน้าสำหรับการแบ่งหน้า |
| limit | ไม่ | จำนวนรายการต่อหน้า |
| status | ไม่ | กรองตามสถานะการแปล |
| type | ไม่ | กรองตามประเภทการแปล |
| targetLanguages | ไม่ | รายการรหัสภาษาเป้าหมายที่คั่นด้วยจุลภาค เพื่อกรอง |
| fromDate | ไม่ | กรองการแปลที่สร้างหลังวันที่นี้ |
| toDate | ไม่ | กรองการแปลที่สร้างก่อนวันที่นี้ |
รับรายละเอียดการแปล
GET /translations/{id}
รับรายละเอียดการแปลเฉพาะโดย ID
curl -X GET "https://api.i18nagent.ai/translations/{id}" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสอบถาม
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| id | ใช่ | ID การแปล |
รับสถานะการแปล
GET /translations/{id}/status
รับสถานะแบบเรียลไทม์ของงานแปลพร้อมการติดตามความคืบหน้าโดยละเอียด ซึ่งประกอบด้วย: เปอร์เซ็นต์ความคืบหน้า เวลาที่ผ่านมา เวลาที่คาดว่าจะเหลือ ข้อมูลจุดตรวจสอบ การแปลบางส่วนสำหรับการแปลหลายภาษา และการดาวน์โหลดแบบลงทะเบียนล่วงหน้า URLs สำหรับผลลัพธ์ที่เสร็จสมบูรณ์
curl -X GET "https://api.i18nagent.ai/translations/{id}/status" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}/status', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}/status',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}/status", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การค้นหา
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| id | ใช่ | ID การแปล |
ดาวน์โหลดผลลัพธ์การแปล
GET /translations/{id}/result
ดาวน์โหลดเนื้อหาที่แปลแล้ว
curl -X GET "https://api.i18nagent.ai/translations/{id}/result" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}/result', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}/result',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}/result", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การค้นหา
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| id | ใช่ | รหัสการแปล |
| language | ไม่ | รหัสภาษาสำหรับผลลัพธ์ภาษาเฉพาะ |
ดาวน์โหลดไฟล์ต้นฉบับ
GET /translations/{id}/original
ดาวน์โหลดไฟล์ที่อัปโหลดดั้งเดิม
curl -X GET "https://api.i18nagent.ai/translations/{id}/original" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}/original', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}/original',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}/original", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การค้นหา
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| id | ใช่ | ID การแปล |
กู้คืนการแปลจากจุดตรวจสอบ
POST /translations/{id}/resume
กู้คืนการแปลที่ล้มเหลวหรือถูกขัดจังหวะจากจุดตรวจสอบเฉพาะหรือกู้คืนอัตโนมัติจากจุดตรวจสอบที่สำเร็จล่าสุด
curl -X POST "https://api.i18nagent.ai/translations/{id}/resume" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/{id}/resume', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/{id}/resume',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/{id}/resume", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสอบถาม
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| id | ใช่ | ID การแปล |
พารามิเตอร์ของเนื้อหาคำขอ
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| checkpointId | string | ไม่ | รหัสจุดตรวจสอบแบบทึบที่จะกลับมาดำเนินการต่อ (ได้รับจากเอนดพอยต์สถานะ) หากไม่ได้ระบุและ autoDetect เป็นจริง จะกลับมาดำเนินการต่อจากจุดตรวจสอบที่สำเร็จครั้งล่าสุด |
| continueToEnd | boolean | ไม่ | เพื่อดำเนินการประมวลผลเนื้อหาที่เหลือทั้งหมดหลังจากกลับมาดำเนินการต่อ (ค่าเริ่มต้น: true) |
| autoDetect | boolean | ไม่ | ตรวจจับและกลับมาดำเนินการต่อจากจุดตรวจสอบที่สำเร็จครั้งล่าสุดโดยอัตโนมัติหากไม่ได้ระบุ checkpointId (ค่าเริ่มต้น: true) |
รับงานแปลที่ใช้งานอยู่
GET /translations/jobs/active
รับรายการงานแปลที่ใช้งานอยู่ในปัจจุบัน
curl -X GET "https://api.i18nagent.ai/translations/jobs/active" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/jobs/active', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/jobs/active',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/jobs/active", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
ดาวน์โหลดผลการแปล
POST /translations/{jobId}/download
ดาวน์โหลดผลการแปลที่เสร็จสมบูรณ์ ส่งคืน URLs ที่ดาวน์โหลดได้ จัดเรียงตามภาษา URLs จะหมดอายุหลังจาก 24 ชั่วโมง
curl -X POST "https://api.i18nagent.ai/translations/{jobId}/download" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{jobId}/download', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/{jobId}/download',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/{jobId}/download", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสอบถาม
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| jobId | ใช่ | ID งานแปล |
ดาวน์โหลดไฟล์แปลภาษาสำหรับภาษาเฉพาะ
GET /translations/{jobId}/files/{language}
ดาวน์โหลดไฟล์แปลภาษาเดียวสำหรับภาษาเป้าหมายเฉพาะ ส่งคืนเนื้อหาไฟล์โดยตรงพร้อมส่วนหัว Content-Type ที่เหมาะสม
curl -X GET "https://api.i18nagent.ai/translations/{jobId}/files/{language}" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{jobId}/files/{language}', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{jobId}/files/{language}',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{jobId}/files/{language}", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งด้านบนส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสืบค้น
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| jobId | ใช่ | ID งานแปล |
| language | ใช่ | รหัสภาษาเป้าหมาย (เช่น 'es', 'fr', 'ja') |
สร้างการแปลพร้อมความคืบหน้าการสตรีม
POST /translations/stream
สร้างการแปลด้วยเหตุการณ์ Server-Sent (SSE) สำหรับการอัปเดตความคืบหน้าแบบเรียลไทม์ รองรับการแปลข้อความเท่านั้น (ไม่ใช่ไฟล์) ส่งคืนการอัปเดตความคืบหน้าแบบเรียลไทม์เป็นเหตุการณ์ SSE
curl -X POST "https://api.i18nagent.ai/translations/stream" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/stream',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/stream", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์ของเนื้อหาคำขอ
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| texts | array | ใช่ | อาร์เรย์ของข้อความที่จะแปล |
| targetLanguage | string | ไม่ | รหัสภาษาเป้าหมาย (เช่น 'es', 'fr', 'ja') - สำหรับการแปลภาษาเดียว |
| targetAudience | string | ไม่ | กลุ่มเป้าหมาย (เช่น 'general', 'technical', 'casual', 'formal') (ค่าเริ่มต้น: general) |
| industry | string | ไม่ | บริบทอุตสาหกรรม (เช่น 'เทคโนโลยี', 'การดูแลสุขภาพ', 'การเงิน') (ค่าเริ่มต้น: เทคโนโลยี) |
| sourceLanguage | string | ไม่ | รหัสภาษาต้นทาง (ตรวจจับอัตโนมัติหากไม่ได้ระบุ) |
| region | string | ไม่ | ภูมิภาคเฉพาะสำหรับการแปลเป็นภาษาท้องถิ่น (เช่น 'สเปน', 'เม็กซิโก', 'บราซิล') |
| targetLanguages | array | ไม่ | อาร์เรย์ของรหัสภาษาปลายทาง (เช่น ['es', 'fr', 'zh-CN']) - สำหรับการแปลหลายภาษา ไม่สามารถใช้ร่วมกับ targetLanguage ได้ |
| context | string | ไม่ | บริบทหรือคำแนะนำเพิ่มเติมสำหรับการแปล (เช่น 'เก็บคำศัพท์ทางเทคนิคเป็นภาษาอังกฤษ', 'ใช้น้ำเสียงทางการ', 'เก็บชื่อแบรนด์') |
| pseudoTranslation | boolean | ไม่ | เปิดใช้โหมดการแปลเทียมสำหรับการทดสอบการใช้งานระหว่างประเทศโดยไม่ใช้การแปลด้วย AI และไม่มีค่าใช้จ่าย การแปลงข้อความด้วยเครื่องหมายเสียงหนัก วงเล็บ และอักขระ CJK เพื่อระบุสตริงที่ยังไม่ได้แปลและทดสอบเค้าโครง UI (ค่าเริ่มต้น: false) |
| pseudoOptions | object | ไม่ | ตัวเลือกการกำหนดค่าสำหรับการแปลเทียม (ใช้เฉพาะเมื่อ pseudoTranslation เป็นจริง) |
| skipWarnings | boolean | ไม่ | ข้ามคำเตือนคุณภาพข้อความต้นฉบับและดำเนินการแปลต่อ (ค่าเริ่มต้น: false) เมื่อเป็นเท็จ จะส่งคำเตือนเกี่ยวกับข้อความต้นฉบับที่มีปัญหา (เช่น วลีที่แปลยาก ปัญหาการผันพจน์ ข้อกังวลเกี่ยวกับการขยายข้อความ) กลับมาในการตอบสนองภายใต้ฟิลด์ 'validationSuggestions' เมื่อเป็นจริง คำเตือนเหล่านี้จะถูกปิดกั้นเพื่อให้ได้ผลลัพธ์ที่สะอาด (ค่าเริ่มต้น: false) |
รับประมาณการค่าใช้จ่ายการแปล
POST /translations/estimate
คำนวณจำนวนคำและเครดิตที่ต้องใช้สำหรับการแปล
curl -X POST "https://api.i18nagent.ai/translations/estimate" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/estimate', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/estimate',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/estimate", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างเช่นนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์ของเนื้อหาคำขอ
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| content | string | ใช่ | เนื้อหาที่จะวิเคราะห์ |
| fileType | string | ไม่ | ประเภทไฟล์สำหรับการวิเคราะห์เนื้อหา (ค่าเริ่มต้น: txt) |
การวิเคราะห์
วิเคราะห์เนื้อหาเพื่อความพร้อมในการแปล
POST /analyze
การตรวจสอบข้อความต้นฉบับแบบเบาเพื่อระบุปัญหาที่อาจเกิดขึ้นก่อนการแปล ส่งคืนผลการตรวจสอบพร้อมรหัสข้อผิดพลาดสำหรับการเข้าถึงแบบโปรแกรม endpoint นี้ไม่ใช้เครดิต - ทำการตรวจสอบแบบกำหนดได้อย่างรวดเร็วโดยไม่มีการเรียก AI/LLM
curl -X POST "https://api.i18nagent.ai/analyze" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/analyze', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/analyze',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/analyze", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์ของ Request Body
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| targetLanguage | string | ใช่ | รหัสภาษาเป้าหมายสำหรับการแปล |
| targetAudience | string | ไม่ | กลุ่มเป้าหมาย (ค่าเริ่มต้น: ทั่วไป) |
| industry | string | ไม่ | บริบทอุตสาหกรรม (ค่าเริ่มต้น: ทั่วไป) |
| sourceLanguage | string | ไม่ | รหัสภาษาต้นทาง (ตรวจจับอัตโนมัติหากไม่ได้ระบุ) |
| region | string | ไม่ | ภูมิภาคเฉพาะสำหรับการแปลเป็นภาษาท้องถิ่น |
| content | object | ใช่ | เนื้อหาที่จะวิเคราะห์ (ข้อความ, อาร์เรย์ของข้อความ หรือออบเจกต์ที่มีโครงสร้าง) |
| fileType | string | ไม่ | ประเภทไฟล์เสริม หากเนื้อหามาจากไฟล์ |
การแปลเนมสเปซ
อัปโหลดไฟล์การแปลสำหรับการนำเนมสเปซกลับมาใช้ใหม่
POST /namespaces/{namespace}/translations/upload
อัปโหลดไฟล์แปลที่มีอยู่ไปยังเนมสเปซเพื่อนำกลับมาใช้ในอนาคต สิ่งนี้ช่วยให้สามารถลดต้นทุนได้โดยการนำสตริงที่แปลไว้แล้วกลับมาใช้ใหม่ ไฟล์จะถูกประมวลผลและคู่การแปลจะถูกดึงออกมาเพื่อเก็บในแคช
curl -X POST "https://api.i18nagent.ai/namespaces/{namespace}/translations/upload" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/namespaces/{namespace}/translations/upload', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/namespaces/{namespace}/translations/upload',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/namespaces/{namespace}/translations/upload", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นจะส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสืบค้น
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| namespace | ใช่ | ตัวระบุเนมสเปซ (3-50 อักขระ ตัวอักษรและตัวเลขเท่านั้น รวมถึงขีดกลางและขีดล่าง) |
รับสถิติการแปลของเนมสเปซ
GET /namespaces/{namespace}/translations/stats
รับสถิติเกี่ยวกับไฟล์แปลที่อัปโหลดและการนำแคชกลับมาใช้สำหรับเนมสเปซ
curl -X GET "https://api.i18nagent.ai/namespaces/{namespace}/translations/stats" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/namespaces/{namespace}/translations/stats', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/namespaces/{namespace}/translations/stats',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/namespaces/{namespace}/translations/stats", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การค้นหา
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| namespace | ใช่ | ตัวระบุเนมสเปซ |
แสดงรายการไฟล์แปลที่อัปโหลดในเนมสเปซ
GET /namespaces/{namespace}/translations/files
รับรายการแบบแบ่งหน้าของไฟล์แปลที่อัปโหลดสำหรับเนมสเปซ
curl -X GET "https://api.i18nagent.ai/namespaces/{namespace}/translations/files" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/namespaces/{namespace}/translations/files', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/namespaces/{namespace}/translations/files',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/namespaces/{namespace}/translations/files", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การค้นหา
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| namespace | ใช่ | ตัวระบุเนมสเปซ |
| limit | ไม่ | จำนวนไฟล์สูงสุดที่จะส่งคืน |
| offset | ไม่ | จำนวนไฟล์ที่จะข้ามสำหรับการแบ่งหน้า |
ลบไฟล์การแปลที่อัปโหลด
DELETE /namespaces/{namespace}/translations/files/{fileId}
ลบไฟล์การแปลที่อัปโหลดและคู่การแปลทั้งหมดออกจากแคช
curl -X DELETE "https://api.i18nagent.ai/namespaces/{namespace}/translations/files/{fileId}" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/namespaces/{namespace}/translations/files/{fileId}', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.delete(
'https://api.i18nagent.ai/namespaces/{namespace}/translations/files/{fileId}',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("DELETE", "https://api.i18nagent.ai/namespaces/{namespace}/translations/files/{fileId}", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การค้นหา
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| namespace | ใช่ | ตัวระบุเนมสเปซ |
| fileId | ใช่ | ไฟล์ ID ที่จะลบ |
อัปโหลดไฟล์แปลแบบขนาน
POST /translations/upload-parallel
อัปโหลดไฟล์ต้นทางและปลายทางแบบขนานสำหรับการแยกคู่แปลและแคช โดยไฟล์ทั้งสองควรมีโครงสร้างและประเภทไฟล์เดียวกัน
curl -X POST "https://api.i18nagent.ai/translations/upload-parallel" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/upload-parallel', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/upload-parallel',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/upload-parallel", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON โครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
ไฟล์
ดาวน์โหลดไฟล์จากที่เก็บข้อมูล
GET /files/{filePath}
ให้บริการไฟล์จากที่เก็บข้อมูลในเครื่อง (การพัฒนา) หรือ S3 (การผลิต) ใช้สำหรับเข้าถึงไฟล์ที่อัปโหลดและแปลแล้ว
curl -X GET "https://api.i18nagent.ai/files/{filePath}" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/files/{filePath}', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/files/{filePath}',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/files/{filePath}", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
คำสั่งข้างต้นส่งคืน JSON ที่มีโครงสร้างดังนี้:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2024-01-15T12:00:00.000Z"
}
}
พารามิเตอร์การสอบถาม
| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
| filePath | ใช่ | เส้นทางไฟล์รวมถึงไดเรกทอรีย่อย (เช่น 'uploads/test-file.json' หรือ 'translations/result.json') |
ข้อผิดพลาด
API ของ i18n-agent ใช้รหัสข้อผิดพลาดต่อไปนี้:
| รหัสข้อผิดพลาด | ความหมาย |
|---|---|
| 400 | คำขอไม่ถูกต้อง -- คำขอของคุณไม่ถูกต้อง |
| 401 | ไม่ได้รับอนุญาต -- คีย์ API ของคุณไม่ถูกต้อง |
| 402 | ต้องชำระเงิน -- เครดิตในบัญชีของคุณไม่เพียงพอ |
| 403 | ต้องห้าม -- คีย์ API ของคุณไม่ได้ใช้งานหรือไม่พบทีม |
| 404 | ไม่พบ -- ไม่สามารถค้นหาทรัพยากรที่ระบุได้ |
| 500 | ข้อผิดพลาดภายในเซิร์ฟเวอร์ -- เรามีปัญหากับเซิร์ฟเวอร์ของเรา กรุณาลองอีกครั้งในภายหลัง |
| 503 | บริการไม่พร้อมใช้งาน -- เราปิดให้บริการชั่วคราวเพื่อการบำรุงรักษา กรุณาลองอีกครั้งในภายหลัง |
รูปแบบการตอบสนองข้อผิดพลาด
{
"error": "Detailed error message describing what went wrong",
"success": false
}