Google NLP API performance - REST API vs Node js client API

70 views
Skip to first unread message

Kapil Gahlot

unread,
Sep 25, 2017, 9:28:33 AM9/25/17
to Google Cloud Developers
During my testing of Google NLP API I found REST API response time (1.4 secs) to be faster than Node js client API response time (2 secs) . I am making API calls from a Meteor server. However Google API docs suggest to prefer client API over REST without providing any reasons. Is it a good decision to use REST API rather than client API just based on the response times that I am getting or are there other considerations in favor of the client API?

Kapil Gahlot

unread,
Sep 25, 2017, 9:28:33 AM9/25/17
to Google Cloud Developers
console.log("api time : ", moment.now() - startTime);


However Google API docs suggest to prefer client API over REST without providing any reasons. Is it a good decision to use REST API rather than client API just based on the response times that I am getting or are there other considerations in favor of the client API?
During my testing of Google NLP API I found REST API response time (1.4 secs) to be faster than Node js client API response time (2 secs) . I am making API calls from a Meteor server.

Here is a snapshot of the code:

Node js client:

in an async function:

set up auth, request, etc.

let startTime = moment.now();
response = await client.annotateText(request);
console.log("api time : ", moment.now() - startTime);

REST API:

in an async function:

set up data, etc.

let startTime = moment.now();

response = await HTTP.call("POST",      "https://language.googleapis.com/v1beta2/documents:annotateText?key=KEY_VALUE",      { data }    );


Thanks


Yannick (Cloud Platform Support)

unread,
Sep 25, 2017, 2:11:05 PM9/25/17
to Google Cloud Developers
Hello Kapil, the justification for that recommendation can be found here. In essence the client libraries are recommended for their ease of use and you are not at all discouraged from using the REST API directly.

Kapil Gahlot

unread,
Sep 25, 2017, 2:36:34 PM9/25/17
to Google Cloud Developers
Thanks a lot. It helps. I will go ahead and use REST as it consistently provides better response time to me and using node js is anyway easy to work with json response from REST API.

Regards
Reply all
Reply to author
Forward
0 new messages