linkに示すように、第二のリンクでオプション「このAPIを試してみてください」を使用してくださいbigQuery.jobs.query exampleの「リクエストボディ」にパラメータとしてクエリを渡すことができます。
var google = require('googleapis');
var bigquery = google.bigquery('v2');
authorize(function(authClient) {
var request = {
// Project ID of the project billed for the query
projectId: '', // TODO: Update placeholder value.
resource: {
// TODO: Add desired properties to the request body.
"query": "Select channel, sum(totalRequests) from
conversation_logs.RequestSummary WHERE timeStamp >
TIMESTAMP('2017-09-03 00:00:00 UTC') Group by channel;",
"maxResults": 1,
"useLegacySql": false
},
auth: authClient
};
bigquery.jobs.query(request, function(err, response) {
if (err) {
console.log(err);
return;
}
// TODO: Change code below to process the `response` object:
console.log(JSON.stringify(response, null, 2));
});
});
function authorize(callback) {
google.auth.getApplicationDefault(function(err, authClient)) {
if (err) {
console.log('authentication failed: ', err);
return;
}
if (authClient.createScopedRequired &&
authClient.createScopedRequired()) {
var scopes = ['https://www.googleapis.com/auth/cloud-
platform'];
authClient = authClient.createScoped(scopes);
}
callback(authClient);
});
}
このサンプルでは、var gcloud = require( 'gcloud')が使用されています。 私はconst google = require( 'googleapis')を使用していますが、 –