API Documentation
Back to App

LinguaFlow API

AI-powered translation, OCR, document extraction, and audio/video transcription with streaming support, glossary memory, and 40+ languages.

Overview

The LinguaFlow API provides a unified interface for:

All endpoints accept optional memory (glossary terms and instructions) passed by the client to customise translations.

Base URL

All endpoints route through a single URL using the action query parameter:

api.do?action={endpoint}

For example, to translate text:

POST /api.do?action=translate HTTP/1.1
Host: your-domain.com
Authorization: Bearer demo
Content-Type: application/json

Authentication

All endpoints (except languages and openapi) require a Bearer token in the Authorization header:

Authorization: Bearer YOUR_API_KEY

A dev key is available to test, the same is used in the frontend: demo.

⚠ For production use, replace the demo key with your provided API key.

Error Handling

Errors return a JSON object with an error string and an appropriate HTTP status code:

{
  "error": "Parameter \"text\" is required."
}
StatusMeaning
400Bad request β€” missing or invalid parameters
401Unauthorized β€” missing or invalid API key
404Endpoint not found β€” invalid action parameter
405Method not allowed β€” wrong HTTP method
413Request body too large
422Unprocessable β€” e.g. no text found in image, no speech in audio
502Upstream error β€” the AI model returned an error

For streaming requests, errors are delivered as SSE events:

event: error
data: {"error":"No speech detected in the audio."}

Streaming (SSE)

Set stream to true (JSON) or "1" (form-data) to receive results as Server-Sent Events. The response uses Content-Type: text/event-stream.

Event types

EventDescription
(default)Translation chunk: data: {"content":"partial text..."}
extractedOCR/transcription/extraction result (image, document, video, audio): data: {"extracted_text":"..."}
doneStream complete: data: [DONE]
errorError: data: {"error":"..."}

For image/document/video/audio endpoints, the extracted event fires first with the OCR, extracted text, or transcription, then translation chunks stream in.

Memory Bank

Glossary terms and custom instructions are client-side β€” no user data is stored on the server. Include an optional memory object with translation requests:

{
  "memory": {
    "glossary": [
      {
        "source_term": "cloud computing",
        "target_term": "computaciΓ³n en la nube",
        "source_lang": "en",
        "target_lang": "es"
      }
    ],
    "instructions": [
      { "text": "Always use British English spelling", "active": true },
      { "text": "Keep brand names in original language", "active": true }
    ]
  }
}

For multipart/form-data requests (image, document, video, audio), send memory as a JSON-encoded string field.

Server-side limits: max 100 glossary entries (200 chars each), max 20 instructions (500 chars each). Only entries with "active": true are applied. Entries are filtered by matching source_lang and target_lang.

Translate Text

POST api.do?action=translate

Request body β€” application/json

FieldTypeRequiredDescription
textstringYesSource text to translate (max 5,000 characters)
target_langstringYesTarget language ISO 639-1 code (e.g. es)
source_langstringNoSource language code, or auto to detect (default: auto)
formalitystringNodefault, formal, or informal
streambooleanNoEnable SSE streaming (default: false)
memoryobjectNoClient-side glossary and instructions

Example request

curl -X POST "https://translate.demo.efficientstack.com/api.do?action=translate" \
  -H "Authorization: Bearer demo" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "The quick brown fox jumps over the lazy dog.",
    "target_lang": "es",
    "formality": "formal"
  }'

Response

{
  "translation": "El rΓ‘pido zorro marrΓ³n salta sobre el perro perezoso."
}

Detect Language

POST api.do?action=detect

Request body β€” application/json

FieldTypeRequiredDescription
textstringYesText sample to detect language from

Example

curl -X POST "https://translate.demo.efficientstack.com/api.do?action=detect" \
  -H "Authorization: Bearer demo" \
  -H "Content-Type: application/json" \
  -d '{"text": "Bonjour le monde"}'

Response

{
  "language": "fr"
}

Translate Image (OCR)

POST api.do?action=image

Extracts text from an image via OCR, then translates it. Supported formats: JPEG, PNG, GIF, WebP (max 7 MB).

Request β€” multipart/form-data

FieldTypeRequiredDescription
filefileYesImage file to process
target_langstringYesTarget language ISO 639-1 code
source_langstringNoSource language (default: auto)
formalitystringNodefault, formal, or informal
streamstringNo0 or 1 (default: 0)
memorystringNoJSON-encoded memory object

Example

curl -X POST "https://translate.demo.efficientstack.com/api.do?action=image" \
  -H "Authorization: Bearer demo" \
  -F "file=@sign.jpg" \
  -F "target_lang=de"

Response

{
  "extracted_text": "Welcome to our store\nOpen daily 9am - 6pm",
  "translation": "Willkommen in unserem GeschΓ€ft\nTΓ€glich geΓΆffnet 9:00 - 18:00 Uhr"
}

Translate Document

POST api.do?action=document

Extracts text from a document and translates it. For text-based files (TXT, CSV, Markdown, JSON, JavaScript, CSS), text is read directly for instant extraction. For binary or markup formats (PDF, HTML, XML, RTF), Gemini is used for intelligent text extraction.

