DeepLX API

萌森
萌森
发布于 2024-09-19 / 4 阅读
0
0

DeepLX API

强大的 DeepL 翻译 API,您可以将 DeepLX 集成到任何应用程序中。

官网

DeepL 官网

https://www.deepl.com/

DeepLX

https://deeplx.owo.network/https://github.com/OwO-Network/DeepLX

安装教程

由于 Deepl API 网络问题,我们建议您自备网络代理。

通过 Docker-Compose

https://github.com/QYG2297248353/appstore-1panel/tree/custom/apps/deeplxhttps://git.lifebus.top/Ms-Studio/appstore-1panel/src/branch/custom/apps/deeplx

通过 1Panel 安装

安装第三方应用商店:Docker 应用商店 - 1Panel 版本

完成安装

API 端点

/translate

终端 - 免费版

模拟 DeepL iOS 客户端以发起翻译请求。不限次数,但在一定时间内频繁请求会导致 429 错误。

请求方式:POST

请求头部

标题 描述 价值
Content-Type 请求主体的内容类型。 application/json
Authorization 保护您的 API 所用的访问令牌。 Bearer your_access_token

请注意,如果无法通过 Authorization ,您也可以使用 URL 参数代替。例如, /translate?token=your_access_token

请求参数

参数 类型 描述 所需
text string 要翻译的文本。 true
source_lang string 源文本的语言代码。 true
target_lang string 您想要翻译成的语言代码。 true

请求响应

{
  "alternatives": [
    "Did you hear about this?",
    "You've heard about this?",
    "You've heard of this?"
  ],
  "code": 200,
  "data": "Have you heard about this?",
  "id": 8356681003,
  "method": "Free",
  "source_lang": "ZH",
  "target_lang": "EN"
}

/v1/translate

终端 - 专业版

模拟 DeepL Pro 账号以发起翻译请求。无限制,这可能有效地避免 429 问题,但你需要提供 Pro 账号的 dl_session 参数,否则无法使用。

请求方式:POST

请求头部

标题 描述 价值
Content-Type 请求主体的内容类型。 application/json
Authorization 保护您的 API 所用的访问令牌。 Bearer your_access_token

请注意,如果无法通过 Authorization ,您也可以使用 URL 参数代替。例如, /translate?token=your_access_token

请求参数

参数 类型 描述 所需
text string 要翻译的文本。 true
source_lang string 源文本的语言代码。 true
target_lang string 您想要翻译成的语言代码。 true

请求响应

{
  "alternatives": [
    "Did you hear about this?",
    "You've heard about this?",
    "You've heard of this?"
  ],
  "code": 200,
  "data": "Have you heard about this?",
  "id": 8356681003,
  "method": "Pro",
  "source_lang": "ZH",
  "target_lang": "EN"
}

/v2/translate

终端 - 官方版

模拟 DeepL 官方 API 发起翻译请求。不限次数,但在一定时间内频繁请求会导致 429 错误。

请求方式:POST

请求头部

标题 描述 价值
Content-Type 请求主体的内容类型。 application/json
Authorization 保护您的 API 所用的访问令牌。 Authorization: DeepL-Auth-Key [yourAccessToken]

请注意,如果您想同时传递两个参数,请用空格将它们分隔开。

请求参数

参数 类型 描述 所需
text string 要翻译的文本。 true
source_lang string 源文本的语言代码。 true
target_lang string 您想要翻译成的语言代码。 true

请求响应

{
  "alternatives": [
    "Did you hear about this?",
    "You've heard about this?",
    "You've heard of this?"
  ],
  "code": 200,
  "data": "Have you heard about this?",
  "id": 8356681003,
  "method": "Pro",
  "source_lang": "ZH",
  "target_lang": "EN"
}

集成

沉浸式翻译

不建议您使用 DeepLX 服务进行沉浸式翻译。这是因为沉浸式翻译会在短时间内发起大量请求,可能导致您的 IP 被 DeepL 封锁。

https://blog.lifebus.top/archives/a3a88e94-8add-4401-ac88-b8f935707857

cURL

可快速测试 API 是否正常,或临时使用。

curl -X POST http://localhost:1188/translate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_access_token" \
-d '{
    "text": "Hello, world!",
    "source_lang": "EN",
    "target_lang": "DE"
}'


评论