Skip to content
Snippets Groups Projects
Commit a41f5671 authored by Piero Toffanin's avatar Piero Toffanin
Browse files

Add HTML note in README, tweak swagger def

parent 0a7c8eba
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,9 @@ Free and Open Source Machine Translation API, entirely self-hosted. Unlike other
## API Examples
### Plain Text
Request:
```javascript
......@@ -36,6 +39,33 @@ Response:
}
```
### HTML
Request:
```javascript
const res = await fetch("https://libretranslate.com/translate", {
method: "POST",
body: JSON.stringify({
q: '<a href="#" class="green">Hello!</a>',
source: "en",
target: "es",
format: "html"
}),
headers: { "Content-Type": "application/json" }
});
console.log(await res.json());
```
Response:
```javascript
{
"translatedText": "<a href\"#='class=\"green\"'>¡Hola!</a>"
}
```
## Install and Run
You can run your own API server in just a few lines of setup!
......@@ -136,7 +166,6 @@ You can pass application arguments directly to Gunicorn via:
gunicorn --bind 0.0.0.0:5000 'wsgi:app(api_keys=True)'
```
## Manage API Keys
LibreTranslate supports per-user limit quotas, e.g. you can issue API keys to users so that they can enjoy higher requests limits per minute (if you also set `--req-limit`). By default all users are rate-limited based on `--req-limit`, but passing an optional `api_key` parameter to the REST endpoints allows a user to enjoy higher request limits.
......
......@@ -267,9 +267,14 @@ def create_app(args):
name: format
schema:
type: string
example: html or text
enum: [text, html]
default: text
example: text
required: false
description: The format of the source text
description: >
Format of source text:
* `text` - Plain text
* `html` - HTML markup
- in: formData
name: api_key
schema:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment