Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @google-cloud/bigquery with all npm packages installed. Try it out:

var bigquery = require("@google-cloud/bigquery")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@google-cloud/bigquery v4.7.0

Google BigQuery Client Library for Node.js

Google Cloud Platform logo

Google Cloud BigQuery: Node.js Client

release level npm version codecov

Google BigQuery Client Library for Node.js

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 Cloud 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. The samples' README.md has instructions for running the samples.

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
Browse Rowssource 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 Tablesource codeOpen in Cloud Shell
Create Table Partitionedsource 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 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
BigQuery Get Tablesource codeOpen in Cloud Shell
Get Table Labelssource codeOpen in Cloud Shell
Insert Rows As Streamsource 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 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 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 Destination Tablesource codeOpen in Cloud Shell
Query Disable Cachesource codeOpen in Cloud Shell
Query Dry Runsource codeOpen in Cloud Shell
Query Legacysource codeOpen in Cloud Shell
Query Legacy Large Resultssource codeOpen in Cloud Shell
Query Params Arrayssource codeOpen in Cloud Shell
Query Params Namedsource codeOpen in Cloud Shell
Query Params Positionalsource 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
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 Table Descriptionsource codeOpen in Cloud Shell
Update Table Expirationsource codeOpen in Cloud Shell

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

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.

License

Apache Version 2.0

See LICENSE

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free