Giới thiệu

Chào mừng đến với API Dịch thuật i18n-agent! Dịch vụ dịch thuật được hỗ trợ bởi AI với khả năng thích ứng văn hóa

Tài liệu API này cung cấp thông tin toàn diện về tất cả các điểm cuối khả dụng, phương thức xác thực, định dạng yêu cầu/phản hồi và mã lỗi.

Cơ sở URLs

Môi trường URL
Phát triển http://localhost:8000
Sản xuất `https://api.i18nagent.Tín Dụng** - Mô hình định giá theo mức sử dụng
  • 🤖 Được Hỗ Trợ Bởi AI - Sử Dụng LLM Tiên Tiến Để Dịch Chính Xác

Xác Thực

Để xác thực, sử dụng mã này:

# 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()
}

Hãy chắc chắn thay thế i18n_your_api_key_here bằng khóa API của bạn.

API i18n-agent sử dụng khóa API để cho phép truy cập vào API. Bạn có thể lấy khóa API của mình từ bảng điều khiển tài khoản.

Khóa API phải được đưa vào tất cả các yêu cầu API đến máy chủ trong một tiêu đề trông như sau:

Authorization: Bearer i18n_your_api_key_here

Điểm Cuối

Tín Dụng

Lấy Tín Dụng Nhóm

GET /credits

Lấy số dư tín dụng hiện tại cho nhóm đã xác thực

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Ngôn ngữ

Danh sách các ngôn ngữ được hỗ trợ

GET /languages

Lấy danh sách tất cả các ngôn ngữ được hỗ trợ với xếp hạng chất lượng

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Công việc Dịch thuật

Lấy lịch sử dịch thuật

GET /translations

Lấy danh sách phân trang các công việc dịch thuật với các bộ lọc tùy chọn về trạng thái, loại, ngôn ngữ đích và phạm vi ngày

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
page Không Số trang cho phân trang
limit Không Số lượng mục trên mỗi trang
status Không Lọc theo trạng thái dịch thuật
type Không Lọc theo loại dịch thuật
targetLanguages Không Danh sách các mã ngôn ngữ đích để lọc, phân cách bằng dấu phẩy
fromDate Không Lọc các bản dịch được tạo sau ngày này
toDate Không Lọc các bản dịch được tạo trước ngày này

Lấy chi tiết bản dịch

GET /translations/{id}

Lấy chi tiết của một bản dịch cụ thể theo 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()
}

Lệnh trên trả về cấu trúc JSON như sau:

{
  "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"
  }
}

Tham số truy vấn

Tham số Bắt buộc Mô tả
id ID Dịch thuật

Lấy trạng thái dịch thuật

GET /translations/{id}/status

Lấy trạng thái của một công việc dịch thuật theo thời gian thực với theo dõi tiến độ chi tiết bao gồm: phần trăm tiến độ, thời gian đã trôi qua, thời gian ước tính còn lại, thông tin điểm kiểm tra, hoàn thành từng phần cho các bản dịch đa ngôn ngữ, và URLs tải xuống được ký trước cho các kết quả đã hoàn thành.

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()
}

Lệnh trên trả về cấu trúc JSON như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
id ID Dịch thuật

Tải xuống kết quả dịch thuật

GET /translations/{id}/result

Tải xuống nội dung đã được dịch

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
id ID Dịch
language Không Mã ngôn ngữ cho kết quả ngôn ngữ cụ thể

Tải xuống tệp gốc

GET /translations/{id}/original

Tải xuống tệp đã tải lên ban đầu

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
id ID Dịch

Tiếp tục dịch từ điểm kiểm tra

POST /translations/{id}/resume

Tiếp tục một bản dịch bị lỗi hoặc bị gián đoạn từ một điểm kiểm tra cụ thể hoặc tự động từ điểm kiểm tra thành công cuối cùng

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()
}

Lệnh trên trả về cấu trúc JSON như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
id ID Dịch

Tham số Nội dung Yêu cầu

Tham số Loại Bắt buộc Mô tả
checkpointId string Không ID điểm kiểm tra mờ để tiếp tục (được lấy từ điểm cuối trạng thái). Nếu không được cung cấp và autoDetect là true, sẽ tiếp tục từ điểm kiểm tra thành công cuối cùng.
continueToEnd boolean Không Có tiếp tục xử lý tất cả nội dung còn lại sau khi tiếp tục (mặc định: true)
autoDetect boolean Không Tự động phát hiện và tiếp tục từ điểm kiểm tra cuối cùng nếu checkpointId không được cung cấp (mặc định: true)

Lấy các công việc dịch đang hoạt động

GET /translations/jobs/active

Lấy danh sách các công việc dịch đang hoạt động hiện tại

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tải xuống kết quả dịch

POST /translations/{jobId}/download

Tải xuống kết quả dịch đã hoàn thành. Trả về liên kết tải xuống URLs được tổ chức theo ngôn ngữ. URLs hết hạn sau 24 giờ.

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số truy vấn

Tham số Bắt buộc Mô tả
jobId ID công việc dịch thuật

Tải xuống tệp dịch thuật cho ngôn ngữ cụ thể

GET /translations/{jobId}/files/{language}

Tải xuống một tệp dịch thuật duy nhất cho một ngôn ngữ đích cụ thể. Trả về nội dung tệp trực tiếp với tiêu đề Content-Type phù hợp.

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
jobId ID công việc dịch thuật
language Mã ngôn ngữ đích (ví dụ: 'es', 'fr', 'ja')

Tạo bản dịch với tiến trình phát trực tuyến

POST /translations/stream

Tạo bản dịch với Sự kiện được gửi từ Máy chủ (SSE) để cập nhật tiến độ theo thời gian thực. Chỉ hỗ trợ dịch thuật văn bản (không phải tệp). Trả về các cập nhật tiến độ theo thời gian thực dưới dạng sự kiện 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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Các Tham số Nội dung Yêu cầu

Tham số Loại Bắt buộc Mô tả
texts array Mảng các văn bản để dịch
targetLanguage string Không Mã ngôn ngữ đích (ví dụ: 'es', 'fr', 'ja') - để dịch một ngôn ngữ
targetAudience string Không Đối tượng mục tiêu (ví dụ: 'general', 'technical', 'casual', 'formal') (mặc định: general)
industry string Không Bối cảnh ngành (ví dụ: 'công nghệ', 'chăm sóc sức khỏe', 'tài chính') (mặc định: công nghệ)
sourceLanguage string Không Mã ngôn ngữ nguồn (tự động phát hiện nếu không được cung cấp)
region string Không Khu vực cụ thể để bản địa hóa (ví dụ: 'Tây Ban Nha', 'Mexico', 'Brazil')
targetLanguages array Không Mảng mã ngôn ngữ đích (ví dụ: ['es', 'fr', 'zh-CN']) - để dịch đa ngôn ngữ. Không thể sử dụng cùng với targetLanguage.
context string Không Bối cảnh hoặc hướng dẫn bổ sung cho bản dịch (ví dụ: 'Giữ các thuật ngữ kỹ thuật bằng tiếng Anh', 'Sử dụng giọng điệu chính thức', 'Giữ nguyên tên thương hiệu')
pseudoTranslation boolean Không Kích hoạt chế độ giả dịch để kiểm tra các triển khai i18n mà không cần dịch thuật AI và KHÔNG tốn phí. Chuyển đổi văn bản bằng dấu âm, dấu ngoặc và các ký tự CJK tùy chọn để xác định các chuỗi chưa được dịch và kiểm tra bố cục giao diện người dùng. (mặc định: sai)
pseudoOptions object Không Các tùy chọn cấu hình cho dịch giả giả (chỉ được sử dụng khi pseudoTranslation là true)
skipWarnings boolean Không Bỏ qua cảnh báo chất lượng văn bản nguồn và tiếp tục dịch (mặc định: false). Khi false, các cảnh báo về văn bản nguồn có vấn đề (ví dụ: cụm từ khó dịch, vấn đề về số nhiều, mối lo về việc mở rộng văn bản) sẽ được trả về trong phản hồi dưới trường 'validationSuggestions'. Khi true, các cảnh báo này sẽ bị chặn để có đầu ra sạch sẽ hơn. (mặc định: false)

Nhận ước tính chi phí dịch thuật

POST /translations/estimate

Tính số lượng từ và tín dụng cần thiết cho bản dịch

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Các tham số Nội dung Yêu cầu

Tham số Loại Bắt buộc Mô tả
content string Nội dung để phân tích
fileType string Không Loại tệp để phân tích nội dung (mặc định: txt)

Phân tích

Phân tích nội dung để kiểm tra sẵn sàng dịch thuật

POST /analyze

Xác thực nhẹ văn bản nguồn để xác định các vấn đề tiềm ẩn trước khi dịch. Trả về kết quả xác thực với mã lỗi để truy cập theo chương trình. Endpoint này KHÔNG tiêu thụ tín dụng - nó chạy xác thực nhanh, xác định mà không cần gọi 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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Các Tham Số Thân Yêu Cầu

Tham Số Loại Bắt Buộc Mô Tả
targetLanguage string Mã ngôn ngữ đích để dịch thuật
targetAudience string Không Đối tượng mục tiêu (mặc định: chung)
industry string Không Bối cảnh ngành (mặc định: chung)
sourceLanguage string Không Mã ngôn ngữ nguồn (tự động phát hiện nếu không được cung cấp)
region string Không Khu vực cụ thể để bản địa hóa
content object Nội dung để phân tích (văn bản, mảng văn bản, hoặc đối tượng có cấu trúc)
fileType string Không Loại tệp tùy chọn nếu nội dung là từ một tệp

Bản dịch Không gian tên

Tải lên tệp dịch thuật cho việc tái sử dụng không gian tên

POST /namespaces/{namespace}/translations/upload

Tải lên tệp dịch thuật hiện có vào một không gian tên để sử dụng trong tương lai. Điều này cho phép tối ưu hóa chi phí bằng cách tái sử dụng các chuỗi đã được dịch trước đó. Tệp được xử lý và các cặp dịch thuật được trích xuất để lưu vào bộ nhớ đệm.

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
namespace Mã định danh không gian tên (3-50 ký tự, chỉ chấp nhận chữ và số + dấu gạch ngang/gạch dưới)

Lấy thống kê dịch không gian tên

GET /namespaces/{namespace}/translations/stats

Lấy thống kê về các tập tin dịch đã tải lên và việc tái sử dụng bộ nhớ đệm cho một không gian tên

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
namespace Mã định danh không gian tên

Liệt kê các tập tin dịch đã tải lên trong không gian tên

GET /namespaces/{namespace}/translations/files

Lấy danh sách phân trang các tập tin dịch đã tải lên cho một không gian tên

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
namespace Định danh không gian tên
limit Không Số lượng tệp tối đa để trả về
offset Không Số lượng tệp để bỏ qua để phân trang

Xóa tệp dịch đã tải lên

DELETE /namespaces/{namespace}/translations/files/{fileId}

Xóa tệp dịch đã tải lên và tất cả các cặp dịch liên quan từ bộ nhớ cache

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
namespace Mã định danh Namespace
fileId ID Tệp để xóa

Tải lên các tệp dịch song song

POST /translations/upload-parallel

Tải lên các tệp nguồn và đích song song để trích xuất và lưu trữ cặp dịch. Cả hai tệp phải có cấu trúc và loại tệp giống nhau.

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Các tệp

Tải xuống tệp từ kho lưu trữ

GET /files/{filePath}

Phục vụ các tệp từ kho lưu trữ cục bộ (phát triển) hoặc S3 (sản xuất). Được sử dụng để truy cập các tệp đã tải lên và đã dịch.

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()
}

Lệnh trên trả về JSON có cấu trúc như sau:

{
  "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"
  }
}

Tham số Truy vấn

Tham số Bắt buộc Mô tả
filePath Đường dẫn tệp bao gồm bất kỳ thư mục con nào (ví dụ: 'uploads/test-file.json' hoặc 'translations/result.json')

Lỗi

API i18n-agent sử dụng các mã lỗi sau:

Mã Lỗi Ý Nghĩa
400 Yêu Cầu Không Hợp Lệ -- Yêu cầu của bạn không hợp lệ.
401 Chưa Được Ủy Quyền -- Khóa API của bạn không hợp lệ.
402 Yêu Cầu Thanh Toán -- Không đủ tín dụng trong tài khoản của bạn.
403 Bị Cấm -- Khóa API của bạn không hoạt động hoặc không tìm thấy nhóm.
404 Không Tìm Thấy -- Không thể tìm thấy tài nguyên được chỉ định.
500 Lỗi Máy Chủ Nội Bộ -- Chúng tôi gặp sự cố với máy chủ. Vui lòng thử lại sau.
503 Dịch Vụ Không Khả Dụng -- Chúng tôi tạm thời ngoại tuyến để bảo trì. Vui lòng thử lại sau.

Định Dạng Phản Hồi Lỗi

{
  "error": "Detailed error message describing what went wrong",
  "success": false
}