1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-24 10:06:43 +02:00

Add auto-detect example

This commit is contained in:
Piero Toffanin 2022-02-10 12:46:02 -05:00 committed by GitHub
parent a13a714b89
commit 8962de8755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,7 @@ Free and Open Source Machine Translation API, entirely self-hosted. Unlike other
## API Examples ## API Examples
### Plain Text ### Simple
Request: Request:
@ -40,6 +40,32 @@ Response:
} }
``` ```
### Auto Detect Language
Request:
```javascript
const res = await fetch("https://libretranslate.com/translate", {
method: "POST",
body: JSON.stringify({
q: "Ciao!",
source: "auto",
target: "en"
}),
headers: { "Content-Type": "application/json" }
});
console.log(await res.json());
```
Response:
```javascript
{
"translatedText": "Bye!"
}
```
### HTML (beta) ### HTML (beta)
Request: Request: