Service methods

This describes the endpoints that deal with Service on the Gengo API.

Language pairs (GET)

Summary :
Returns supported translation language pairs, tiers, and credit prices.
URL :
https://api.gengo.com/v2/translate/service/language_pairs
Authentication :
Not required
Parameters :
  • api_key (required) - Your API key
  • api_sig (required) - Your API signature
  • ts (required) - Current Unix epoch time as an integer
Data arguments :
lc_src (optional): Source language code. Submitting this will filter the response to only relevant language pairs.

Example call

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/python
# -*- coding: utf-8 -*-

from gengo import Gengo


gengo = Gengo(
    public_key='your_public_key',
    private_key='your_private_key',
    sandbox=False,
    debug=False)

print(gengo.getServiceLanguagePairs(lc_src='de'))

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
  "opstat": "ok",
  "response": [
    {
      "unit_price": 0.0500,
      "lc_tgt": "en",
      "lc_src": "de",
      "tier": "standard",
      "currency": "USD"
    },
    {
      "unit_price": 0.1000,
      "lc_tgt": "en",
      "lc_src": "de",
      "tier": "pro",
      "currency": "USD"
    },
  ]
}

Languages (GET)

Summary :
Returns a list of supported languages and their language codes.
URL :
https://api.gengo.com/v2/translate/service/languages
Authentication :
Not required
Parameters :
  • api_key (required) - Your API key

Example call

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/python
# -*- coding: utf-8 -*-

from gengo import Gengo


gengo = Gengo(
    public_key='your_public_key',
    private_key='your_private_key',
    sandbox=False,
    debug=False)

print(gengo.getServiceLanguages())

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "opstat": "ok",
  "response": [
    {
      "unit_type": "word",
      "lc": "en",
      "localized_name": "English",
      "language": "English"
    },
    {
      "unit_type": "character",
      "lc": "ja",
      "localized_name": "日本語",
      "language": "Japanese"
    },
    {
      "unit_type": "word",
      "lc": "es",
      "localized_name": "Español",
      "language": "Spanish (Spain)"
    }
  ]
}

Quote (POST)

Summary :
Returns credit quote and unit count for text based on content, tier, and language pair for job or jobs submitted.
URL :
https://api.gengo.com/v2/translate/service/quote
Authentication :
Required
Parameters :
  • api_key (required) - Your API key
  • api_sig (required) - Your API signature
  • ts (required) - Current Unix epoch time as an integer
Data arguments :
jobs (required): A dictionary of Job payloads, but only with the “lc_src”, “lc_tgt”, and “tier” parameters.

Example call

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
# -*- coding: utf-8 -*-

from gengo import Gengo


gengo = Gengo(
    public_key='your_public_key',
    private_key='your_private_key',
    sandbox=False,
    debug=False)

jobs_data = {
        'job_1': {
            'type': 'text',
            'slug': 'Single :: English to Japanese',
            'body_src': 'Testing Gengo API library calls.',
            'lc_src': 'en',
            'lc_tgt': 'ja',
            'tier': 'standard',
            'auto_approve': 0,
            'comment': 'HEY THERE TRANSLATOR',
            'callback_url': 'http://...',
            'custom_data': 'your optional custom data, limited to 1kb.',
        },
        'job_2': {
            'type': 'text',
            'slug': 'Single :: English to Japanese',
            'body_src': 'Testing Gengo API library calls.',
            'lc_src': 'en',
            'lc_tgt': 'ja',
            'tier': 'standard',
            'auto_approve': 0,
            'comment': 'HEY THERE TRANSLATOR',
            'callback_url': 'http://...',
            'custom_data':'your optional custom data, limited to 1kb.',
            'services': ['translation', 'edit'],
        },
        ...
}

print(gengo.determineTranslationCost(jobs=jobs_data))

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
  "opstat": "ok",
  "response": {
    "jobs": {
      "job_2": {
        "custom_data": "your optional custom data, limited to 1kb.",
        "credits": 4.2,
        "eta": 25164,
        "unit_count": 42,
        "lc_src_detected": "en",
        "currency": "USD",
        "type": "text"
      },
      "job_1": {
        "custom_data": "your optional custom data, limited to 1kb.",
        "credits": 35.64,
        "eta": 45198,
        "unit_count": 324,
        "lc_src_detected": "en",
        "currency": "USD",
        "type": "text"
      }
    }
  }
}

