2022-10-20 02:11:14 +08:00
<!--
* @Author: Vincent Young
* @Date: 2022-10-18 07:32:29
2024-04-23 12:50:11 +08:00
* @LastEditors: Vincent Yang
* @LastEditTime: 2024-04-23 00:47:59
2022-10-20 02:23:16 +08:00
* @FilePath: /DeepLX/README.md
2022-10-20 02:11:14 +08:00
* @Telegram: https://t.me/missuo
*
* Copyright © 2022 by Vincent, All Rights Reserved.
-->
2023-11-09 04:24:20 +08:00
[![GitHub Workflow][1]](https://github.com/OwO-Network/DeepLX/actions)
[![Go Version][2]](https://github.com/OwO-Network/DeepLX/blob/main/go.mod)
[![Go Report][3]](https://goreportcard.com/badge/github.com/OwO-Network/DeepLX)
[![Maintainability][4]](https://codeclimate.com/github/OwO-Network/DeepLX/maintainability)
[![GitHub License][5]](https://github.com/OwO-Network/DeepLX/blob/main/LICENSE)
2023-11-09 04:25:53 +08:00
[![Docker Pulls][6]](https://hub.docker.com/r/missuo/deeplx)
2023-11-09 04:24:20 +08:00
[![Releases][7]](https://github.com/OwO-Network/DeepLX/releases)
2023-11-20 08:26:07 +08:00
[1]: https://img.shields.io/github/actions/workflow/status/OwO-Network/DeepLX/release.yaml?logo=github
2023-11-09 04:24:20 +08:00
[2]: https://img.shields.io/github/go-mod/go-version/OwO-Network/DeepLX?logo=go
[3]: https://goreportcard.com/badge/github.com/OwO-Network/DeepLX
[4]: https://api.codeclimate.com/v1/badges/b5b30239174fc6603aca/maintainability
[5]: https://img.shields.io/github/license/OwO-Network/DeepLX
2023-11-09 04:25:53 +08:00
[6]: https://img.shields.io/docker/pulls/missuo/deeplx?logo=docker
2023-11-09 04:24:20 +08:00
[7]: https://img.shields.io/github/v/release/OwO-Network/DeepLX?logo=smartthings
2022-10-20 02:11:14 +08:00
2023-07-23 20:42:10 +08:00
## **Related Projects**
2024-01-21 01:35:36 +08:00
| Link | Description | Maintainer |
| ------------------------------------------------------------------- | ----------------------------------- | --------------------------------------------------------------- |
| [OwO-Network/PyDeepLX ](https://github.com/OwO-Network/PyDeepLX ) | Python Package for DeepLX | [Vincent Yang ](https://github.com/missuo ) |
| [OwO-Network/gdeeplx ](https://github.com/OwO-Network/gdeeplx ) | Golang Package for DeepLX | [Vincent Yang ](https://github.com/missuo ) |
| [ifyour/deeplx ](https://github.com/ifyour/deeplx ) | JS Package for DeepLX (JavaScript) | [ifyour ](https://github.com/ifyour ) |
| [deeplx-serverless ](https://github.com/LegendLeo/deeplx-serverless ) | Serverless Package for DeepLX | [LegendLeo ](https://github.com/LegendLeo/deeplx-serverless ) |
2023-11-13 07:16:15 +08:00
2023-07-02 12:28:21 +08:00
## Discussion Group
[Telegram Group ](https://t.me/+8KDGHKJCxEVkNzll )
2022-10-20 02:23:16 +08:00
## Description
2023-04-23 13:25:47 +08:00
- `DeepLX` is listening to `0.0.0.0:1188` by default. You can modify the listening port by yourself.
- `DeepLX` is using `DeepL` Free API.
- `DeepLX` is unlimited to the number of requests.
2022-10-20 02:23:16 +08:00
2023-02-12 09:29:59 +08:00
## Usage
2023-11-28 04:04:46 +08:00
### For Developer
#### Request Parameters
2023-02-12 09:29:59 +08:00
- text: string
- source_lang: string
- target_lang: string
2023-11-28 04:04:46 +08:00
#### Response
2023-02-12 09:29:59 +08:00
```json
{
2023-03-16 20:25:44 +08:00
"alternatives": [
2023-11-28 04:04:46 +08:00
"Did you hear about this?",
"You've heard about this?",
"You've heard of this?"
2023-03-16 20:25:44 +08:00
],
2023-02-12 09:29:59 +08:00
"code": 200,
2023-11-28 04:04:46 +08:00
"data": "Have you heard about this?",
"id": 8356681003,
"method": "Free",
2023-09-15 01:59:15 +08:00
"source_lang": "ZH",
"target_lang": "EN"
2023-02-12 09:29:59 +08:00
}
```
2023-11-28 04:04:46 +08:00
### Custom Options
**The following settings are optional and not required.**
- `-port` or `-p` : Listening port. Default is `1188` .
2024-03-07 22:49:14 +08:00
- `-token` : Access token. If you have set it up, each request needs to include `Authorization` in the **Headers** or `token` parameter in the **URL Params** .
2023-11-28 13:24:41 +08:00
- `-authkey` : DeepL Official `AuthKey` . If you have set it up, after the 429 response, the official AuthKey will be used for the request. If multiple authKeys are used simultaneously, they need to be separated by commas.
2024-04-23 12:50:11 +08:00
- `s` : `dl-session` is the cookie for a **DeepL Pro** account. If you set this, you will be able to use another endpoint `/v1/translate` , which can effectively avoid 429.
2024-04-17 02:54:18 +08:00
- `/v2/translate` : This endpoint is fully compatible with the DeepL official API. When using this endpoint, please strictly adhere to the request styles outlined in the official DeepL documentation. Note that in this endpoint, please use `DeepL-Auth-Key $token` in the `Authorization` , which is actually the Access Token, not the official `Auth Key` of DeepL.
2023-10-29 10:48:58 +08:00
2024-04-23 12:50:11 +08:00
2024-04-17 03:11:38 +08:00
#### Example of requesting a token-protected `/v2/translate` endpoint
2024-04-17 02:54:18 +08:00
```bash
2024-04-17 03:11:38 +08:00
curl -X POST 'http://localhost:1188/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [yourAccessToken] [yourAuthKey]' \
2024-04-17 02:54:18 +08:00
--header 'Content-Type: application/json' \
--data '{
"text": [
"Hello, world!"
],
"target_lang": "DE"
}'
2024-04-17 03:11:38 +08:00
# Please note that either `yourAccessToken` or `yourAuthKey` can be omitted.
2023-10-29 10:48:58 +08:00
```
2024-04-17 02:54:18 +08:00
#### Requesting a token-protected **DeepLX API** instance using the `curl`
```bash
2023-10-29 10:48:58 +08:00
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"
}'
2023-04-23 13:25:47 +08:00
```
2024-03-07 15:10:51 +08:00
or
2024-04-17 02:54:18 +08:00
```bash
2024-03-07 15:10:51 +08:00
curl -X POST http://localhost:1188/translate?token=your_access_token \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world!",
"source_lang": "EN",
"target_lang": "DE"
}'
```
2023-02-12 09:29:59 +08:00
2023-03-06 20:48:26 +08:00
### Run with Docker
```bash
2023-03-07 03:05:22 +08:00
# ghcr.io
2023-03-06 20:48:46 +08:00
docker run -itd -p 1188:1188 ghcr.io/owo-network/deeplx:latest
2023-03-07 03:05:22 +08:00
2023-11-28 04:04:46 +08:00
# custom environment variables
2024-04-23 12:50:11 +08:00
docker run -itd -p 1188:1188 -e "TOKEN=helloxxx" -e "AUTHKEY=xxxx:fx" -e "DL_SESSION=xxxxx" ghcr.io/owo-network/deeplx:latest
2023-11-28 04:04:46 +08:00
2023-03-07 03:05:22 +08:00
# dockerhub
docker run -itd -p 1188:1188 missuo/deeplx:latest
2023-11-28 04:04:46 +08:00
# custom environment variables
2024-04-23 12:50:11 +08:00
docker run -itd -p 1188:1188 -e "TOKEN=helloxxx" -e "AUTHKEY=xxxx:fx" -e "DL_SESSION=xxxxx" missuo/deeplx:latest
2023-03-06 20:48:26 +08:00
```
2023-03-07 03:12:31 +08:00
### Run with Docker Compose
```bash
mkdir deeplx
cd deeplx
2023-11-28 04:04:46 +08:00
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/compose.yaml
# modify environment variables
# environment:
# - TOKEN=helloxxx
# - AUTHKEY=xxxxxxx:fx
2024-04-23 12:50:11 +08:00
# - DL_SESSION=xxxxx
2023-11-28 04:04:46 +08:00
# docker compose
2023-03-17 17:27:19 +08:00
docker compose up -d
2023-03-07 03:12:31 +08:00
```
2023-02-18 21:01:05 +08:00
### Run on Linux Server
```bash
2023-05-30 01:27:53 +08:00
bash < (curl -Ls https://raw.githubusercontent.com/OwO-Network/DeepLX/main/install.sh)
# or
2024-02-01 12:12:26 +08:00
bash < (curl -Ls https://owo.nz/deeplx)
2023-02-18 21:01:05 +08:00
```
2023-02-12 09:29:59 +08:00
### Run on Mac
2023-03-02 23:22:26 +08:00
#### Homebrew (Recommended)
2023-03-02 11:51:56 +08:00
```bash
brew tap owo-network/brew
brew install deeplx
brew services start owo-network/brew/deeplx
2023-03-03 02:26:49 +08:00
2023-03-03 02:27:30 +08:00
# Update to the latest version
2023-03-03 02:26:49 +08:00
brew update
brew upgrade deeplx
brew services restart owo-network/brew/deeplx
2023-03-03 02:31:10 +08:00
# View the currently installed version
brew list --versions deeplx
2023-03-02 11:51:56 +08:00
```
#### Manual
2023-02-12 09:46:30 +08:00
1. Download the latest release of DeepL X.
2022-10-20 02:11:14 +08:00
```bash
sudo mv deeplx_darwin_amd64 /usr/local/bin/deeplx
2023-02-20 16:46:48 +08:00
sudo chmod +x /usr/local/bin/deeplx
2022-10-20 02:11:14 +08:00
```
2023-02-18 20:28:10 +08:00
2. Download the `me.missuo.deeplx.plist` to `~/Library/LaunchAgents` .
2022-10-20 02:11:14 +08:00
```bash
2023-02-18 19:46:43 +08:00
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/me.missuo.deeplx.plist -O ~/Library/LaunchAgents/me.missuo.deeplx.plist
2022-10-20 02:11:14 +08:00
```
3. Run following command.
```bash
2023-02-18 19:46:43 +08:00
launchctl load ~/Library/LaunchAgents/me.missuo.deeplx.plist
launchctl start ~/Library/LaunchAgents/me.missuo.deeplx.plist
2022-10-20 02:11:14 +08:00
```
2023-02-16 20:38:33 +08:00
### Install from AUR
```bash
paru -S deeplx-bin
```
2023-02-24 21:37:01 +08:00
After installation, start the daemon with the following command.
2023-02-16 20:38:33 +08:00
```bash
systemctl daemon-reload
systemctl enable deeplx
```
2023-12-25 12:12:11 +08:00
2024-03-02 15:43:54 +08:00
**Special thanks to [AsukaMinato ](https://github.com/asukaminato0721 ) for maintaining the updates of [ArchLinux packages ](https://aur.archlinux.org/packages/deeplx-bin ).**
2023-12-25 12:12:11 +08:00
### Run on Sealos
[![ ](https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg )](https://cloud.sealos.io/?openapp=system-template%3FtemplateName%3Ddeeplx)
2022-10-20 02:11:14 +08:00
## Setup on [Bob App](https://bobtranslate.com/)
2023-03-05 22:10:58 +08:00
1. Install [bob-plugin-deeplx ](https://github.com/missuo/bob-plugin-deeplx ) on Bob.
2022-10-20 02:11:14 +08:00
2023-03-07 04:10:38 +08:00
2. Setup the API. (If you use Brew to install locally you can skip this step)
2024-03-02 15:46:03 +08:00
![c5c19dd89df6fae1a256d ](./img/c5c19dd89df6fae1a256d.png )
2022-10-20 02:11:14 +08:00
2023-02-28 18:15:54 +08:00
## Setup on [immersive-translate](https://github.com/immersive-translate/immersive-translate)
2023-03-07 04:58:17 +08:00
**It is not recommended, because the `immersive-translate` will send many requests in a short time, which will cause the `DeepL API` to block your IP.**
2023-02-28 18:15:54 +08:00
1. Install Latest [immersive-translate ](https://github.com/immersive-translate/immersive-translate/releases ) on your browser.
2. Click on **Developer Settings** in the bottom left corner. **Enable Beta experimental features** .
2023-03-07 04:40:44 +08:00
3. Set the URL. (If you are not deploying locally, you need to change 127.0.0.1 to the IP of your server)
2023-03-04 16:57:28 +08:00
2024-03-02 15:46:03 +08:00
![6a48ba28621f2465028f0 ](./img/6a48ba28621f2465028f0.png )
2023-02-28 18:15:54 +08:00
2023-03-21 16:56:08 +08:00
## Use in Python
```python
import httpx, json
deeplx_api = "http://127.0.0.1:1188/translate"
data = {
"text": "Hello World",
"source_lang": "EN",
"target_lang": "ZH"
}
post_data = json.dumps(data)
r = httpx.post(url = deeplx_api, data = post_data).text
print(r)
```
2023-02-24 21:37:01 +08:00
## Backup the Docker Image of zu1k
2023-02-12 09:29:59 +08:00
```shell
2023-02-18 21:29:55 +08:00
docker run -itd -p 1188:80 missuo/deeplx-bk
2023-02-12 09:29:59 +08:00
```
2023-02-24 21:37:01 +08:00
**This docker image is not related to this project, as the original author deleted the image, it is only for backup.**
2024-01-22 01:47:01 +08:00
## Acknowledgements
### Contributors
2024-01-24 06:35:48 +08:00
< a href = "https://github.com/OwO-Network/DeepLX/graphs/contributors" >
2024-01-22 01:47:01 +08:00
< img src = "https://contrib.rocks/image?repo=OwO-Network/DeepLX&anon=0" / >
< / a >
2024-01-23 00:08:39 +08:00
## Activity
![Alt ](https://repobeats.axiom.co/api/embed/5f473f85db27cb30028a2f3db7a560f3577a4860.svg "Repobeats analytics image" )
2023-11-09 04:49:21 +08:00
## License
[![FOSSA Status ](https://app.fossa.com/api/projects/git%2Bgithub.com%2FOwO-Network%2FDeepLX.svg?type=large )](https://app.fossa.com/projects/git%2Bgithub.com%2FOwO-Network%2FDeepLX?ref=badge_large)