Skip to main content

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 Forbidden with error code DOMAIN_EMAIL_VERIFICATION_REQUIRED and 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 Authorization header. 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:

StatusExact response messageCauseHow to resolve
401Invalid authentication token or Firebase authentication requiredAuthorization header missing, expired, or invalid Firebase ID tokenSign in and resend the request with a valid Authorization: Bearer <FIREBASE_ID_TOKEN>
403Document translation requires an authenticated accountSigned in as a guest/anonymous userSign in with a regular (non-guest) account
403Audio translation requires authenticated accountSigned in as a guest/anonymous userSign in with a regular (non-guest) account
403Artifact translation is not enabled / The free artifact preview is not enabledYour plan does not include artifact translation, and the free preview is not availableUpgrade 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​

  1. Sign up for an XTranslator account — audio, image, and document translation are not available to guest sessions
  2. Authenticate with your account's Firebase ID token in the Authorization header
  3. Use the REST API directly (see the examples above)
  4. Start translating programmatically

Questions?​