部分 Google Cloud API 只有部分語言版本的 Cloud 用戶端程式庫。如果您想使用其中一種 API,且該 API 沒有您慣用語言版本的 Cloud 用戶端程式庫,您仍然可使用稱為 Google API 用戶端程式庫的舊版用戶端程式庫。如果您要升級已使用這些程式庫的專案,也可以使用這些程式庫。這類程式庫具有下列特性:
Firebase 是各項 Google 服務通用的解決方案,可用來在行動裝置上建構應用程式。這個平台提供包含用戶端程式碼的 SDK,可讓您透過 iOS、Android 和網路應用程式存取行動相關 Cloud API。如要瞭解支援的 Cloud API 和開始使用 Firebase 的方式,請參閱 Firebase 說明文件。
使用您自己的用戶端程式碼
如果您是經驗豐富的開發人員,而 Google 的用戶端程式庫無法滿足您的特定需求,您可以自行編寫自訂程式碼來直接存取服務的低階服務 API。
REST/HTTP API
所有 Cloud API 都提供簡單的傳統 JSON/REST 介面。如果您需要使用第三方 HTTP 用戶端程式庫,自行編寫自訂程式碼來直接存取 REST API,請參閱 HTTP 規定,進一步瞭解 Cloud API 如何與不同 HTTP 版本和實作項目搭配運作。
gRPC API
gRPC 是與語言和平台無關的開放原始碼遠端程序呼叫 (RPC) 系統,最初由 Google 開發。詳情請參閱 grpc.io。支援 gRPC 的 Cloud API 通常同時具備 REST 和 RPC 介面,因此支援 gRPC 的 API 用戶端除了可透過 HTTP 使用 JSON 與 REST 介面通訊,也能透過 HTTP2 使用通訊協定緩衝區和 gRPC 與 RPC 介面通訊。如要瞭解 API 是否支援 gRPC,請參閱其「API 和參考資料」部分。
如果 Cloud API 支援 gRPC,您就能使用支援 gRPC 的任何語言產生自己的 gRPC 用戶端程式庫。為此,您需要 API 的通訊協定緩衝區服務定義 (通常可從 GitHub 上的存放區取得)。接著,您可以依 grpc.io 中與您慣用語言相關的指示操作,以產生及使用您的用戶端。
如果您不想產生自己的 gRPC 程式碼,也仍可受惠於 gRPC:針對支援 gRPC 的 API,有越來越多這類 API 的 Cloud 用戶端程式庫會「暗中」使用 gRPC 與 Google 的服務通訊。就輸送量和 CPU 使用率而言,這項做法的效率大幅提升。與 JSON REST API 相比,使用 gRPC 存取 API 時,每個 CPU 的輸送量最多可增加 10 倍。Google 計畫盡可能將所有 Cloud 用戶端程式庫升級至 gRPC;在此期間,您仍可享有 Google 用戶端程式庫程式碼的所有其他優勢。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eCloud Client Libraries are the recommended method for accessing Cloud APIs programmatically, offering idiomatic code, consistent style, and handling low-level server communication.\u003c/p\u003e\n"],["\u003cp\u003eGoogle API Client Libraries serve as an alternative for APIs that lack Cloud Client Libraries in certain languages, providing access to the REST interface only, but with autogenerated interface code.\u003c/p\u003e\n"],["\u003cp\u003eFirebase SDK provides client code for accessing mobile-relevant Cloud APIs from iOS, Android, and Web applications, which is the go to solution for mobile device application development.\u003c/p\u003e\n"],["\u003cp\u003eExperienced developers can opt to write their own custom code to directly interact with the service's lower-level APIs, using the JSON/REST interface or gRPC.\u003c/p\u003e\n"],["\u003cp\u003egRPC-enabled Cloud APIs offer a performance advantage through the use of protocol buffers and gRPC over HTTP2, with some Cloud Client Libraries leveraging gRPC for improved efficiency.\u003c/p\u003e\n"]]],[],null,["# Client libraries explained\n\nClient libraries make it easier to access\n[Google Cloud APIs](/apis/docs/overview)\nfrom a supported language. While you can use Google Cloud APIs directly\nby making raw requests to the server, client libraries provide simplifications\nthat significantly reduce the amount of code you need to write.\n\nThis document explains the different types of client libraries that Google\nprovides for Cloud APIs. You can also find out more about the available\nlibraries for your product or language of choice in the product or language's\ndocumentation.\n\nCloud Client Libraries\n----------------------\n\n[Cloud Client Libraries](/apis/docs/cloud-client-libraries)\nare the recommended option for accessing Cloud APIs programmatically, where\navailable. Cloud Client Libraries use the latest client library model and:\n\n- Provide idiomatic code in each language to make Cloud APIs simple and intuitive to use.\n- Provide a consistent style across client libraries to simplify working with multiple Cloud services.\n- Handle all the low-level details of communication with the server, including [authenticating with Google](/docs/authentication/client-libraries).\n- Can be installed using familiar package management tools such as `npm` and `pip`.\n- In some cases, give you performance benefits by using gRPC. For more information, see the [gRPC APIs](#grpc_apis).\n\nYou can find installation instructions and reference material for the\nCloud Client Library on the Client Libraries page for the\n[Cloud API](/apis/docs/overview)s\nyou're using. You can find links to get started with the\nCloud Client Libraries and their reference documentation on the\n[Cloud Client Libraries page](/apis/docs/cloud-client-libraries).\n\nTry it for yourself\n-------------------\n\n\nIf you're new to Google Cloud, create an account to evaluate how our\nproducts perform in real-world scenarios. New customers also get $300 in\nfree credits to run, test, and deploy workloads.\n[Get started for free](https://console.cloud.google.com/freetrial)\n\nGoogle API Client Libraries\n---------------------------\n\nA few Google Cloud APIs don't have Cloud Client Libraries available in all\nlanguages. If you want to use one of these APIs and there is no\nCloud Client Library for your preferred language, you can still use the previous\nstyle of client library, called\n[Google API Client Libraries](https://developers.google.com/api-client-library/).\nYou might also use these libraries if you're upgrading a project that already\nuses them. These libraries:\n\n- Provide access to the API's REST interface only; gRPC is not supported.\n- Have autogenerated interface code that might not be as idiomatic as the Cloud Client Libraries.\n- Handle all the low-level details of communication with the server, including [authenticating with Google](/docs/authentication/client-libraries).\n- Can be installed using familiar package management tools such as `npm` and `pip`.\n\nThese libraries are linked on the Client Libraries page for the relevant Cloud\nAPIs.\n\nUsing the Firebase mobile platform\n----------------------------------\n\nFirebase is the Google-wide solution for building applications on mobile\ndevices. It offers an SDK with client code that lets you access mobile-relevant\nCloud APIs from iOS, Android, and Web apps. For information on the supported\nCloud APIs and how to get started with Firebase, see the\n[Firebase documentation](https://firebase.google.com/docs).\n\nUsing your own client code\n--------------------------\n\nIf you're an experienced developer and Google's client libraries don't meet your\nspecific needs, you can write your own custom code to access the service's\nlower-level service APIs directly.\n\n### REST/HTTP APIs\n\nAll Cloud APIs expose a simple traditional JSON/REST interface. If you need to\nwrite your own custom code to directly access the REST API using a third-party\nHTTP client library, you can find out more about how Cloud APIs work with\ndifferent HTTP versions and implementations in the\n[HTTP Guidelines](/apis/docs/http).\n\n### gRPC APIs\n\ngRPC is a language-neutral, platform-neutral, open source, remote procedure call\n(RPC) system initially developed at Google. You can find out about it at\n[grpc.io](http://www.grpc.io/).\ngRPC-enabled Cloud APIs generally have both REST and RPC interfaces, so rather\nthan just using JSON over HTTP to talk to the REST interface, gRPC-enabled API\nclients can also use\n[protocol buffers](https://developers.google.com/protocol-buffers/)\nand gRPC over HTTP2 to talk to the RPC interface. You can find out if an API is\ngRPC-enabled by checking its APIs and Reference section.\n\nIf a Cloud API is gRPC-enabled, you can generate your own gRPC client libraries\nfor it in any gRPC-supported language. To do this, you'll need the API's\n[protocol buffers](https://developers.google.com/protocol-buffers/)\nservice definition (typically available from\n[the repository on GitHub](https://github.com/googleapis/googleapis)).\nYou can then follow the instructions for your preferred language on\n[grpc.io](http://www.grpc.io/)\nto generate and use your client.\n\nIf you don't want to generate your own gRPC code, you can still benefit from\ngRPC: a growing number of Cloud Client Libraries for gRPC-enabled APIs use gRPC\n\"under the hood\" to communicate with Google's servers. This is significantly\nmore efficient in terms of throughput and CPU usage --- accessing an API\nusing gRPC can increase throughput per CPU by as much as a factor of 10 compared\nto the JSON REST API. Google plans to upgrade as many Cloud Client Libraries as\npossible to gRPC; in the meantime, you'll still get all the other advantages of\nGoogle's client library code.\n\nOther ways to access Cloud APIs\n-------------------------------\n\nIf you don't want to access an API programmatically, you can access some\nof the same functionality using the tools in\n[Google Cloud CLI](/sdk/docs) or using the\n[Google Cloud console](https://console.cloud.google.com/)."]]