Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including gengo-node with all npm packages installed. Try it out:

var gengoNode = require("gengo-node")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gengo-node v1.0.2

A client for Gengo's human translation API

  • Under development *


Gengo makes it easy to plug human powered translation in to your service or platform.


$npm install gengo-node


Gengo = require Gengo
gengoClient = new Gengo {public: YOUR_PUBLIC_KEY, private: your_private_key}

By default the client sends all requests to the Gengo Sandbox environment.

Send a couple of jobs for translation

First we create a couple of jobs that represent a blog post. I've only set a few of the options here, but check out the job payloads for a full list.

blog_post =
    lc_src: 'en'
    lc_tgt: 'ja'
    tier: 'standard'
    body_src: "This is the title of my blog post"
    custom_data: {blog_post_id: 2322, part: 'title'}
    callback_url: ""
    lc_src: 'en'
    lc_tgt: 'ja'
    tier: 'standard'
    body_src: "This is the body content of my blog post"
    custom_data: {blog_post_id: 2322, part: 'body'}
    callback_url: ""

There are two important concepts in this payload.

  1. custom_data: Here we've added 2 bits of information that will help us map the translated content back to our own system. In this example a blog post ID and the part of the post.

  2. callback_url: Since there will be real human translators working on the content it may take a bit of time. Once the translation is ready we'll post the translation to the URL provided along with the custom_data and order details.

Since the Gengo API is designed to support thousnads of jobs, there is a queueing mechanism placed in front of the API. This means that when a jobs are sent, we reply with an order_id and put the jobs in a queue.

blog_post_order_id = null
Gengo.postJobs blog_post, (res) ->
  blog_post_order_id = res.order_id
  console.log res

    "order_id": "139370",
    "group_id": 23015,
    "job_count": "2",
    "credits_used": "3.50",
    "currency": "USD"

Now that we have the order ID we can check on the status of the order.

blog_post_job_ids = null
Gengo.getOrder blog_post_order_id, (res) ->
  blog_post_job_ids = res.order.jobs_available
  console.log res

    "order": {
      "order_id": "139370",
      "total_credits": "3.50",
      "currency": "USD",
      "total_units": 17,
      "as_group": 1,
      "jobs_available": [
      "jobs_pending": [],
      "jobs_reviewable": [],
      "jobs_approved": [],
      "jobs_queued": 0,
      "total_jobs": "2"
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free