appscript.dev
Guide Intermediate

Unlock the Advanced Google Services

Reach APIs the basic Apps Script services don't cover — Drive API, People API, BigQuery.

Published Sep 5, 2025

The everyday Apps Script services — DriveApp, GmailApp, SpreadsheetApp — are deliberately small. They wrap the most common operations in a friendly, hand-built API, but they only expose a slice of what Google’s products can actually do. Sooner or later you ask for something the basic service simply has no method for: a file’s full revision history, a contact’s structured phone numbers, a query against BigQuery.

That is when you reach for Advanced Google Services. These are thin, generated bindings over Google’s full REST APIs, switched on per-project from the editor. They give you the complete capability surface of a Google product, at the cost of a slightly lower-level, more verbose API. This guide shows how to enable one and when the trade-off is worth it.

Enable an advanced service

Advanced services are opt-in per script project. Turning one on takes three steps:

  1. In the editor, open the Services panel (the + next to “Services” in the left sidebar) and search for the API you need.
  2. Pick the API and choose a version — the latest version is usually correct unless you have a reason to pin an older one.
  3. Add it. Apps Script injects a global object named after the service — Drive, People, YouTube, BigQuery — that you call straight away.

Enabling a service does two things: it makes the global object available, and it adds the matching OAuth scopes to your project so the consent screen requests the right permissions. No npm, no imports — once added, the object is just there.

Example: Drive API for revision history

The basic DriveApp can open files and read their metadata, but it cannot list the revisions behind a file. The advanced Drive service can:

function listRevisions(fileId) {
  // Drive.Revisions.list maps directly onto the Drive REST endpoint.
  // The `fields` parameter trims the response to just what we need —
  // smaller payloads are faster and count less against quota.
  const res = Drive.Revisions.list(fileId, {
    fields: 'revisions(id,modifiedTime,lastModifyingUser)',
  });

  // `res.revisions` is an array of revision objects, oldest first.
  return res.revisions;
}

Notice the shape of the call: Service.Resource.method(args, optionalParams). That structure mirrors the underlying REST API one-to-one, so anything you read in Google’s REST documentation translates directly into Apps Script. The fields mask is worth a habit — requesting only the properties you use keeps responses lean and avoids hitting size limits on large results.

Handling paginated results

Unlike the basic services, an advanced list call returns only one page of data plus a token for the next. To get everything, you loop until the token disappears:

function listAllFiles() {
  const files = [];
  let pageToken;

  do {
    // Pass the previous pageToken to fetch the next page.
    const res = Drive.Files.list({
      pageSize: 100,                    // up to 100 results per request
      fields: 'nextPageToken, files(id,name)',
      pageToken: pageToken,             // undefined on the first pass
    });

    if (res.files) files.push(...res.files);

    // When nextPageToken is absent, there are no more pages.
    pageToken = res.nextPageToken;
  } while (pageToken);

  return files;
}

Forgetting this loop is the most common advanced-services bug: the code runs without error but quietly processes only the first hundred rows. Whenever a method name ends in list, assume it is paginated.

Why “advanced” vs basic

The two tiers are not competitors — they solve different problems. Choose by what you actually need:

Basic servicesAdvanced services
API styleHand-crafted, object-orientedGenerated, mirrors REST
CoverageCommon operations onlyThe full product surface
ErgonomicsFriendly, less codeVerbose, more parameters
IDE supportFull autocompleteFull autocomplete and typing
QuotasStandardUsually higher
SetupAlways availableMust be enabled per project

A few rules of thumb:

  • Reach for basic services first — they are shorter to write and cover the majority of tasks.
  • Switch to an advanced service when the basic one has no method for what you need, when you are hitting quota limits, or when you want to use fields masks and pagination for performance.
  • You can freely mix both in the same project. It is common to use DriveApp for simple file work and Drive for the one operation that needs the full API.

Watch out for

  • Some advanced services need a standard GCP project. Services like BigQuery require your script to be linked to a Google Cloud project you control, not the default hidden one. Set this up in Project Settings before the first call, or the service throws an authorisation error.
  • Advanced services do not auto-paginate. A list call returns one page plus a nextPageToken. If you forget to loop on that token, you silently process only the first page of results.
  • The OAuth scopes are broader. Enabling an advanced service often adds a wider scope than the basic equivalent, which means a more alarming consent screen for users. Review the scopes the project requests before publishing.
  • Versions can be deprecated. Pinning an old API version is fine until Google retires it. If a long-lived script suddenly fails, check whether the service version still exists.
  • Responses are plain objects, not service classes. An advanced-service result has no helper methods — you get raw JSON-shaped data. Do not expect the convenience methods that basic-service objects provide.