Google BigQuery

API Overview (V2)

The API Overview section describes how to use the BigQuery API and is broken up into different pages for different types of tasks. This document describes how to get started using the API. After reviewing this page, be sure to read authorizing access and the remaining sections of the API overview.


Getting Started

BigQuery provides a REST-based API that can be accessed programmatically from a variety of languages. The recommended way to access the BigQuery API is through one of the Google API Client libraries. This API overview uses the Python client library and the Java client library and provides samples in both languages.


Before you can use the BigQuery API, you must:

  • Activate the BigQuery API

    If you are a member of an existing Google APIs Console project that already has BigQuery enabled, you can use that project to build your application. To learn how to sign up for BigQuery, check out our sign up process.

If you want to run the samples provided in this overview, you must:

  • Download and install client libraries

    Download and install either the Java client library or the Python client library.

  • Be able to write basic Java or Python code

    The samples in this overview assume that you have basic coding knowledge.

Authorizing Access to the BigQuery API

The BigQuery API requires all requests to be authorized by an authenticated user or a service account. We strongly recommend that your application use the OAuth 2.0 protocol to authorize requests to the BigQuery API. OAuth provides authorization flows for web, desktop, mobile, server-based and even embedded device applications.

Before you write any code, read our guide to authorizing access to the BigQuery API.

Authorizing access to the BigQuery API requires using the following scope:

Scope Meaning View and manage data in Google BigQuery View data in Google BigQuery

To request access using OAuth 2.0, your application needs the scope information, as well as information that Google supplies during application registration (such as the client ID and/or the client secret).

Instantiating a BigQuery API service object

After your choosing an authorization method and retrieving a credential to access BigQuery, you can instantiate a service class to make calls to the API. We strongly recommend that you use one of the Google client libraries for this purpose.

BigQuery Service Object Examples


This sample uses the Google APIs Client Library for Java.



class MyClass {


  private static final HttpTransport TRANSPORT = new NetHttpTransport();
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();

  Bigquery bigquery = new Bigquery.Builder(TRANSPORT, JSON_FACTORY, credential)
    .setApplicationName("Your User Agent String Here")



This sample uses the Google APIs Client Library for JavaScript.

<script src=""></script>

var config = {'client_id': client_id,
              'scope': ''

gapi.auth.authorize(config, function() {
    gapi.client.load('bigquery', 'v2');


This sample uses the Google APIs Client Library for Python.

import httplib2

from apiclient import errors
from apiclient.discovery import build

http = credentials.authorize(http)
service = build('bigquery', 'v2')

Back to top

Next Steps

When you're ready to start using the API:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.