Google BigQuery: Node.js Client

release level npm version codecov

Google BigQuery Client Library for Node.js

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable the Google BigQuery API.
  3. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/bigquery

Using the client library

// Imports the Google Cloud client library
const {BigQuery} = require('@google-cloud/bigquery');

async function createDataset() {
  // Creates a client
  const bigqueryClient = new BigQuery();

  // Create the dataset
  const [dataset] = await bigqueryClient.createDataset(datasetName);
  console.log(`Dataset ${dataset.id} created.`);
}
createDataset();

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

SampleSource CodeTry it
Add Column Load Appendsource codeOpen in Cloud Shell
Add Column Query Appendsource codeOpen in Cloud Shell
Add Empty Columnsource codeOpen in Cloud Shell
Auth View Tutorialsource codeOpen in Cloud Shell
Browse Tablesource codeOpen in Cloud Shell
Cancel Jobsource codeOpen in Cloud Shell
Client JSON Credentialssource codeOpen in Cloud Shell
Copy Tablesource codeOpen in Cloud Shell
Copy Table Multiple Sourcesource codeOpen in Cloud Shell
Create Datasetsource codeOpen in Cloud Shell
Create Jobsource codeOpen in Cloud Shell
Create Modelsource codeOpen in Cloud Shell
Create Routinesource codeOpen in Cloud Shell
Create Routine DDLsource codeOpen in Cloud Shell
Create Tablesource codeOpen in Cloud Shell
Create Table Partitionedsource codeOpen in Cloud Shell
Create Table Range Partitionedsource codeOpen in Cloud Shell
Create Viewsource codeOpen in Cloud Shell
Ddl Create Viewsource codeOpen in Cloud Shell
Delete Datasetsource codeOpen in Cloud Shell
Delete Label Datasetsource codeOpen in Cloud Shell
Delete Label Tablesource codeOpen in Cloud Shell
Delete Modelsource codeOpen in Cloud Shell
Delete Routinesource codeOpen in Cloud Shell
Delete Tablesource codeOpen in Cloud Shell
Extract Table Compressedsource codeOpen in Cloud Shell
Extract Table JSONsource codeOpen in Cloud Shell
Extract Table To GCSsource codeOpen in Cloud Shell
Get Datasetsource codeOpen in Cloud Shell
Get Dataset Labelssource codeOpen in Cloud Shell
Get Jobsource codeOpen in Cloud Shell
BigQuery Get Modelsource codeOpen in Cloud Shell
Get Routinesource codeOpen in Cloud Shell
BigQuery Get Tablesource codeOpen in Cloud Shell
Get Table Labelssource codeOpen in Cloud Shell
Get Viewsource codeOpen in Cloud Shell
Insert Rows As Streamsource codeOpen in Cloud Shell
Inserting Data Typessource codeOpen in Cloud Shell
BigQuery Label Datasetsource codeOpen in Cloud Shell
Label Tablesource codeOpen in Cloud Shell
List Datasetssource codeOpen in Cloud Shell
List Datasets By Labelsource codeOpen in Cloud Shell
List Jobssource codeOpen in Cloud Shell
BigQuery List Modelssource codeOpen in Cloud Shell
BigQuery List Models Streamingsource codeOpen in Cloud Shell
List Routinessource codeOpen in Cloud Shell
List Tablessource codeOpen in Cloud Shell
Load CSV From GCSsource codeOpen in Cloud Shell
Load CSV From GCS Autodetectsource codeOpen in Cloud Shell
Load CSV From GCS Truncatesource codeOpen in Cloud Shell
Load JSON From GCSsource codeOpen in Cloud Shell
Load JSON From GCS Autodetectsource codeOpen in Cloud Shell
Load JSON From GCS Truncatesource codeOpen in Cloud Shell
Load Local Filesource codeOpen in Cloud Shell
Load Orc From GCS Truncatesource codeOpen in Cloud Shell
Load Parquet From GCS Truncatesource codeOpen in Cloud Shell
Load Table GCS Avrosource codeOpen in Cloud Shell
Load Table GCS Avro Truncatesource codeOpen in Cloud Shell
Load Table GCSORCsource codeOpen in Cloud Shell
Load Table GCS Parquetsource codeOpen in Cloud Shell
Load Table Partitionedsource codeOpen in Cloud Shell
Nested Repeated Schemasource codeOpen in Cloud Shell
Querysource codeOpen in Cloud Shell
Query Batchsource codeOpen in Cloud Shell
Query Destination Tablesource codeOpen in Cloud Shell
Query Disable Cachesource codeOpen in Cloud Shell
Query Dry Runsource codeOpen in Cloud Shell
Query External GCS Permsource codeOpen in Cloud Shell
Query Legacysource codeOpen in Cloud Shell
Query Legacy Large Resultssource codeOpen in Cloud Shell
Query Paginationsource codeOpen in Cloud Shell
Query Params Arrayssource codeOpen in Cloud Shell
Query Params Namedsource codeOpen in Cloud Shell
Query Params Named Typessource codeOpen in Cloud Shell
Query Params Positionalsource codeOpen in Cloud Shell
Query Params Positional Typessource codeOpen in Cloud Shell
Query Params Structssource codeOpen in Cloud Shell
Query Params Timestampssource codeOpen in Cloud Shell
Query Stack Overflowsource codeOpen in Cloud Shell
Quickstartsource codeOpen in Cloud Shell
Relax Columnsource codeOpen in Cloud Shell
Relax Column Load Appendsource codeOpen in Cloud Shell
Relax Column Query Appendsource codeOpen in Cloud Shell
Set User Agentsource codeOpen in Cloud Shell
Undelete Tablesource codeOpen in Cloud Shell
Update Dataset Accesssource codeOpen in Cloud Shell
Update Dataset Descriptionsource codeOpen in Cloud Shell
Update Dataset Expirationsource codeOpen in Cloud Shell
BigQuery Update Modelsource codeOpen in Cloud Shell
Update Routinesource codeOpen in Cloud Shell
Update Table Descriptionsource codeOpen in Cloud Shell
Update Table Expirationsource codeOpen in Cloud Shell
Update View Querysource codeOpen in Cloud Shell

The Google BigQuery Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed via npm dist-tags. The dist-tags follow the naming convention legacy-(version).

Legacy Node.js versions are supported as a best effort:

  • Legacy versions will not be tested in continuous integration.
  • Some security patches may not be able to be backported.
  • Dependencies will not be kept up-to-date, and features will not be backported.

Legacy tags available

  • legacy-8: install client libraries from this dist-tag for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE