From 8962de8755653660e1529a5055ebdca12a7b38de Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 10 Feb 2022 12:46:02 -0500 Subject: [PATCH] Add auto-detect example --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d90bde..747ea66 100644 --- a/README.md +++ b/README.md @@ -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: