usepolylingo / polylingo
Official PHP SDK for the PolyLingo translation API
v0.1.0
2026-04-10 23:20 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.8
- psr/http-client: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2026-04-10 23:25:48 UTC
README
PHP client for the PolyLingo translation API.
Requires PHP 7.4 or newer.
Install
composer require usepolylingo/polylingo
Quick start
<?php use PolyLingo\PolyLingo; $client = new PolyLingo([ 'apiKey' => getenv('POLYLINGO_API_KEY'), // 'baseURL' => 'https://api.usepolylingo.com/v1', // 'timeout' => 120_000, ]); $r = $client->translate([ 'content' => '# Hello', 'targets' => ['es', 'fr'], 'format' => 'markdown', ]); echo $r['translations']['es'];
API
| Method | Notes |
|---|---|
$client->health() |
GET /health |
$client->languages() |
GET /languages |
$client->translate([...]) |
POST /translate |
$client->batch([...]) |
POST /translate/batch |
$client->usage() |
GET /usage |
$client->jobs->create([...]) |
POST /jobs (202) |
$client->jobs->get($jobId) |
GET /jobs/:id |
$client->jobs->translate([...]) |
Submit job, poll until done (pollInterval, timeout, onProgress) |
Responses are associative arrays matching the JSON API (e.g. translations, usage).
Errors
PolyLingo\Errors\PolyLingoException is the base type (getHttpStatus(), getErrorCode(), getMessage()). Subclasses: AuthException (401), RateLimitException (429, optional getRetryAfter()), JobFailedException (failed or timed-out job, includes getJobId()).
Documentation
Repository
github.com/UsePolyLingo/polylingo-php
License
MIT