This describes the endpoints that deal with Service on the Gengo API.
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"
},
]
}
|
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)"
}
]
}
|
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"
}
}
}
}
|
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"
}
}
}
}
|
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
}
]
|