From cb6b324478e4c456dee86c39d5c6a9dc31ee8247 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 3 Jun 2024 13:08:16 -0400 Subject: [PATCH] Update README.md --- README.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b62f81c..11ae2d8 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Response: } ``` -### HTML (beta) +### HTML Request: @@ -97,6 +97,38 @@ Response: } ``` +### Alternative Translations + +Request: + +```javascript +const res = await fetch("https://libretranslate.com/translate", { + method: "POST", + body: JSON.stringify({ + q: "Hello", + source: "en", + target: "it", + format: "text", + alternatives: 3 + }), + headers: { "Content-Type": "application/json" } +}); + +console.log(await res.json()); +``` + +Response: + +```javascript +{ + "alternatives": [ + "Salve", + "Pronto" + ], + "translatedText": "Ciao" +} +``` + ## Install and Run You can run your own API server with just a few lines of setup!