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
### Plain Text
### Simple
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)
Request: