Jobs methods¶
This describes the endpoints that deal with Jobs on the Gengo API.
Jobs (POST)¶
- Summary :
Submits a job or group of jobs to translate. If all jobs which are placed in one order have same language pair and level then those jobs will be grouped.
- URL :
http://api.gengo.com/v2/translate/jobs
- Authentication :
Required
- Parameters :
api_key
(required) - Your API keyapi_sig
(required) - Your API signaturets
(required) - Current Unix epoch time as an integer
- Data arguments :
jobs
(required) - An array of Job Payloads. Please see the job payloads page for full details of the required 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
13data = {
14 'jobs': {
15 'job_1': {
16 'type': 'text',
17 'slug': 'Single :: English to Japanese',
18 'body_src': 'Testing Gengo API library calls.',
19 'lc_src': 'en',
20 'lc_tgt': 'ja',
21 'tier': 'standard',
22 'auto_approve': 0,
23 'comment': 'Instructions for translators on this specific job go here',
24 'attachments': [{'url': 'http://example.com/image01.jpg', 'filename': 'image01.jpg', 'mime_type': 'image/jpg'},
25 {'url': 'http://example.com/video/1234', 'filename': 'video.mp4', 'mime_type': 'video/mp4'}],
26 'callback_url': 'http://...',
27 'custom_data': 'your optional custom data, limited to 1kb.',
28 'force': 0,
29 'use_preferred': 0,
30 },
31 'job_2': {
32 'type': 'text',
33 'slug': 'Single :: English to Japanese',
34 'body_src': 'Testing Gengo API library calls.',
35 'lc_src': 'en',
36 'lc_tgt': 'ja',
37 'tier': 'standard',
38 'auto_approve': 0,
39 'comment': 'Instructions for translators on this specific job go here',
40 'attachments': [{'url': 'http://example.com/image02.jpg', 'filename': 'image02.jpg', 'mime_type': 'image/jpg'},
41 {'url': 'http://example.com/video/4321', 'filename': 'video01.mp4', 'mime_type': 'video/mp4'}],
42 'callback_url': 'http://...',
43 'custom_data':'your optional custom data, limited to 1kb.',
44 'force': 0,
45 'use_preferred': 0,
46 'services': ['translation', 'edit'],
47 },
48 },
49 'comment':'Instructions for translators on the entire order go here'
50}
51
52print(gengo.postTranslationJobs(jobs=data))
Comments
Please note that you can submit comments on individual jobs or on the entire order.
Response
In all cases, the response from should be near instant. That said, there are 3 possible types of response payloads depending on the jobs that were submitted in the POST call.
All jobs are new
If there are only new jobs, or all jobs have the force flag, the response will have a new order id, the number of jobs and the total cost of the order.
1{
2 "opstat": "ok",
3 "response": {
4 "job_count": 10,
5 "order_id": 139370,
6 "credits_used": 100.45,
7 "currency": "USD"
8 }
9}
All jobs are old
If there are only 100% matching jobs (i.e. all jobs have already been ordered before and translations exist), the response is a list of the jobs, keyed the same as in the original submission. The status for these jobs will be updated as “approved”. Notice that each index is a list, as there may be several matching jobs for a single payload if the force flag has been used in past POSTs.
The translation is in the “body_tgt” variable. The order id will be new and the credits_used will be same amount, but not charged again because we have not ordered any new content.
1 "opstat": "ok",
2 "response": {
3 "jobs": {
4 "job_2": [
5 {
6 "custom_data": "1234567",
7 "job_id": 1821444,
8 "credits": 0.10,
9 "auto_approve": 0,
10 "eta": -1,
11 "lc_tgt": "fr",
12 "unit_count": 1,
13 "lc_src": "en",
14 "slug": "3",
15 "callback_url": "http://example.com",
16 "currency": "USD",
17 "tier": "pro",
18 "body_src": "Third",
19 "body_tgt": "Troisieme",
20 "ctime": 1378703629,
21 "status": "reviewable"
22 }
23 ],
24 "job_1": [
25 {
26 "custom_data": "1234567",
27 "job_id": 1821443,
28 "credits": 0.10,
29 "auto_approve": 0,
30 "eta": -1,
31 "lc_tgt": "fr",
32 "unit_count": 1,
33 "lc_src": "en",
34 "slug": "3",
35 "callback_url": "http://example.com",
36 "currency": "USD",
37 "tier": "pro",
38 "body_src": "Second",
39 "body_tgt": "Deuxieme",
40 "ctime": 1378703629,
41 "status": "reviewable"
42 }
43 ]
44 },
45 "job_count": 2,
46 "order_id": 754511,
47 "credits_used": 0.00,
48 "currency": "USD"
49 }
50}
There are repeated jobs in the jobs payload
If there are any jobs inside a payload that are repeats of any other jobs in the same payload, the response will return the same translated text of the previous jobs that were sent.
The job count will be the number of jobs sent, however the credits will only charge for one of the repeated jobs in the payload. A new order id is created for each request.
1 "opstat": "ok",
2 "response": {
3 "jobs": [
4 [
5 {
6 "job_id": 1087795,
7 "credits": 0.10,
8 "auto_approve": 0,
9 "eta": 25308,
10 "lc_tgt": "fr",
11 "unit_count": 2,
12 "lc_src": "en",
13 "slug": "API Job test",
14 "callback_url": "http://example.com",
15 "currency": "USD",
16 "tier": "standard",
17 "body_src": "First test.",
18 "body_tgt": "Premier test.",
19 "ctime": 1378694499,
20 "status": "available"
21 }
22 ],
23 [
24 {
25 "job_id": 1087795,
26 "credits": 0.10,
27 "auto_approve": 0,
28 "eta": 25308,
29 "lc_tgt": "fr",
30 "unit_count": 2,
31 "lc_src": "en",
32 "slug": "API Job test",
33 "callback_url": "http://example.com",
34 "currency": "USD",
35 "tier": "standard",
36 "body_src": "First test.",
37 "body_tgt": "Premier test.",
38 "ctime": 1378694499,
39 "status": "available"
40 }
41 ]
42 ],
43 "job_count": 2,
44 "order_id": 122900,
45 "credits_used": 0.10,
46 "currency": "USD"
47 }
48}
49
50// Mix of new and old jobs
51{
Mix of new and old jobs
If there is a mix of previously ordered jobs (100% matching in content and language pair) and new jobs in the POST, you will get back a response that contains the old jobs, an order ID for the new jobs and total cost for the new jobs in the order.
Please Note that the number of job_count will be the total number of jobs sent in your payload, not just the new ones.
1 "jobs": {
2 "old_job1": [
3 {
4 "custom_data": "1234567",
5 "job_id": 1821444,
6 "credits": 0.10,
7 "auto_approve": 0,
8 "eta": -1,
9 "lc_tgt": "fr",
10 "unit_count": 1,
11 "lc_src": "en",
12 "slug": "3",
13 "callback_url": "http://example.com",
14 "currency": "USD",
15 "tier": "pro",
16 "body_src": "Third",
17 "body_tgt": "Troisieme",
18 "ctime": 1378703629,
19 "status": "reviewable"
20 }
21 ]
22 },
23 "job_count": 2,
24 "order_id": 754513,
25 "credits_used": 0.20,
26 "currency": "USD"
27 }
28}
Jobs (GET)¶
- Summary :
Retrieves a list of resources for the most recent jobs filtered by the given parameters.
- URL :
http://api.gengo.com/v2/translate/jobs
- Authentication :
Required
- Parameters :
api_key
(required) - Your API keyapi_sig
(required) - Your API signaturets
(required) - Current Unix epoch time as an integer
- Data arguments :
status
(optional) - “available”, “pending”, “reviewable”, “approved”, “rejected”, or “canceled”timestamp_after
(optional) - Epoch timestamp from which to filter submitted jobscount
(optional) - Defaults to 10 (maximum 200)
- Note
If you only use count, you’ll get the most recent count jobs
If you use count with timestamp_after, you’ll get count jobs submitted since timestamp_after
If you only use timestamp_after, you’ll get all jobs submitted since timestamp_after
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.getTranslationJobs(status="available", count=15))
Response
1{
2 "opstat": "ok",
3 "response": [
4 {
5 "job_id": 123,
6 "ctime": "..."
7 },
8 {
9 "job_id": 425,
10 "ctime": "..."
11 },
12 {
13 "job_id": 274,
14 "ctime": "..."
15 }
16 ]
17}
Jobs by id (GET)¶
- Summary :
Retrieves a list of jobs. They are requested by a comma-separated list of job ids.
- URL :
http://api.gengo.com/v2/translate/jobs/{ids}
- Authentication :
Required
- Parameters :
api_key
(required) - Your API keyapi_sig
(required) - Your API signaturets
(required) - Current Unix epoch time as an integer
- Note
For the jobs that are file jobs, the response will include
file_url_src
andfile_url_tgt
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.getTranslationJobBatch(id="1,2"))
Response
1{
2 "opstat": "ok",
3 "response": {
4 "jobs": [
5 {
6 "custom_data": "{internal_id: 2311}",
7 "job_id": 1,
8 "credits": 0.25,
9 "auto_approve": 1,
10 "eta": 25308,
11 "order_id": 54632,
12 "lc_tgt": "jp",
13 "unit_count": 5,
14 "lc_src": "en",
15 "slug": "This is a short story",
16 "callback_url": "http://yourapp.com/gengo_callback/job/1",
17 "currency": "USD",
18 "tier": "standard",
19 "body_src": "This is a short story",
20 "ctime": 1352879655,
21 "status": "available"
22 },
23 {
24 "custom_data": "{internal_id: 2312}",
25 "job_id": 2,
26 "credits": 0.35,
27 "auto_approve": 1,
28 "eta": 25308,
29 "order_id": 54632,
30 "lc_tgt": "jp",
31 "unit_count": 7,
32 "lc_src": "en",
33 "slug": "This is a short story as well",
34 "callback_url": "http://yourapp.com/gengo_callback/job/2",
35 "currency": "USD",
36 "tier": "standard",
37 "body_src": "This is a short story as well",
38 "ctime": 1352879764,
39 "status": "available"
40 }
41 ]
42 }
43}
Jobs (PUT)¶
- Summary :
Updates a group of jobs to translate. Request should be no larger than 100MB. Comments per job should not exceed more than 25,000 characters.
- URL :
http://api.gengo.com/v2/translate/jobs/
- Authentication :
Required
- Parameters :
api_key
(required) - Your API keyapi_sig
(required) - Your API signaturets
(required) - Current Unix epoch time as an integer
- Data arguments :
- action (required): (per job) :
- “revise“ - Returns this job back to the translator for revisions.
Other parameters
comment
(required) - The reason to the translator for sending the job back for revisions.
- “approve“ - Approves job.
Other parameters
rating
(optional) 1 (poor) to 5 (fantastic)for_translator
(optional) - Comments for the translatorfor_mygengo
(optional) - Comments for Gengo staff (private)public
(optional) 1 (true) / 0 (false, default) - Whether Gengo can share this feedback publicly, including the source and target text (see Open Data).
- “reject“ - Rejects the translation. Please see our FAQs for details of the rejection process.
Other parameters
reason
(required) - “quality”, “incomplete”, “other”comment
(required)follow_up
(optional) “requeue” (default) or “cancel” - If you choose “requeue” the job will be rejected and then passed onto another translator. If you choose “cancel” the job will be completely cancelled upon rejection.
“archive“ - Archive approved job.
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
13# Archive a group of jobs
14gengo.updateTranslationJobs(action={
15 'job_ids': [4854, 547],
16 'action': 'archive'
17})
18
19# Revise a group of jobs
20gengo.updateTranslationJobs(action={
21 'action': 'revise',
22 'job_ids': [{'job_id': 922, 'comment': 'Please change the word banana to gorilla'},
23 {'job_id': 923, 'comment': 'Please change the word banana to monkey'}],
24})
25
26## Reject a group of jobs
27gengo.updateTranslationJobs(action={
28 'action': 'reject',
29 'job_ids': [{'job_id': 929, 'reason': 'quality', 'comment': 'This sentence should be in the past tense'},
30 {'job_id': 811, 'reason': 'quality', 'comment': 'This should have be capitalized'}],
31})
32
33# Approve a group of jobs
34gengo.updateTranslationJobs(action={
35 'action': 'approve',
36 'job_ids': [{'job_id': 924},
37 {'job_id': 928}],
38})
Response
1// Archive a group of jobs
2{
3 "opstat": "ok",
4 "response": {
5
6 }
7}
8
9// Revising a group of jobs.
10{
11 "opstat": "ok",
12 "response": {
13
14 }
15}
16
17// Rejecting a group of jobs.
18{
19 "opstat": "ok",
20 "response": {
21 "jobs": [
22 {
23 "rejection_comments": "...",
24 "worker_id": 4,
25 "rejection_reason": "quality",
26 "customer_id": 3,
27 "job_id": 929
28 },
29 {
30 "rejection_comments": "...",
31 "worker_id": 4,
32 "rejection_reason": "quality",
33 "customer_id": 3,
34 "job_id": 811
35 }
36 ]
37 }
38}
39
40// Approving a group of jobs.
41{
42 "opstat": "ok",
43 "response": {
44
45 }
46}