Translate endpoint

POST/v1/translate

Translate xcstrings files and automatically create a GitHub PR with the translations. This endpoint is asynchronous—it returns a job ID that you can poll for status.

Request body

json
{
  "github_repo": "owner/repo",
  "files": [
    {
      "filename": "Localizable.xcstrings",
      "content": "<file content as string>"
    }
  ],
  "target_languages": ["de", "fr", "ja"],
  "source_language": "en",
  "translator": "bulk",
  "github_base_branch": "main",
  "branch_name": "autoglot/translations",
  "commit_message": "chore(i18n): update translations",
  "pr_title": "chore(i18n): update translations",
  "github_pat": "ghp_..."
}

Parameters

ParameterRequiredDescription
github_repoYesRepository in "owner/repo" format
filesYesArray of files with filename and content
target_languagesYesArray of target language codes
source_languageNoSource language (default: "en")
translatorNo"bulk" (fast, default) or "batch" (24h, 50% cheaper)
github_patNo*GitHub PAT (required if GitHub App not installed)
github_base_branchNoBase branch (default: "main")
branch_nameNoPR branch name (default: "autoglot/translations")
commit_messageNoCustom commit message
pr_titleNoCustom PR title

* Either install the autoglot GitHub App or provide a github_pat with repo access.

Response (202 Accepted)

json
{
  "job_id": "abc123",
  "status": "queued",
  "translator": "bulk",
  "message": "Translation job created. The PR will be created automatically when complete."
}

Check job status

Poll the job status using the job ID:

GET/v1/translate/:job_id
json
{
  "job_id": "abc123",
  "status": "completed",
  "translator": "bulk",
  "progress": 100,
  "total_strings": 42,
  "completed_strings": 42,
  "github_repo": "owner/repo",
  "github_pr_number": 123,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:31:00Z"
}

Example

bash
# Start translation job
curl -X POST https://api.autoglot.app/v1/translate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "github_repo": "myorg/myapp",
    "files": [
      {
        "filename": "Localizable.xcstrings",
        "content": "'"$(cat Localizable.xcstrings)"'"
      }
    ],
    "target_languages": ["de", "fr", "ja"],
    "github_pat": "ghp_xxxx"
  }'

# Check job status
curl https://api.autoglot.app/v1/translate/abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"