The documentation states you should load your api from javascript like this:
var ROOT = 'https://your_app_id.appspot.com/_ah/api';
gapi.client.load('your_app_id', 'v1', function() {
doSomethingAfterLoading();
}, ROOT);
But, what it seems to actually be is
var ROOT = 'https://your_app_id.appspot.com/_ah/api';
gapi.client.load('your_api_name', 'v1', function() {
doSomethingAfterLoading();
}, ROOT);
For example, I can pass "users" as the api name, and now the users
object is defined as an attribute of gapi.client
.
Just to be clear, my api is defined like this:
@endpoints.api(name='users',version='v1',
description='The user service.')
class UserService(remote.Service):
...
So now, I wonder, am I doing something in an unintended way? And, since /_ah/api/explorer
can find all the APIs that are defined, is there a way to have this function add all the apis I define without having to specify all their names in separate gapi.client.load
calls?
Thanks for pointing it out, this is a bug in the documentation! We'll try to get if fixed ASAP.
You should check out the fully-baked Tic Tac Toe sample application.
In it, we show how to load multiple APIs (among other things).
google.devrel.samples.ttt.init = function(apiRoot) {
// Loads the OAuth and Tic Tac Toe APIs asynchronously, and triggers login
// when they have completed.
var apisToLoad;
var callback = function() {
if (--apisToLoad == 0) {
google.devrel.samples.ttt.signin(true,
google.devrel.samples.ttt.userAuthed);
}
}
apisToLoad = 2; // must match number of calls to gapi.client.load()
gapi.client.load('tictactoe', 'v1', callback, apiRoot);
gapi.client.load('oauth2', 'v2', callback);
var buttons = document.querySelectorAll('td');
for (var i = 0; i < buttons.length; i++) {
var button = buttons[i];
button.addEventListener('click', google.devrel.samples.ttt.clickSquare);
}
var reset = document.querySelector('#restartButton');
reset.addEventListener('click', google.devrel.samples.ttt.resetGame);
};