9

I see there are two available libraries. I am wondering what are the differences? Are they both officially maintained by Google?

https://www.npmjs.com/package/googleapis

https://www.npmjs.com/package/google-cloud

user699681
  • 213
  • 4
  • 10

2 Answers2

2

Yes both are maintained by Google. googleapis covers all these APIs (drive, calendar, admin sdk, maps, etc) whereas google-cloud covers the cloud platform stuff like bigquery, datastore, cloud storage, bigtable, pub/sub, etc. There appears to be overlap and I don't know which one is better for a particular service. Will be playing with cloud storage and admin sdk here soon though :)

Michael
  • 116
  • 1
  • 5
1

The answer is found here.

From the reference, the @google-cloud library is recommended as it has the following benefits:

  • In some cases, gives you performance benefits by using gRPC. You can find out more in the gRPC APIs section below.
  • @googleapis " has autogenerated interface code that may not be as idiomatic as our newer libraries."

Personally, I think if you are using non-cloud APIs like Gmail, Calendar, etc, it may be more worth it to use just the Google APIs library for syntactic consistency.

One thing I noticed is that the @google-cloud library didn't allow the same authentication method that I like using with @googleapis:

const { google } = require('googleapis');

new google.auth.JWT(client_email, null, private_key, [
        'https://www.googleapis.com/auth/cloud-platform'
    ]);
Nth.gol
  • 746
  • 9
  • 20