Getting Started

This page describes the basic steps necessary to set up your local environment to experiment with Timeseries Insights API using the curl command.

NOTE: This is a guide to set up as Owner, to allow creating and deleting datasets. The Quickstart guide instead uses a shared read-only project.

Create or select a project

Enable Timeseries Insights API

To use Timeseries Insights API, you must first enable it in the Cloud project you want to use it for:

  1. Go to the Google Cloud Console API Library page.
    Go to the API Library page
  2. Select the Cloud project that you want to use to access the service.
  3. On the API Library page, click Enable.

Configure authorization

A convenient way to authorize your Cloud project to access Timeseries Insights API is to use a service account. To set up, do the following:

  1. Create a service account.
    1. Go to the Cloud Console Service Accounts page.
      Go to the Service Accounts page
    2. Select the Cloud project that you want to use to access the service.
    3. Create a service account. To learn how to create service accounts, see Creating and Managing Service Account.
  2. Grant your new service account the "Timeseries Insights DataSet Owner" role. To learn how to grant roles to service accounts, see Granting Roles to Service Accounts.
  3. Configure your local machine.

    1. Go to the Cloud Console API Credentials page.
      Go to the API Credentials page
    2. Create a service account key for your new service account and download its JSON credential file to your local machine. The examples in this guide assume the file path is ~/credentials.json. To learn how to create service account keys, see Creating and Managing Service Account Keys.
    3. Install oauth2l on your local machine so you can interact with the Google OAuth system.
    4. Optionally, use oauth2l to create a bearer token using your credential file; this verifies that your OAuth setup is correct and that your service account credential file is valid:

          oauth2l header --json ~/credentials.json cloud-platform

      When successful, the output is similar to the following:

          Authorization: Bearer y29.xxxxxxx

See OAuth 2.0 for detailed documentation about authorization.

Test with curl

  1. Define a convenient shell alias for calling Google REST APIs:

    alias gcurl='curl -H "$(oauth2l header --json ~/credentials.json cloud-platform" -H "Content-Type: application/json"'
  2. Set an environment variable PROJECT_ID with the identifier of your project:

  3. Ensure that you are logged into 'gcloud':

    gcloud auth login
  4. List the enabled APIs and services in this project:

    gcurl "${PROJECT_ID}/datasets"

    If you do not see an error, then your setup is successful.

Next steps

Follow Tutorial to learn about the API.