From 3791a825ee16acf163cef677bbb92eb565032f6e Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sun, 20 Dec 2020 16:13:38 -0500 Subject: [PATCH] Update README --- README.md | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aa402b3..2d14c0f 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,43 @@ # LibreTranslate -Free and Open Source Translation API. - -Entirely self-hosted and can work in offline environments. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. +Free and Open Source Translation API, entirely self-hosted and can work in offline environments. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. ![image](https://user-images.githubusercontent.com/1951843/102724116-32a6df00-42db-11eb-8cc0-129ab39cdfb5.png) [Try it online!](https://libretranslate.com) | [API Docs](https://libretranslate.com/docs) -Website: [libretranslate.com](https://libretranslate.com) +## API Examples + +Request: + +```javascript +const res = await fetch("https://libretranslate.com/translate", { + method: "POST", + body: JSON.stringify({ + q: "Hello!", + source: "en", + target: "es" + }), + headers: { + "Content-Type": "application/json" + }); + +console.log(await res.json()); +``` + +Response: + +```javascript +{ + "translatedText": "¡Hola!" +} +``` + ## Build and Run +You can run your own API server in just a few lines of setup! + Make sure you have installed Python (3.8 or higher), then simply issue: ```bash @@ -21,6 +47,8 @@ pip install -r requirements.txt python main.py [args] ``` +Then open a web browser to http://localhost:5000 + ## Arguments | Argument | Description | Default |