Bibliotecas de cliente da API Maps Datasets

Nesta página, mostramos como começar a usar as bibliotecas de cliente da API Maps Datasets.

Leia mais sobre as bibliotecas de cliente em Explicações sobre bibliotecas de cliente.

Instale a biblioteca de cliente

Node.js

Para mais informações, consulte Como configurar um ambiente de desenvolvimento em Node.js.

npm install @googlemaps/maps-platform-datasets

Python

Para mais informações, consulte Como configurar um ambiente de desenvolvimento em Python.

pip install --upgrade google-maps-mapsplatformdatasets

Configurar a autenticação

Quando você usa bibliotecas de cliente, utiliza o Application Default Credentials (ADC) para fazer a autenticação. Para acessar informações sobre como configurar o ADC, consulte Fornecer credenciais para o Application Default Credentials. Para informações sobre como usar o ADC com bibliotecas de cliente, consulte Autenticar usando bibliotecas de cliente.

Usar a biblioteca de cliente

Node.js

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Parent project that will own the dataset.
 *  Format: projects/{$project}
 */
// const parent = 'abc123'
/**
 *  Required. The dataset version to create.
 */
// const dataset = {}

// Imports the Mapsplatformdatasets library
const {MapsPlatformDatasetsClient} = require('@googlemaps/maps-platform-datasets').v1;

// Instantiates a client
const mapsplatformdatasetsClient = new MapsPlatformDatasetsClient();

async function callCreateDataset() {
  // Construct request
  const request = {
    parent,
    dataset,
  };

  // Run request
  const response = await mapsplatformdatasetsClient.createDataset(request);
  console.log(response);
}

callCreateDataset();

Python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.maps import mapsplatformdatasets_v1


def sample_create_dataset():
    # Create a client
    client = mapsplatformdatasets_v1.MapsPlatformDatasetsClient()

    # Initialize request argument(s)
    request = mapsplatformdatasets_v1.CreateDatasetRequest(
        parent="parent_value",
    )

    # Make the request
    response = client.create_dataset(request=request)

    # Handle the response
    print(response)

Outros recursos

Node.js

Python