Setup for Full Access

Stay organized with collections Save and categorize content based on your preferences.

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 a project with Owner permission, which allows you to allow you to create and delete 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 Google 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.

    1. The "Timeseries Insights DataSet Owner" role might not be shown on the UI while Timeseries Insights API is in preview. You can use the role ID roles/timeseriesinsights.datasetsOwner with the gcloud command to grant the necessary access.

      gcloud projects add-iam-policy-binding "${PROJECT_ID}" --member="serviceAccount:${SVC_ACCOUNT}" --role=roles/timeseriesinsights.datasetsOwner --condition=None
  3. Configure your local machine.

    1. Go to the Google 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.

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"'

    NOTE: gcurl is different from gcurl-demo in The Quickstart Guide. gcurl-demo uses the demo project and is authenticated for read-only to the demo project.

  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.