ZPK » APIS » ZPK Translate » Docs

ZPK Translate

An API to translate in more than 120 languages that beats Google Translate both in terms of translation quality and price per character.

ZPK Translate allows you to perform text and document translations using the latest translation technologies, an API that uses traditional algorithms created by humans, and also the latest advances in machine learning.

With the ZPK Translation API you will get more accurate translations, in less time, and at a lower price than our competitors.

API connection

Server and protocols involved.

API connection details
Server: https://zpk.systems
Scheme: HTTPS, secure connections only.
Protocol:
JSON recommended

Sending a JSON in the request body, and specifying a Content-Type: application/json header in the request

Files should be sent encoded as a base64 string.


Form-Data not recommended

Format used in web forms, not recommended. When sending a form_data request you can send all the fields separately. However if the request is very large we recommend that you send the content of the request in a single text field called _json (with an underscore).

This special parameter will be processed by our backend as if it were a regular JSON request.

The server to send the requests to is https://zpk.systems, using a secure HTTPS connection.

The recommended communication type is JSON, in which case we will specify in the connection a Content-Type: application/json, and we will send the request body as a valid JSON string.

Text translation

Endpoint & parameters

POST /api/translate/text
Parameter Description
application_id

string required

An application id. You can get the id of an application by clicking on 'details' in your panel

api_key

string required

The API KEY of the application that makes the call to this API, you can obtain it in your panel, by clicking on the 'details' button of an application

texts

array required

An array containing each element of it a text to translate and one or more translation languages.

The language of the text you provide will be autodetected by ZPK, however you can specify it if you wish.

Structure of an array element:

Example of texts[] element
[
	{
		"text": "Text to translate from.",
		"source_language": "es",		
		"target_languages": ["en","fr","it"]
	},
	{
	
		"text": "Another text",
		"target_languages": ["es","fr"]
	}
]

Supported languages

You can get a list of all supported languages, and to which other languages ​​translation is allowed via the API. See: Obtaining all languages

Responses

Example response

Success translation response JSON
{
   "success": true,
   "results": [
      {
         "source": "Los seres humanos son libres.",
         "source_language": "es",
         "translations": {
            "en": "Human beings are free.",
            "it": "Gli esseri umani sono liberi."
         }
      },
      {
         "source": "El perro es amarillo",
         "source_language": "es",
         "translations": {
			"en": "the dog is yellow",
            "it": "il cane è giallo"
         }
      }
   ],
   "costs": {
      "characters": 626,
      "characters_substracted_from_free_quota": 0,
      "characters_substracted_from_credit": 626,
      "price_per_character_mili_eur": 16,
      "total_cost": 0.010016
   }
}

Response structure

JSON response structure
Parameter Description
success

boleano

A boolean indicating whether the request could be successfully processed, true if so.

results

translations array

An array that will contain all the translations made.

Structure of results array
Parameter Description
source

A string with the source text that was requested to translate.

source_language

The language detected in the source text.

translations

associative : array

An associative array with the text translated to each requested language, the key being the ISO code of the target language.

Example:

{
"es": "Perro amarillo",
"en": "Yellow dog",
"...": "etc..."
}
errors

associative : array

One or more errors in case of errors, the errors array is only returned in case the success bolean boolean is false.

Cada elemento del array errors contiene:

  • code: Error code identifier.
  • message: A text reporting the details of the error in order to debug..
costs

associative : array

Detailed breakdown of the costs of this request to the translation API

characters: Total number of characters.
characters_substracted_from_free_quota: Characters substracted from your monthly free quota.
characters_substracted_from_credit: The number of characters that are billed..
price_per_character_mili_eur: Price per character in euros/1000000 (million part of euro)
total_cost: Total request cost in euros.

Error response

Response containing errors
{
  "success": false,
  "errors": [
    {
      "id": "MISSING_REQUIRED_PARAMETER",
      "message": "Required parameter 'texts' not sent",
	  "on": "texts"
    }
  ]
}

Obtaining all supported languages

Get all languages

You can get all supported languages and translations by calling the following endpoint:

GET /api/translate/supported_languages
Parameter Description
application_id

string required

An application id. You can get the id of an application by clicking on 'details' in your panel

api_key

string required

The API KEY of the application that makes the call to this API, you can obtain it in your panel, by clicking on the 'details' button of an application

Example languages response

Response from supported_languages
{
  "success": true,
  "languages": [
    {
      "code": "es",
      "name": "español",
      "localized": {
        "af": "Spaans",
        "ak": "Spanish",
        "am": "ስፓኒሽኛ",
        "more": "...",
        "zu": "isi-Spanish"
      },
      "from": [
        "af",
        "ay",
        "...",
        "zh-CN"
      ],
      "to": [
        "af",
        "ak",
        "...",
        "zu"
      ]
    },
    {
		"more_languages_here":"..."
    }
  ],
  "costs": {
    "total_cost": 0.01
  }
}

Response structure

JSON Response structure
Parameter Description
success

boleano

A boolean indicating whether the request could be successfully processed, true if so.

languages

array

An array containing all the languages that the API supports, and extra information about each language, such as name in different languages, and languages supported as source/target.

languages array structure
Parameter Description
code

string

Language ISO code.

localized_name

array : asociativo

An associative array of key » string containing the language name, written in other languages. For example, for Spanish:

es » Español , cat » Espanyol , en » Spanish , etc...

from

array

The iso code of all source languages from which this language can be translated.

to

array

The iso code of all target languages into which this language can be translated.

costs

array of costs

An associative array that will only contain a total_cost key with the cost of this API request

Requesting a language listing is an API request that will be billed. We recommend saving this data in cache.

PHP Integration

ZPK-PHP is an open source composer-installable library that will allow you to integrate our APIs into your PHP project with minimal effort.

Installing PHP ZPK with composer

Terminal
composer require zpksystems/phpzpk

Translation example in PHP

Traduciendo a otro idioma con PHP
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkTranslator;

$t = new zpkTranslator( new zpkApplication('appid','key') );
$t->addTranslation("Buenos días, bienvenido al sitio web de ZPK Systems.",['en','it']);
$response = $t->translate();

Pricing

First 600.000 characters per month / Free
1 EUR foreach 62.500 additional characters

If you do not have enough credit in your account when making a request, the ZpkTranslate API will return an error.

Signup to try


Login, or Signup for freee to test this API