Para testar a API, siga as instruções de configuração alternativas neste guia e use o comando curl para testar a API sem configurar um ambiente de desenvolvimento de aplicativo completo.
Configuração para chamar a API diretamente
Esta seção descreve as etapas básicas necessárias para configurar seu ambiente local para testar a API Service Usage usando o comando curl. Ela tem como foco os desenvolvedores que precisam programar com os recursos da API Service Usage.
Ativar a API Service Usage
Para usar a API Service Usage, primeiro você precisa ativá-la no projeto doGoogle Cloud em que ela será usada:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-13 UTC."],[],[],null,["# Quickstart: Set up Service Usage for a development environment\n\nSet up Service Usage for a development environment\n==================================================\n\nThis page describes how to set up your development environment to use the\nService Usage API.\n\n- For most operational use cases, the simplest way to enable and disable services is to use Google Cloud console.\n- If you need to create scripts, you can use the Google Cloud CLI.\n- If you need to program against the Service Usage API, use one of the [client libraries](/service-usage/docs/libraries).\n- To experiment with the API, you can follow the alternative setup instructions in this guide and use the `curl` command to test the API without setting up a full application development environment.\n\nSet up to call the API directly\n-------------------------------\n\nThis section describes the basic steps necessary to set up your local\nenvironment to experiment with the Service Usage API using the\n`curl` command. It is aimed at developers who need to program against the\nService Usage API.\n| **Note:** You don't need to complete the instructions in this section if you want to list, enable, or disable services using Google Cloud console or the `gcloud` command line interface.\n\n### Enable the Service Usage API\n\nTo use the Service Usage API, you must first enable it in the\nGoogle Cloud project you want to use it for:\n\n1. Go to the Google Cloud console **API Library** page. \n [Go to the API Library page](https://console.cloud.google.com/project/_/apis/library/serviceusage.googleapis.com)\n2. Select the Google Cloud project that you want to use to access the service.\n3. On the API Library page, click **Enable**.\n4. Ensure that your user account has the [Service Usage Admin](https://cloud.google.com/iam/docs/understanding-roles#service-usage-roles) role.\n\n### Test with curl\n\n1. Define a convenient shell alias for calling Google REST APIs:\n\n alias gcurl='curl -H \"Authorization: Bearer $(gcloud auth print-access-token)\" -H \"Content-Type: application/json\"'\n\n2. Set an environment variable `PROJECT_ID` with the identifier of your\n project. This can be the project id or number:\n\n PROJECT_ID=\"my-project-id\"\n\n3. Ensure that you are logged into 'gcloud':\n\n gcloud auth login\n\n4. List the enabled APIs and services in this project:\n\n gcurl \"https://serviceusage.googleapis.com/v1/projects/${PROJECT_ID}/services?filter=state:ENABLED&fields=services.config.title,services.config.name\"\n\n If you see output like this, then your setup is successful: \n\n {\n \"services\": [\n {\n \"config\": {\n \"name\": \"bigquery.googleapis.com\",\n \"title\": \"BigQuery API\"\n }\n },\n {\n \"config\": {\n \"name\": \"bigquerystorage.googleapis.com\",\n \"title\": \"BigQuery Storage API\"\n }\n },\n ...\n\nNext steps\n----------\n\nFollow [Listing Services](/service-usage/docs/list-services) to list the APIs\nand services that are enabled or available in your Google Cloud projects."]]