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#!/usr/bin/python
 2# -*- coding: utf-8 -*-
 3
 4from gengo import Gengo
 5
 6
 7gengo = Gengo(
 8    public_key='your_public_key',
 9    private_key='your_private_key',
10    sandbox=False,
11    debug=False)
12
13print(gengo.getServiceLanguagePairs(lc_src='de'))

Response

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

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#!/usr/bin/python
 2# -*- coding: utf-8 -*-
 3
 4from gengo import Gengo
 5
 6
 7gengo = Gengo(
 8    public_key='your_public_key',
 9    private_key='your_private_key',
10    sandbox=False,
11    debug=False)
12
13print(gengo.getServiceLanguages())

Response

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

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#!/usr/bin/python
 2# -*- coding: utf-8 -*-
 3
 4from gengo import Gengo
 5
 6
 7gengo = Gengo(
 8    public_key='your_public_key',
 9    private_key='your_private_key',
10    sandbox=False,
11    debug=False)
12
13jobs_data = {
14        'job_1': {
15            'type': 'text',
16            'slug': 'Single :: English to Japanese',
17            'body_src': 'Testing Gengo API library calls.',
18            'lc_src': 'en',
19            'lc_tgt': 'ja',
20            'tier': 'standard',
21            'auto_approve': 0,
22            'comment': 'HEY THERE TRANSLATOR',
23            'callback_url': 'http://...',
24            'custom_data': 'your optional custom data, limited to 1kb.',
25        },
26        'job_2': {
27            'type': 'text',
28            'slug': 'Single :: English to Japanese',
29            'body_src': 'Testing Gengo API library calls.',
30            'lc_src': 'en',
31            'lc_tgt': 'ja',
32            'tier': 'standard',
33            'auto_approve': 0,
34            'comment': 'HEY THERE TRANSLATOR',
35            'callback_url': 'http://...',
36            'custom_data':'your optional custom data, limited to 1kb.',
37            'services': ['translation', 'edit'],
38        },
39        ...
40}
41
42print(gengo.determineTranslationCost(jobs=jobs_data))

Response

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

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#!/usr/bin/python
 2# -*- coding: utf-8 -*-
 3
 4from gengo import Gengo
 5
 6
 7gengo = Gengo(
 8    public_key='your_public_key',
 9    private_key='your_private_key',
10    sandbox=False,
11    debug=False)
12
13jobs_data = {
14    'job_1': {
15        'type': 'file',
16        'lc_src': 'en',
17        'lc_tgt': 'ja',
18        'tier': 'standard',
19        'file_path': '/job_1/file_path.doc',
20    },
21    'job_2': {
22        'type': 'file',
23        'lc_src': 'en',
24        'lc_tgt': 'ja',
25        'tier': 'standard',
26        'file_path': '/job_2/file_path.pdf',
27    },
28    'job_3': {
29        'type': 'file',
30        'lc_src': 'en',
31        'lc_tgt': 'ja',
32        'tier': 'standard',
33        'file_path': '/job_3/file_path.foo',
34    },
35}
36
37print(gengo.determineTranslationCost(jobs=jobs_data))

Response

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

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#!/usr/bin/env python
 2# -*- coding: utf-8 -*-
 3
 4import requests
 5
 6url = 'https://api.gengo.com/service/unit_count'
 7
 8headers = {'Content-type': 'application/json',
 9           'Accept': 'application/json',}
10
11data = [
12    {'text': 'Hello World!', 'lc': 'en'},
13    {'text': 'Ciao Mondo!', 'lc': 'it'},
14    {'text': 'こんにちは', 'lc': 'ja'}
15]
16
17resp = requests.post(url, json=data, headers=headers)
18print(resp.text)

Response

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