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 :
http://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 :
http://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 :
http://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): An array 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
#!/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.'
        },
        ...
}

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": 16.2,
        "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 :
http://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
Data arguments :
  • jobs (required) - An array of Job payloads, but only with the “lc_src”, “lc_tgt”, and “tier” parameters.
  • files (required) - A dictionary of files, where for each key, there is a multipart-encoded file.

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"
      }
    }
  }
}