Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menyiapkan Penggunaan Layanan untuk lingkungan pengembangan
Halaman ini menjelaskan cara menyiapkan lingkungan pengembangan untuk menggunakan
Service Usage API.
Untuk sebagian besar kasus penggunaan operasional, cara termudah untuk mengaktifkan dan menonaktifkan layanan adalah dengan menggunakan konsol Google Cloud .
Jika perlu membuat skrip, Anda dapat menggunakan Google Cloud CLI.
Jika Anda perlu
memprogram terhadap Service Usage API, gunakan salah satu
library klien.
Untuk bereksperimen dengan API, Anda dapat mengikuti petunjuk penyiapan alternatif dalam panduan ini
dan menggunakan perintah curl untuk menguji API tanpa menyiapkan lingkungan pengembangan
aplikasi lengkap.
Menyiapkan untuk memanggil API secara langsung
Bagian ini menjelaskan langkah-langkah dasar yang diperlukan untuk menyiapkan lingkungan lokal Anda untuk bereksperimen dengan Service Usage API menggunakan perintah curl. Panduan ini ditujukan bagi developer yang perlu memprogram terhadap
Service Usage API.
Mengaktifkan Service Usage API
Untuk menggunakan Service Usage API, Anda harus mengaktifkannya terlebih dahulu di
projectGoogle Cloud yang ingin Anda gunakan:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]