Python
Example of a request using the python
. Your need to install the httpx
package first.
bash
pip install httpx
Free Endpoint
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)
Pro Endpoint
python
import httpx, json
deeplx_api = "http://127.0.0.1:1188/v1/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)
Official Endpoint
python
import httpx, json
deeplx_api = "http://127.0.0.1:1188/v2/translate"
data = {
"text": [
"Hello, world!"
],
"target_lang": "DE"
}
post_data = json.dumps(data)
r = httpx.post(url = deeplx_api, data = post_data).text
print(r)