Google Handwriting IME API Request

Published in: Javascript

When you write on the Google homepage using handwriting mode, the drawn path is sent as a POST request to Google Input Tools IME API as an array of X,Y points. Following is a sample payload request sent to the Google IME API.

 "method": "POST",
 "url": "",
 "postData": { "text": "{
   "device":"Chrome/19.0.1084.46 Safari/536.5",

And here’s a snippet of deobfuscated JavaScript code that traces and sends your handwriting to Google IME API.

_.Qx = function () {
  if (!(0, _.Dx)()) {
    var a = (0, _.rx)(_.Mx, _.Cx.slice(0)),
      b = {
        writing_guide: {
          writing_area_width: _.yx.width,
          writing_area_height: _.yx.height,
        ink: (0,, function (a) {
          return [
            (0,, function (a) {
              return a.x;
            (0,, function (a) {
              return a.y;
            (0,, function (a) {
              return a.t;
      c = (0, _.Rx)();
    c && 0 < c.length && (b.pre_context = c);
    c = || "en";
    c = c.replace("-", "_");
    b.language = c;
    var b = window.JSON.stringify({
        device: window.navigator.userAgent,
        options: "enable_pre_space",
        requests: [b],
      d = new _.jx();
    c && (0,, "complete", c);
    (0,, "ready", (0, _.Ya)(_.yda, d));
    d.lK = window.Math.max(0, 6e3);
    d.send("/inputtools/request?ime=handwriting&app=gws&cs=1", "POST", b, {
      "Content-Type": "application/json",
  _.Ux.clearRect(0, 0, _.yx.width, _.yx.height);
  _.Bx = _.o;
  _.Cx = [];
  (0, _.Vx)();

_.Gx = function (a) {
  var b = new window.Date().getTime() - _.Jx;
  if (!a.touches) {
    var c = a.pageX - window.pageXOffset,
      a = a.pageY - window.pageYOffset;
    return {
      x: c,
      y: a,
      t: b,
  c = a.touches[0].pageX - window.pageXOffset;
  a = a.touches[0].pageY - window.pageYOffset;
  return {
    x: c,
    y: a,
    t: b,

_.zx = function () {
  _.Ux.clearRect(0, 0, _.yx.width, _.yx.height);;
  _.Ux.lineWidth = 6;
  _.Ux.fillStyle = "#4d90fe";
  _.Ux.strokeStyle = "#4d90fe";
  _.Ux.lineCap = "round";
  _.Ux.lineJoin = "round";
  _.Ux.shadowColor = "rgba(0,0,0,0.3)";
  _.Ux.shadowBlur = 3;
  _.Ux.shadowOffsetY = 2;
  for (var a = 0; a < _.Cx.length; a++) (0, _.Wx)(_.Ux, _.Cx[a]);
📮  Subscribe to our Email Newsletter for Google tips and tutorials!
Published in: Javascript

Looking for something? Find here!

Meet the Author

Web Geek, Google Developer Expert
Amit Agarwal

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India. He is the developer of Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Get in touch

Google Add-ons

Do more with your Gmail and GSuite account

We build bespoke solutions that use the capabilities and the features of Google Workspace for automating business processes and driving work productivity.

  1. Mail Merge with Attachments
    Send personalized email to your Google Contact with a Google Sheet and Gmail
  2. Save Emails and Attachments
    Download email messages and file attachments from Gmail to your Google Drive
  3. Google Forms Email Notifications
    Send email notifications to multiple people when a new Google Form is submitted
  4. Document Studio
    Create beautiful pixel perfect documents merging data from Google Sheets and Google Forms
  5. Creator Studio for Google Slides
    Turn your Google Slides presentations into animated GIFs and videos for uploading to YouTube