Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gapi.load versus gapi.client.load

In Google's JavaScript API's, what's the difference between gapi.load() and gapi.client.load()? How interchangeable are they and when should I use one versus the other? I see both are used in the Google Drive Realtime API sample code.

like image 728
Brian Slesinsky Avatar asked Jun 01 '13 02:06

Brian Slesinsky


People also ask

What is gapi client?

GAPI is Google's client library for browser-side JavaScript. It's used in Google Sign-in, Google Drive, and thousands of internal and external web pages for easily connecting with Google APIs.

What is gapi client init?

gapi. client. init( args ) Initializes the JavaScript client with API key, OAuth client ID, scope, and API discovery document(s). If OAuth client ID and scope are provided, this function will load the gapi.


1 Answers

As indicated by the CORS documentation, the gapi.load function is used to dynamically load specific JavaScript libraries.

As documented in the description of the gapi.client.load function (which is provided by the "client" JS library), gapi.client.load is used to build a JavaScript interface for accessing specific HTTP(S) APIs; you can also do this sort of thing yourself using API discovery (search for it to find docs) and sending API requests directly with gapi.client.request or CORS.

Edit: added clarification based on Brian Slesinsky's follow-up comment and made minor wording changes.

like image 148
Ben Sittler Avatar answered Oct 18 '22 09:10

Ben Sittler