API Documentation
Integrate XTranslator into your applications programmatically.
Overview
The XTranslator API allows developers to:
- Translate text programmatically
- Translate documents and images (same-format output)
- Translate audio files
- Integrate translation into workflows and build custom applications
Endpoints
Text Translation API
POST /api/v1/translations
- Real-time text translation
- Streaming responses
- Domain selection
- Multiple language pairs
Document Translation API
POST /api/v1/document/translate
- Translate documents while preserving the source format
- Asynchronous processing (returns a
trackingId, stream status via SSE) - Multi-page documents within the plan's page limit
Image Translation API
POST /api/v1/image/translate
- Translate a single image while preserving the source format
- Asynchronous processing (returns a
trackingId) - Returns the translated image artifact
Audio Translation API
POST /api/v1/audio/translate
- Transcription + translation
- Multiple audio formats
- Asynchronous processing (returns a
trackingId)
Authentication
All API endpoints — including audio, image, and document translation — require a signed-in XTranslator account and the account's Firebase ID token in the Authorization header using the Bearer scheme:
Authorization: Bearer <FIREBASE_ID_TOKEN>
Notes:
- The token is verified on every request. Missing, expired, or invalid tokens are rejected with
401 Unauthorized. - Audio, image, and document translation require an authenticated, non-guest account. An account signed in as a guest/anonymous user receives
403 Forbidden. - An email-unverified account can only spend its one-time taste grant. A request beyond that returns
403 Forbiddenwith error codeDOMAIN_EMAIL_VERIFICATION_REQUIREDand the message:Email verification required: verify your email to unlock your monthly credits and free previews.Verify your email to unlock monthly credits and free previews (details). - The token is only accepted in the
Authorizationheader. It must not be placed in a URL query parameter.
Audio / Image / Document Translation Endpoints
POST /api/v1/document/translate, POST /api/v1/image/translate, and POST /api/v1/audio/translate follow the authentication requirements above. The 401/403 responses below are intentional guard and entitlement behavior, not service errors:
| Status | Exact response message | Cause | How to resolve |
|---|---|---|---|
401 | Invalid authentication token or Firebase authentication required | Authorization header missing, expired, or invalid Firebase ID token | Sign in and resend the request with a valid Authorization: Bearer <FIREBASE_ID_TOKEN> |
403 | Document translation requires an authenticated account | Signed in as a guest/anonymous user | Sign in with a regular (non-guest) account |
403 | Audio translation requires authenticated account | Signed in as a guest/anonymous user | Sign in with a regular (non-guest) account |
403 | Artifact translation is not enabled / The free artifact preview is not enabled | Your plan does not include artifact translation, and the free preview is not available | Upgrade to a plan that includes artifact translation |
Additionally, an authenticated account with an unverified email receives a 403 EmailVerificationRequiredException — see Email Verification Required (403).
Request Example
Files are uploaded to the service's Firebase Storage bucket first (via the client SDK), then referenced by their gs:// URL. To submit a document for translation:
curl -X POST "https://XTranslator.app/api/v1/document/translate" \
-H "Authorization: Bearer $FIREBASE_ID_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fileUrl": "gs://<bucket>/uploads/<userId>/documents/my-doc.pdf",
"fileName": "my-doc.pdf",
"fileSize": 2048000,
"targetLanguage": "ja",
"sourceLanguage": "auto"
}'
On success the job is queued and a tracking ID is returned:
{
"trackingId": "a1b2c3d4-...",
"message": "Document artifact translation job queued successfully"
}
The exact same Authorization header applies to POST /api/v1/image/translate and POST /api/v1/audio/translate, which use the same request body fields.
Rate Limits
Rate limits are enforced per account and based on your subscription plan:
- Free: 200 requests/minute
- Starter: 300 requests/minute
- Pro: 500 requests/minute
- Ultimate: 1,000 requests/minute
When exceeded, the API responds with 429 Too Many Requests including a retryAfter value in seconds.
Pricing
API usage will consume credits from your account:
- Same credit system as web application
- No additional API fees
- Credits work across both web and API
See Credits System for details.
SDKs and Libraries
Planned SDK support:
- JavaScript/TypeScript (Node.js)
- Python
- PHP
- Ruby
- Go
Getting Started
- Sign up for an XTranslator account — audio, image, and document translation are not available to guest sessions
- Authenticate with your account's Firebase ID token in the
Authorizationheader - Use the REST API directly (see the examples above)
- Start translating programmatically
Questions?
- Contact Us for API inquiries
- FAQ for general questions