Skip to content

Custom Translation API Channel

What is it?

pyVideoTrans supports connecting to your own translation API service. If you've built a translation endpoint or use a third-party custom translation service, you can integrate it through this channel. The software sends translation requests as GET requests to the API address you provide.

Prerequisites

  • A working translation API endpoint
  • The endpoint must return JSON in the specified format

API Specification

Request Method

The software sends GET requests to the configured API URL, using the application/x-www-form-urlencoded format.

Request Parameters

ParameterTypeDescription
textstringThe text to translate (URL-encoded)
source_languagestringSource language code, e.g., zh, en, ja
target_languagestringTarget language code, e.g., zh, en, ja
secretstringOptional API key (configured in settings)

Supported Language Codes

zh, en, ja, ko, ru, de, fr, tr, th, vi, ar, hi, hu, es, pt, it

Response Format

The endpoint must return JSON:

json
{
    "code": 0,
    "msg": "ok",
    "text": "translated text"
}
FieldDescription
codeStatus code: 0 for success, >0 for failure
msgStatus message: ok on success, error reason on failure
textTranslated text (returned on success)

Configuring in pyVideoTrans

  1. Open the menu bar → Translation SettingsCustom Translation API Settings
  2. Enter your translation endpoint URL in the API URL field
    • For example: https://your-api.com/translate
    • The software automatically appends query parameters — no need to add them manually
  3. Optionally enter an API key in the Secret field
  4. Click the Test button to verify the endpoint is working
  5. Save after a successful test

Example: Using an Open-Source Translation API

A free translation API based on Cloudflare and M2M100 can be found at: https://github.com/jianchang512/translate-api

Deploy it and enter its URL into pyVideoTrans's custom translation API settings.

Troubleshooting

IssueCauseSolution
Connection failedAPI URL incorrectCheck the URL format and confirm the endpoint is reachable
Response format errorEndpoint doesn't match the expected formatEnsure the response JSON contains code, msg, and text fields
Empty translation resulttext field is emptyCheck if the endpoint logic correctly handles translation requests
Frequent errorsEndpoint has rate limitsIncrease the post-translation pause time