Quote files (POST)

Summary :
Uploads files to Gengo and returns a quote for each file, with an identifier for when client is ready to place the actual order. Price quote is based on content, tier, and language pair. After using this call, use the returned identifier as a parameter in the jobs POST method to order the actual job (see Job Payloads).
Note:
When uploading files, there is a limit of 50 files per call.
URL :
https://api.gengo.com/v2/translate/service/quote/file
Authentication :
Required
Parameters :
  • api_key (required) - Your API key
  • api_sig (required) - Your API signature
  • ts (required) - Current Unix epoch time as an integer
  • Additional one parameter for each “file_key” mentioned in data arguments, with the multipart-encoded file.
Data arguments :
  • jobs (required) - A dictionary of Job payloads with “lc_src”, “lc_tgt”, “tier”, “type” and “file_key” parameters.

Example call

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
# -*- coding: utf-8 -*-

from gengo import Gengo


gengo = Gengo(
    public_key='your_public_key',
    private_key='your_private_key',
    sandbox=False,
    debug=False)

jobs_data = {
    'job_1': {
        'type': 'file',
        'lc_src': 'en',
        'lc_tgt': 'ja',
        'tier': 'standard',
        'file_path': '/job_1/file_path.doc',
    },
    'job_2': {
        'type': 'file',
        'lc_src': 'en',
        'lc_tgt': 'ja',
        'tier': 'standard',
        'file_path': '/job_2/file_path.pdf',
    },
    'job_3': {
        'type': 'file',
        'lc_src': 'en',
        'lc_tgt': 'ja',
        'tier': 'standard',
        'file_path': '/job_3/file_path.foo',
    },
}

print(gengo.determineTranslationCost(jobs=jobs_data))

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "opstat": "ok",
  "response": {
    "jobs": {
      "job_3": {
        "err": {
          "filename": "file_path.foo",
          "code": 1802,
          "key": "job_3"
        }
      },
      "job_2": {
        "credits": 0.30,
        "eta": 25128,
        "identifier": "4fd1551c3a5628f795d645394bfcd0a5442e4e7ae60ad1f163424bdeb8420df4",
        "unit_count": 6,
        "lc_src": "en",
        "lc_src_detected": "en",
        "currency": "USD",
        "type": "file"
      },
      "job_1": {
        "credits": 0.30,
        "eta": 25128,
        "order_id": "54632",
        "identifier": "49427e41a1b6cefd7444b0d27ec165e7481658791885e71b7602c6babfc80b77",
        "unit_count": 6,
        "lc_src": "en",
        "lc_src_detected": "en",
        "currency": "USD",
        "type": "file"
      }
    }
  }
}

Unit Count (GET)

Summary :
Returns unit type and unit count for text based on content and language code submitted.
URL :
https://api.gengo.com/service/unit_count
Authentication :
Not required
Data arguments :
  • data (required) - An array of data, but only with the “text” and “lc” parameters.

Example call

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import requests

url = 'https://api.gengo.com/service/unit_count'

headers = {'Content-type': 'application/json',
           'Accept': 'application/json',}

data = [
    {'text': 'Hello World!', 'lc': 'en'},
    {'text': 'Ciao Mondo!', 'lc': 'it'},
    {'text': 'こんにちは', 'lc': 'ja'}
]

resp = requests.post(url, json=data, headers=headers)
print(resp.text)

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
[
	{
		"text":"Hello World!",
		"lc":"en",
		"unit_type":"word",
		"unit_count":2
	},
	{
		"text":"Ciao Mondo!",
		"lc":"it",
		"unit_type":"word",
		"unit_count":2
	},
	{
		"text":"こんにちは",
		"lc":"ja",
		"unit_type":"character",
		"unit_count":5
	}
]