Sign up for email announcements to stay updated on the latest information about the GMB API.

Basic setup

To proceed, make sure you've completed the steps in Prerequisites and that your project has been approved for Google My Business API access.

Enable the API

You can enable the Google My Business API in the developer console of your Google Developers project through either of two methods:

Use the provided shortcut to enable the API

To enable the Google My Business API, click the Enable the Google My Business API button below. Use the down arrow to select an existing project, or create a new project.

Enable the Google My Business API

If you haven't successfully completed all of the steps in Prerequisites, you might see the following error message:

"Something went wrong. Please try again."

Make sure that you've completed all of the required prerequisites and that you've requested access to the API.

Manually enable the API

If you've completed all of the Prerequisites and have been granted access to the API, but were unable to use the provided shortcut, you can enable the API manually with the following steps.

To enable an API for your project, do the following:

  1. Open the API Library in the Google API Console. If prompted, select a project or create a new one. The API Library lists all available APIs, grouped by product family and popularity.
  2. If the API you want to enable isn't visible in the list, use search to find it.
  3. Select the API you want to enable, then click the Enable button.
  4. If prompted, enable billing.
  5. If prompted, accept the API's Terms of Service.

Request an OAuth 2.0 client ID

Because your app accesses protected (non-public) data, you need an OAuth 2.0 client ID. This lets your app request authorization to access your organization's location data on behalf of your app's users.

Your application must send an OAuth 2.0 token with any Google My Business API request that accesses private user data.

If you haven't done so already, go to the "Credentials" section of the Google API Console and click Create credentials > OAuth client ID to create your OAuth 2.0 credentials. After you've created the credentials, you can see your client ID on the Credentials page. Click the client ID for details, such as client secret, redirect URIs, JavaScript origins address, and email address.

Learn REST basics

There are two ways to invoke the API:

If you decide not to use client libraries, you need to understand the basics of REST.

REST is a style of software architecture that provides a convenient and consistent approach to request and modify data.

The term REST is short for "Representational State Transfer." In the context of Google APIs, it refers to the use of HTTP verbs to retrieve and modify representations of data stored by Google.

In a RESTful system, resources are stored in a data store. A client sends a request for the server to perform a particular action, such as to create, retrieve, update, or delete a resource, and the server performs the action and sends a response. That response is often in the form of a representation of the specified resource.

In Google's RESTful APIs, the client specifies an action with an HTTP verb, such as GET, POST, PUT, or DELETE. The client specifies a resource by a globally unique uniform resource identifier (URI) of the following form:

https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters

Because all API resources have unique HTTP-accessible URIs, REST enables data caching and is optimized to work with the web's distributed infrastructure.

You might find the method definitions in the HTTP 1.1 standards documentation useful. They include specifications for GET, POST, PUT, and DELETE.

REST in the Google My Business API

The Google My Business API operations map directly to REST HTTP verbs.

The specific format for the Google My Business API is shown in the following URI:

https://mybusiness.googleapis.com/v4/resourcePath?parameters

The full set of URIs used for each supported operation in the API is summarized in the Google My Business API Reference documentation.

Resource IDs are defined by a resource path of the following form:

accounts/account_name/locations/locationId

The variables account_name and locationId represent the numeric portion of the ID.

The resource path to an account appears as in the following example:

accounts/0123456789

The resource path for a location appears in the following form:

accounts/0123456789/locations/9876543210

Learn JSON basics

The Google My Business API returns data in JSON format.

JavaScript Object Notation (JSON) is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information, see json.org.

Make a simple HTTP request

You can use the OAuth 2.0 Playground to experiment with the Google My Business API. Because the Google My Business API isn't a public API, there are a few extra steps you need to take to use it in the Playground. You need a client ID for a web application to proceed.

  1. Go to the Google API Console and open your project. If you don't have an OAuth client ID for web applications, create one now:
    1. From the Create credentials drop-down list, select OAuth client ID.
    2. For Application type, click Web Application.
    3. Add
      https://developers.google.com/oauthplayground
      as a valid redirect URI.
    4. Click Create.
  2. Copy the client ID to the clipboard.
  3. Go to OAuth 2.0 Playground.
  4. Click the gear icon to open the configuration options and make the following changes:
    1. Set OAuth flow to Client-side.
    2. Check Use your own OAuth credentials.
    3. Paste in your OAuth client ID.
  5. Close the configuration options.
  6. Under "Step 1 - Select & authorize APIs," paste the following scope for the Google My Business API into the field labeled as Input your own scopes:

    https://www.googleapis.com/auth/plus.business.manage
  7. Click Authorize APIs.
  8. Click Accept when prompted.
  9. Under "Step 2 - Configure request to API," paste the following URI into the Request URI field:

    https://mybusiness.googleapis.com/v4/accounts
  10. Click Send the request. The response should show a status of 200 OK.

For more information about how to make various types of requests, see the Google My Business API Reference.

Client libraries

The Google My Business API client libraries wrap the functionality of the Google My Business API. They provide functionality common to all Google APIs, such as HTTP transport, error handling, authentication, and JSON parsing.

To download client libraries, see Samples.