要使用 Cloud API,您还需要拥有一个 Google 项目。一个项目等效于一个开发者账号。它充当您的 Google Cloud 资源的资源容器。它还为使用 Google Cloud 服务提供了一个隔离边界,从而使您可以在项目级层独立管理配额限制和结算。使用的遥测和信息中心也按项目分组。如果您还没有项目,则可以使用 Google Cloud 控制台进行创建。
一个项目可以拥有各种各样的资源,包括 API 密钥、OAuth 客户端、服务账号、Compute Engine 虚拟机、Cloud Storage 存储分区和 BigQuery 数据集。当应用调用 Cloud API 时,拥有应用凭证的项目称为客户端项目,而拥有目标资源的项目称为资源项目。一个 API 请求可能涉及多个资源,从而涉及多个资源项目。
如果您出于任何原因要停止使用 Google Cloud,可以使用 Google Cloud 控制台删除项目。在经过保留期限之后,您的项目和项目中的所有资源都将被删除。请注意,不同类型的数据的保留期限有所不同。
发现 API
在使用任何 Cloud API 之前,您应该使用 Google Cloud 控制台 API 库浏览可用的 Cloud API,并发现最符合您业务需求的 API。如需详细了解特定 Cloud API,请访问其公共文档网站,例如 Spanner API。
启用 API
某些 Cloud API 默认处于启用状态。如需使用默认情况下未启用的 Cloud API,您必须为项目启用该 API。根据您的应用所涉及的服务和项目,包括客户端项目和资源项目,您可能需要为多个项目启用 API。当您启用某个依赖于其他 API 的 API 时,这些 API 也会同时启用。
启用 API 需要您接受 API 的服务条款和结算责任。您需要获得项目的 serviceusage.services.enable 权限才能启用 API。如需了解详情,请参阅 Service Usage 访问权限控制。
此外,要启用的服务必须设为公开,否则服务所有者必须向用户授予专用服务的 servicemanagement.services.bind 权限。如需了解详情,请参阅 Service Management 访问权限控制。
如果您要使用 Cloud API 构建应用,我们建议您使用 Google Cloud 客户端库(如果有的话)。客户端库处理常见的 API 功能,以方便您进行身份验证、错误处理、重试和载荷验证。您需要在初始化期间将应用凭据传递给客户端库,以便客户端库可以代表您的应用调用Google Cloud API。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eThis guide outlines the steps for developers to begin using Google Cloud APIs, starting with experimenting using \u003ccode\u003ecurl\u003c/code\u003e commands.\u003c/p\u003e\n"],["\u003cp\u003eUtilizing Google Cloud APIs necessitates a Google account and a Google project, which serves as a resource container and isolation boundary.\u003c/p\u003e\n"],["\u003cp\u003eBefore using a Cloud API, one must discover it in the API Library and then enable it for the relevant project(s), which may involve accepting terms and billing responsibility.\u003c/p\u003e\n"],["\u003cp\u003eFor using certain APIs and building full applications, a billing account linked to the project and proper authentication credentials, such as Application Default Credentials or API keys, are required.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Cloud Client Libraries are recommended for building applications, as they simplify API interactions by managing authentication, error handling, retries, and payload validation.\u003c/p\u003e\n"]]],[],null,["# Getting started\n\nThis page explains how developers can get started using Google Cloud APIs.\n\nIf you are using Google Cloud APIs for the first time, you can follow\nthe steps in this guide to call the APIs using `curl` commands. You can use\n`curl` commands to experiment with an API before you develop your application.\n\nCreating a Google account\n-------------------------\n\nTo use Google Cloud APIs in your applications, you first need to have a\nGoogle account. This allows you to use Google developer products, including\n[Google Cloud console](https://console.cloud.google.com/),\n[gcloud CLI](/sdk), [Cloud Logging](/logging), and\n[Cloud Monitoring](/monitoring). If you're new to Google Cloud,\n[create an account](https://console.cloud.google.com/freetrial)\nto evaluate how our products perform in real-world scenarios. New customers\nalso get $300 in free credits to run, test, and deploy workloads.\n\nCreating a Google project\n-------------------------\n\nTo use Cloud APIs, you also need to have a Google project. A project is\nequivalent to a developer account. It serves as a resource container for\nyour Google Cloud resources. It also provides an isolation boundary for your\nusage of Google Cloud services, so you can manage quota limits and billing\nindependently at the project level. Usage telemetry and dashboards are grouped\nby projects as well. If you don't already have a project, you can create one\nusing the [Google Cloud console](https://console.cloud.google.com/).\n\nA project can own a wide range of resources, including API keys, OAuth clients,\nservice accounts, Compute Engine VMs, Cloud Storage buckets, and BigQuery\ndatasets. When an\napplication calls a Cloud API, the project that owns the application\ncredentials is called the *client project* , and the project that owns the\ntarget resource is called the *resource project*. One API request may touch\nmultiple resources, hence multiple resource projects are involved.\n\nIf you want to stop using Google Cloud for any reasons, you can use\n[Google Cloud console](https://console.cloud.google.com/) to delete your project. Your\nproject and all resources in the project will be deleted after the retention\nwindow. Note that different types of data have different retention periods.\n\nDiscovering APIs\n----------------\n\nBefore using any Cloud APIs, you should use Google Cloud console\n[API Library](https://console.cloud.google.com/apis/library/browse) to\nbrowse available Cloud APIs and discover the ones that best meet your business\nneeds. For more information about a specific Cloud API, visit its public\ndocumentation site, such as [Spanner API](/spanner).\n\nEnabling APIs\n-------------\n\nSome Cloud APIs are enabled by default. To use a Cloud API that is not enabled\nby default, you must enable it for your project. Depending on which\nservices and which projects are involved from your application, including the\nclient project and resource projects, you may need to enable an API for\nmultiple projects. When you enable an API that depends on other APIs, those APIs\nare also enabled at the same time.\n\nEnabling an API requires you to accept the Terms of Service and billing\nresponsibility for the API. You need permission `serviceusage.services.enable`\non the project to enable APIs. For more information, see Service Usage\n[Access Control](/service-usage/docs/access-control).\n\nIn addition, the service to enable must either be public, or else the service\nowner must grant the user the `servicemanagement.services.bind` permission on\nthe private service. See [Service Management Access Control](/service-infrastructure/docs/service-management/access-control) for more\ninformation.\n\nTo enable an API for a project using the console:\n\n1. Go to the [Google Cloud console API Library](https://console.cloud.google.com/apis/library?project=_).\n2. From the projects list, select the project you want to use.\n3. In the API Library, select the API you want to enable. If you need help finding the API, use the search field and/or the filters.\n4. On the API page, click **ENABLE**.\n\nFrom the same page you can disable an API for your project if you no longer\nuse it to avoid misuse and accidental billing charges. You can also enable\nand disable Cloud APIs using the [gcloud CLI](/sdk/docs) and the\n[Service Usage API](/service-usage/docs/reference/rest/v1/services/enable): \n\n $ gcloud services enable pubsub.googleapis.com\n $ gcloud services disable pubsub.googleapis.com\n\nEnabling billing\n----------------\n\nSome Cloud APIs charge for usage. You need to enable billing for your project\nbefore you can start using these APIs in your project. The API usage in a\nproject is charged to the billing account associated with the project.\n\nIf you don't have a billing account, go to the\n[Google Cloud console billing page](https://console.cloud.google.com/billing)\nand follow the instructions to create one. Then\n[link your billing account](https://console.cloud.google.com/billing/linkedaccount?project=_)\nto your project.\n\nAuthenticating to APIs\n----------------------\n\nHow you authenticate to an API depends on your development environment and what\nauthentication methods the API supports.\n\nSetting up [Application Default Credentials](/docs/authentication/provide-credentials-adc) for use in a variety of\nenvironments is the most common approach, and is recommended for most\napplications. If the API supports [API keys](/docs/authentication/api-keys), that is another option.\nIf your application needs to access Cloud resources owned by your end users, you\n[create an OAuth 2.0 Client ID and use the authentication libraries](https://developers.google.com/identity/protocols/oauth2/web-server).\n\nFor general information about authentication, see\n[Authentication at Google](/docs/authentication).\n\nBuilding applications\n---------------------\n\nIf you are building an application using Cloud APIs, we recommend you to use\n[Google Cloud Client Libraries](/apis/docs/cloud-client-libraries) if\navailable. The client libraries can handle common API features for your\nconvenience, such as authentication, error handling, retry, and payload\nvalidation. You need to pass your application credentials to the client\nlibraries during initialization, so the client libraries can make calls to\nGoogle Cloud APIs on behalf of your application.\n\nSee the following step-by-step guides that use the client libraries for some\npopular APIs:\n\n- [Cloud Billing Budget API with Node.js](https://console.cloud.google.com/?tutorial=billing--budget--billing-budget-api-nodejs).\n- [Cloud Billing Budget API with Python](https://console.cloud.google.com/?tutorial=billing--budget--billing-budget-api-python).\n- [Cloud Logging with Node.js](https://console.cloud.google.com/?tutorial=logging--logging-nodejs).\n- [Cloud Logging with Python](https://console.cloud.google.com/?tutorial=logging--logging-python).\n- [Cloud Logging with Go](https://console.cloud.google.com/?tutorial=logging--logging-go).\n- [Cloud Logging with Java](https://console.cloud.google.com/?tutorial=logging--logging-java).\n- [Speech-to-Text with Node.js](https://console.cloud.google.com/?tutorial=speech-to-text--speech-to-text-nodejs).\n- [Speech-to-Text with Python](https://console.cloud.google.com/?tutorial=speech-to-text--speech-to-text-python).\n- [Speech-to-Text with Go](https://console.cloud.google.com/?tutorial=speech-to-text--speech-to-text-go).\n- [Speech-to-Text with Java](https://console.cloud.google.com/?tutorial=speech-to-text__speech-to-text-java).\n\nFor more information, see\n[Client Libraries Explained](/apis/docs/client-libraries-explained).\n\nMore information\n----------------\n\n- For more information about authentication, see\n [Authentication at Google](/docs/authentication).\n\n- For more information about error handling, see\n [Handling Errors](/apis/design/errors#handling_errors).\n\n- For more information about billing, see\n [Create, modify, or close your billing account](/billing/docs/how-to/manage-billing-account).\n\n- For more information about enabling billing on your project, see\n [Modify a project's billing settings](/billing/docs/how-to/modify-project).\n\n- For more information about enabling and disabling APIs, see\n [Enabling and disabling services](/service-usage/docs/enable-disable)."]]