Skip to content
Talk to an Engineer Dashboard

BigQuery (Service Account)

Connect to BigQuery using a GCP service account for server-to-server authentication without user login.

BigQuery (Service Account) logo

Supports authentication: Service Account

In Scalekit dashboard, go to Agent AuthCreate Connection. Find BigQuery (Service Account) and click Create.

That’s it — no OAuth credentials or redirect URIs needed. BigQuery Service Account uses server-to-server authentication handled entirely through your GCP service account credentials.

To connect a BigQuery account programmatically, you need a GCP service account JSON key. Here’s how to get one:

  1. Create a GCP service account

    • Go to Google Cloud ConsoleIAM & AdminService Accounts.
    • Click + Create Service Account, enter a name and description, and click Create and Continue.
    • Grant the service account the BigQuery Data Viewer, BigQuery Data Editor, and BigQuery Job User roles, then click Done.
  2. Enable the BigQuery API

    • In Google Cloud Console, go to APIs & ServicesLibrary.

    • Search for BigQuery API and click Enable.

      Enable BigQuery API in Google Cloud Console

  3. Download the service account JSON key

    • In the Service Accounts list, click on your service account.
    • Go to the Keys tab → Add KeyCreate new key.
    • Select JSON and click Create. The key file downloads automatically.
    • Use the contents of this file as the service_account_json value when creating a connected account.

Connect to BigQuery using a GCP service account — Scalekit handles authentication automatically using your service account credentials.

import { ScalekitClient } from '@scalekit-sdk/node';
import 'dotenv/config';
const connectionName = 'bigqueryserviceaccount'; // get your connection name from connection configurations
const identifier = 'user_123'; // your unique user identifier
// Get your credentials from app.scalekit.com → Developers → Settings → API Credentials
const scalekit = new ScalekitClient(
process.env.SCALEKIT_ENV_URL,
process.env.SCALEKIT_CLIENT_ID,
process.env.SCALEKIT_CLIENT_SECRET
);
const actions = scalekit.actions;
// Create a connected account with your service account credentials
await actions.getOrCreateConnectedAccount({
connectionName,
identifier,
authorizationDetails: {
staticAuth: {
serviceAccountJson: '<paste your GCP service account JSON here>',
},
},
});
// Execute a BigQuery tool
const result = await actions.executeTool({
toolName: 'bigqueryserviceaccount_run_query',
connectionName,
identifier,
toolInput: {
query: 'SELECT 1 AS test',
},
});
console.log(result);

Proxy API Calls

// Make a direct BigQuery REST API call via Scalekit proxy
// Base URL is already scoped to: .../bigquery/v2/projects/{project_id}
const result = await actions.request({
connectionName,
identifier,
path: '/datasets',
method: 'GET',
});
console.log(result);

Retrieve metadata for a specific BigQuery dataset, including location, description, labels, access controls, and creation/modification times.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset to retrieve

Retrieve the status and configuration of a BigQuery job by its job ID. Use this to poll for completion of an async query job.

NameTypeRequiredDescription
job_idstringYesThe ID of the job to retrieve
locationstringNoGeographic location where the job was created, e.g. US or EU

Retrieve metadata for a specific BigQuery ML model, including model type, feature columns, label columns, and training run details.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset containing the model
model_idstringYesThe ID of the model to retrieve

Retrieve the results of a completed BigQuery query job. Supports pagination via page tokens. Use after polling Get Job until status is DONE.

NameTypeRequiredDescription
job_idstringYesThe ID of the completed query job
locationstringNoGeographic location where the job was created, e.g. US or EU
max_resultsintegerNoMaximum number of rows to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page of results
timeout_msintegerNoMaximum milliseconds to wait if the query has not yet completed

Retrieve the definition and metadata of a specific BigQuery routine (stored procedure or UDF), including its arguments, return type, and body.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset containing the routine
routine_idstringYesThe ID of the routine to retrieve

Retrieve metadata and schema for a specific BigQuery table or view, including column names, types, descriptions, and table properties.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset containing the table
table_idstringYesThe ID of the table or view to retrieve

List all BigQuery datasets in the project. Supports filtering by label and pagination.

NameTypeRequiredDescription
allbooleanNoIf true, includes hidden datasets in the results
filterstringNoLabel filter expression to restrict results, e.g. labels.env:prod
max_resultsintegerNoMaximum number of datasets to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page

List BigQuery jobs in the project. Supports filtering by state and projection, and pagination.

NameTypeRequiredDescription
all_usersbooleanNoIf true, returns jobs for all users in the project; otherwise returns only the current user’s jobs
max_resultsintegerNoMaximum number of jobs to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page
projectionstringNoControls the fields returned: minimal (default) or full
state_filterstringNoFilter jobs by state: done, pending, or running

List all BigQuery ML models in a dataset, including their model type, training status, and creation time.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset to list models from
max_resultsintegerNoMaximum number of models to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page

List all stored procedures and user-defined functions (UDFs) in a BigQuery dataset.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset to list routines from
filterstringNoFilter expression to restrict results, e.g. routineType:SCALAR_FUNCTION
max_resultsintegerNoMaximum number of routines to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page

Read rows directly from a BigQuery table without writing a SQL query. Supports pagination, row offset, and field selection.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset containing the table
max_resultsintegerNoMaximum number of rows to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page
selected_fieldsstringNoComma-separated list of fields to return; if omitted all fields are returned
start_indexintegerNoZero-based row index to start reading from
table_idstringYesThe ID of the table to read rows from

List all tables and views in a BigQuery dataset. Supports pagination.

NameTypeRequiredDescription
dataset_idstringYesThe ID of the dataset to list tables from
max_resultsintegerNoMaximum number of tables to return per page
page_tokenstringNoPage token from a previous response to retrieve the next page

Execute a SQL query synchronously against BigQuery and return results immediately. Best for short-running queries.

NameTypeRequiredDescription
create_sessionbooleanNoIf true, creates a new session and returns a session ID in the response
dry_runbooleanNoIf true, validates the query and returns estimated bytes processed without executing
locationstringNoGeographic location of the dataset, e.g. US or EU
max_resultsintegerNoMaximum number of rows to return in the response
querystringYesSQL query to execute
timeout_msintegerNoMaximum milliseconds to wait for query completion before returning
use_legacy_sqlbooleanNoUse BigQuery legacy SQL syntax instead of standard SQL