API Reference
Translayer API
Integrate AI-powered visual translation into your workflow. Upload pages, track progress in real-time, download results.
Base URL: https://translayer.app/api
Authentication
The Translayer API uses your Firebase UID for authentication. Pass your userId in the request body.
Pro plan required. API access is available on the Pro plan ($199/month). Generate your API key in
Dashboard → Settings.
POST
/api/translate
Upload images for translation. Returns a job ID for tracking progress.
Request (multipart/form-data)
| Field | Type | Description |
|---|---|---|
| images | File[] | Page images (JPG, PNG, WebP). Required. |
| sourceLang | string | Source language or "auto" for detection. |
| targetLang | string | Target language (e.g. "pl", "en", "ja"). |
| mode | string | "fast" (0.5x credits), "standard" (1x), "advanced" (2x). |
| resolution | string | "original", "1K", "2K", "4K". |
| userId | string | Your Firebase UID. Required. |
| customPrompt | string | Optional translation instructions. |
Credit Cost Formula
credits = ceil(pages × resolution_multiplier × mode_multiplier)
Example (cURL)
curl -X POST https://translayer.app/api/translate \
-F "images=@page1.jpg" \
-F "images=@page2.jpg" \
-F "sourceLang=en" \
-F "targetLang=ja" \
-F "mode=standard" \
-F "resolution=2K" \
-F "userId=YOUR_FIREBASE_UID" Response
{
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"mode": "standard",
"creditsNeeded": 4
} 402 — Insufficient credits 400 — No files uploaded
GET
/api/jobs/:jobId/events
Real-time Server-Sent Events stream for translation progress.
Example (JavaScript)
const es = new EventSource('/api/jobs/' + jobId + '/events');
es.onmessage = (event) => {
const job = JSON.parse(event.data);
console.log(job.status, job.progress + '/' + job.total);
if (job.status === 'completed' || job.status === 'failed') {
es.close();
}
}; Event Payload
{
"id": "job-uuid",
"status": "processing", // pending | processing | completed | failed
"progress": 3,
"total": 10,
"currentFile": "page_003.jpg",
"results": [
{ "sourceFilename": "page_001.jpg", "url": "/api/outputs/..." }
]
} GET
/api/download/:jobId
Download all translated pages as a ZIP archive.
Example (cURL)
curl -o translated.zip https://translayer.app/api/download/JOB_ID File Retention
| Plan | Retention |
|---|---|
| Free | 3 days |
| Starter | 14 days |
| Standard | 30 days |
| Pro | 90 days |
404 — Job not found 410 — Expired
DELETE
/api/projects/:id
Delete a translation project and its output files.
Example (cURL)
curl -X DELETE https://translayer.app/api/projects/JOB_ID \
-H "Content-Type: application/json" \
-d '{"userId": "YOUR_FIREBASE_UID"}' 403 — Not authorized 404 — Not found
POST
/api/checkout
Create a Stripe Checkout session for subscription or credit pack purchase.
curl -X POST https://translayer.app/api/checkout \
-H "Content-Type: application/json" \
-d '{
"priceId": "price_xxx",
"mode": "subscription",
"userId": "YOUR_FIREBASE_UID"
}'
// Response: { "url": "https://checkout.stripe.com/..." } Complete Example (Python)
import requests, json, sseclient
BASE = "https://translayer.app/api"
UID = "your_firebase_uid"
# 1. Upload pages for translation
files = [("images", open(f"page_{i}.jpg", "rb")) for i in range(1, 6)]
data = {"sourceLang": "en", "targetLang": "ja", "mode": "standard",
"resolution": "2K", "userId": UID}
res = requests.post(f"{BASE}/translate", files=files, data=data)
job_id = res.json()["jobId"]
print(f"Job started: {job_id}")
# 2. Track progress via SSE
response = requests.get(f"{BASE}/jobs/{job_id}/events", stream=True)
client = sseclient.SSEClient(response)
for event in client.events():
job = json.loads(event.data)
print(f"{job['progress']}/{job['total']} - {job['status']}")
if job["status"] in ("completed", "failed"):
break
# 3. Download ZIP
if job["status"] == "completed":
zip_res = requests.get(f"{BASE}/download/{job_id}")
with open("translated.zip", "wb") as f:
f.write(zip_res.content)
print("Downloaded translated.zip") Rate Limits & Quotas
| Plan | Pages/month | Concurrent jobs | Max file size |
|---|---|---|---|
| Free | 10 | 1 | 5 MB |
| Starter | 75 | 2 | 10 MB |
| Standard | 500 | 5 | 25 MB |
| Pro | 1,000 | 10 | 50 MB |
Ready to integrate?
Start with the free tier or upgrade to Pro for full API access.
Get Started Free