Supported formats: PDF, TXT, HTML, CSV, XML, Markdown, RTF, JSON, JavaScript, CSS (max 7 MB). Extracted text is capped at 20,000 characters.

Request β€” multipart/form-data

FieldTypeRequiredDescription
filefileYesDocument file to process
target_langstringYesTarget language ISO 639-1 code
source_langstringNoSource language (default: auto)
formalitystringNodefault, formal, or informal
streamstringNo0 or 1 (default: 0)
memorystringNoJSON-encoded memory object

Example

curl -X POST "https://translate.demo.efficientstack.com/api.do?action=document" \
  -H "Authorization: Bearer demo" \
  -F "file=@report.pdf" \
  -F "target_lang=es"

Response

{
  "extracted_text": "Quarterly Report\n\nRevenue increased by 15% compared to the previous quarter...",
  "translation": "Informe Trimestral\n\nLos ingresos aumentaron un 15% en comparaciΓ³n con el trimestre anterior..."
}
Extraction modes: Text-based files (text/plain, text/csv, text/markdown, application/json, etc.) are read directly from the file for instant, lossless extraction. Binary and markup formats (application/pdf, text/html, text/xml, text/rtf) are processed by Gemini for intelligent text extraction and layout preservation.

Transcribe & Translate Video

POST api.do?action=video

Transcribes spoken content from a video file with speaker identification, then translates the transcription. Supported formats: MP4, WebM, MOV (max 7 MB).

Request β€” multipart/form-data

FieldTypeRequiredDescription
filefileYesVideo file to process
target_langstringYesTarget language ISO 639-1 code
source_langstringNoSource language (default: auto)
formalitystringNodefault, formal, or informal
streamstringNo0 or 1 (default: 0)
memorystringNoJSON-encoded memory object

Example

curl -X POST "https://translate.demo.efficientstack.com/api.do?action=video" \
  -H "Authorization: Bearer demo" \
  -F "file=@interview.mp4" \
  -F "target_lang=fr" \
  -F "stream=0"

Response

The transcription uses a speaker-labelled format with Markdown-bold speaker names:

{
  "transcription": "**Host:** Welcome to the show. Today we have a special guest.\n**Guest:** Thank you for having me. It's great to be here.\n**Host:** Let's dive right in.",
  "translation": "**PrΓ©sentateur :** Bienvenue dans l'Γ©mission. Aujourd'hui, nous avons un invitΓ© spΓ©cial.\n**InvitΓ© :** Merci de m'avoir invitΓ©. C'est formidable d'Γͺtre ici.\n**PrΓ©sentateur :** Allons-y directement."
}
Speaker format: Each line of the transcription follows the pattern **Speaker Name:** spoken text. The frontend renders this as a colour-coded conversation view. Each unique speaker is assigned a distinct colour.

Transcribe & Translate Audio

POST api.do?action=audio

Identical behaviour to the video endpoint but for audio files. Supported formats: MP3, WAV, OGG, M4A, AAC, FLAC, WebM (max 7 MB).

Request β€” multipart/form-data

Same fields as the video endpoint.

Example

curl -X POST "https://translate.demo.efficientstack.com/api.do?action=audio" \
  -H "Authorization: Bearer demo" \
  -F "file=@podcast.mp3" \
  -F "target_lang=ja"

Response

{
  "transcription": "**Speaker 1:** Hello everyone and welcome back.\n**Speaker 2:** Thanks for having me on the show.",
  "translation": "**スピーカー1:** ηš†γ•γ‚“γ€γ“γ‚“γ«γ‘γ―γ€‚γŠεΈ°γ‚Šγͺさい。\n**スピーカー2:** η•ͺη΅„γ«ε‘Όγ‚“γ§γ„γŸγ γγ‚γ‚ŠγŒγ¨γ†γ”γ–γ„γΎγ™γ€‚"
}

Supported Languages

GET api.do?action=languages No auth required

Response

{
  "languages": [
    { "code": "en", "name": "English" },
    { "code": "es", "name": "Spanish" },
    ...
  ]
}

All 40 supported languages

en English
es Spanish
fr French
de German
it Italian
pt Portuguese
pt-br Portuguese (BR)
ru Russian
zh Chinese (Simplified)
zh-tw Chinese (Traditional)
ja Japanese
ko Korean
ar Arabic
hi Hindi
nl Dutch
pl Polish
tr Turkish
sv Swedish
da Danish
no Norwegian
fi Finnish
cs Czech
ro Romanian
hu Hungarian
el Greek
he Hebrew
th Thai
vi Vietnamese
id Indonesian
ms Malay
uk Ukrainian
bg Bulgarian
hr Croatian
sk Slovak
sl Slovenian
et Estonian
lv Latvian
lt Lithuanian
ca Catalan
tl Filipino
sw Swahili
bn Bengali

OpenAPI Specification

GET api.do?action=openapi No auth required

Returns the full OpenAPI 3.0.3 JSON specification. Use it with tools like:

curl "https://translate.demo.efficientstack.com/api.do?action=openapi" | python -m json.tool