Google Data API 範例
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
警告:本頁面介紹的是 Google 的舊版 API (Google Data API),僅適用於Google Data API 目錄中列出的 API,其中許多 API 都已由新版 API 取代。如需特定新 API 的相關資訊,請參閱該 API 的說明文件。如要瞭解如何使用較新的 API 授權要求,請參閱「Google 帳戶驗證和授權」。
本頁面提供範例程式碼的連結和相關資訊。
目錄
- JavaScript 範例
- JSON 範例
- 小工具範例
- Java 範例
- .NET 範例
- 其他語言
JavaScript 範例
您可以透過網頁瀏覽器使用 JavaScript 用戶端程式庫,與 Base Data API、Blogger Data API、Calendar Data API、Contacts Data API 和 Finance Data API 互動。
注意:本節先前的範例已移除,因為這些範例使用的 API 和/或驗證方法已不適用。
JSON 範例
這些是實際範例,點選即可查看。詳情請參閱「搭配 Google Data API 使用 JSON」。
Google 日曆
- 日曆中的近期活動
- 這個範例示範如何使用 Calendar Data API 提供的 JSON 輸出格式,在網頁上顯示 Google 日曆中即將舉辦的活動清單。
Blogger
- Blogger 的近期貼文
- 這個範例示範如何使用 Blogger Data API 提供的 JSON 輸出格式,顯示 Blogger Beta 託管的網誌中最近發布的文章清單。
試算表
- 讀取 Google 試算表資料
- 這個範例示範如何使用試算表資料 API 提供的 JSON 輸出格式,在網頁上顯示 Google 試算表的資料。
小工具範例
如要進一步瞭解如何建立 Google Data API 小工具,請參閱「建立 Google Data 小工具」或完整的「撰寫 OAuth 小工具」說明文件。
- Blogger 小工具
- YouTube 小工具
Java 範例
用戶端程式庫隨附的範例
這些範例位於可下載的 Java 用戶端程式庫套件中。詳情請參閱 Java 用戶端程式庫開發人員指南,或下載 Java 用戶端程式庫。
- java/sample/authsub/
- 使用 Java Servlet 實作的 GData AuthSub Proxy;透過 Proxy 存取資料的 JavaScript 用戶端範例。
- java/sample/calendar/
- 簡單的用戶端,可對 Google 日曆執行多項硬體連線操作。
- java/sample/codesarch/
- 指令列用戶端,用於查詢 Google Code Search 資料 API。
- java/sample/spreadsheet/
- 使用 Google 試算表 API 的範例應用程式。
- java/sample/appsforyourdomain/
- 使用 G Suite API 的範例應用程式。
- java/sample/blogger/
- 使用 Blogger API 的應用程式範例。
- java/sample/contacts/
- 使用 Google Contacts API 的範例應用程式。
- java/sample/docs/
- 使用 Google Doclist API 的範例應用程式。
- java/sample/gbase/
- 使用 Google Base API 的範例應用程式。
- java/sample/photos/
- 使用 Picasa Web Albums API 的範例應用程式。
- java/sample/sidewiki/
- 使用 Google 網頁註解 API 的範例應用程式。
- java/sample/webmastertools/
- 使用 Webmaster API 的範例應用程式。
- java/sample/youtube/
- 使用 YouTube API 的範例應用程式。
- YouTubeSample ASP 頁面
- 使用用戶端程式庫的影片搜尋和上傳範例。
.NET 範例
用戶端程式庫隨附的範例
這些範例位於可下載的 .NET 用戶端程式庫套件中。詳情請參閱 .NET 用戶端程式庫開發人員指南,或下載 .NET 用戶端程式庫。
- clients/cs/samples/blogger/
- 使用 Blogger API 的範例應用程式。
- clients/cs/samples/calendar/
- 使用 Google Calendar Data API 的範例應用程式。
- clients/cs/samples/spreadsheets/
- 使用 Google 試算表 API 的範例應用程式。
- clients/cs/samples/DocListUploader/
- 將文件上傳至 Google 文件。
- clients/cs/samples/DocListExporter/
- 以各種格式匯出 Google 文件。
- clients/cs/samples/PhotoBrowser/
- 使用 Picasa Web Album API 的範例應用程式。
- clients/cs/samples/YouTubeSample/
- 使用 YouTube API 的範例應用程式。
- clients/cs/samples/appsforyourdomain/
- 使用 G Suite API 的範例應用程式。
其他範例
- 聯絡人更新程式
- 這個 WPF 範例示範如何使用 Contacts API 讀取及更新聯絡人。
你也可以下載 .zip 檔案。
- Google 文件 PDF 串連工具
- 將 PDF 檔案串連在一起,然後將結果上傳至 Google 文件。
你也可以下載 .zip 檔案。
其他語言
C++
- Documents List API 範例
- 允許使用者檢視、上傳、刪除及搜尋 Google 文件、試算表、簡報和資料夾。這個範例也會列出具有讀取/寫入權限的使用者,展示 API 的 ACL 功能。
小茹
- DocList Manager
- Ruby on Rails 範例,可讓使用者查看及匯出文件。
返回頁首
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eThis page focuses on Google's older Google Data APIs and provides links to relevant documentation for newer APIs.\u003c/p\u003e\n"],["\u003cp\u003eThe page offers various code samples in JavaScript, JSON, Gadget, Java, .NET, and other languages to showcase interactions with the APIs.\u003c/p\u003e\n"],["\u003cp\u003eMany previously available JavaScript samples have been removed due to reliance on outdated APIs or authentication methods.\u003c/p\u003e\n"],["\u003cp\u003eUsers can find bundled sample code within the downloadable Java and .NET client library packages.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides documentation and resources for creating Google Data API gadgets and using JSON with Google Data APIs.\u003c/p\u003e\n"]]],[],null,["# Google Data APIs Samples\n\n**Warning** : This page is about Google's older APIs, the Google Data APIs; it's relevant only to the APIs that are listed in the [Google Data APIs directory](/gdata/docs/directory), many of which have been replaced with newer APIs. For information about a specific new API, see the new API's documentation. For information about authorizing requests with a newer API, see [Google Accounts Authentication and Authorization](/accounts).\n\nThis page provides links and information about sample code.\n\nContents\n--------\n\n1. [JavaScript samples](#JavaScript)\n2. [JSON samples](#JSON)\n3. [Gadget samples](#Gadgets)\n4. [Java samples](#Java)\n5. [.NET samples](#NET)\n6. [Other languages](#OTHERLANGS)\n\nJavaScript samples\n------------------\n\nThe [JavaScript client library](/gdata/docs/js)\ncan be used from web browsers to interact with the [Base Data API](/base), [Blogger Data API](/blogger/docs/1.0/developers_guide_js),\n[Calendar Data API](/google-apps/calendar/v1/developers_guide_javascript), [Contacts Data API](/google-apps/contacts/v1/developers_guide_js), and\n[Finance Data API](/finance/docs/1.0/developers_guide_js).\n\n**Note**: The samples that were previously in this section have been removed because they relied on APIs and/or authentication methods that are no longer available.\n\nJSON samples\n------------\n\nThese are live samples; click to view them. For more information, see [Using JSON with Google Data APIs](/gdata/json).\n\n### Google Calendar\n\n[Upcoming events from Calendar](/gdata/samples/cal_sample)\n: This sample demonstrates displaying a list of upcoming calendar events from a Google Calendar on a web page using the JSON output format provided by the Calendar Data API.\n\n### Blogger\n\n[Recent posts from Blogger](/gdata/samples/blogger_sample)\n: This sample demonstrates displaying a list of recent posts from a blog hosted on Blogger Beta using the JSON output format provided by the Blogger Data API.\n\n### Spreadsheets\n\n[Reading Google Spreadsheets data](/gdata/samples/spreadsheet_sample)\n: This sample demonstrates displaying data from a Google Spreadsheet on a web page using the JSON output format provided by the Spreadsheet Data API.\n\nGadget samples\n--------------\n\nFor more information on creating Google Data API gadgets, see [Creating a Google Data Gadget](/gdata/articles/gdata_gadgets) or the full [Writing OAuth Gadgets](/gadgets/docs/oauth) documentation.\n\n[Blogger gadget](http://code.google.com/p/gdata-samples/source/browse/trunk/gadgets/blogger/blogger_gadget.xml)\n[YouTube gadget](http://gadget-doc-examples.googlecode.com/svn/trunk/opensocial-gadgets/oauth-test.xml)\n\nJava samples\n------------\n\n### Samples bundled with the client library\n\nThese samples can be found in the downloadable Java client library\npackage. For more information, see the [Java\nclient library developer's guide](/gdata/client-java), or [download the Java client library](//code.google.com/p/gdata-java-client/downloads/list).\n\n[java/sample/authsub/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/authsub)\n: GData AuthSub proxy, implemented using Java servlets; sample JavaScript client that accesses data through the proxy.\n\n[java/sample/calendar/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/calendar)\n: Simple client that performs several hardwired manipulations on a Google Calendar.\n\n[java/sample/codesarch/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/codesearch)\n: Command line client to query the Google Code Search data API.\n\n[java/sample/spreadsheet/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/spreadsheet)\n: Sample apps using Google Spreadsheet API.\n\n[java/sample/appsforyourdomain/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/appsforyourdomain)\n: Sample apps using G Suite API.\n\n[java/sample/blogger/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/blogger)\n: Sample apps using Blogger API.\n\n[java/sample/contacts/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/contacts)\n: Sample apps using Google Contacts API.\n\n[java/sample/docs/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/docs)\n: Sample apps using Google Doclist API.\n\n[java/sample/gbase/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/gbase)\n: Sample apps using Google Base API.\n\n[java/sample/photos/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/photos)\n: Sample apps using Picasa Web Album API.\n\n[java/sample/sidewiki/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/sidewiki)\n: Sample apps using Google Sidewiki API.\n\n[java/sample/webmastertools/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/webmastertools)\n: Sample apps using Webmaster API.\n\n[java/sample/youtube/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/youtube)\n: Sample apps using YouTube API.\n\n[YouTubeSample ASP page](http://google-gdata.googlecode.com/svn/trunk/clients/cs/samples/YouTubeSample/)\n: Video search and upload sample using the client library.\n\n.NET samples\n------------\n\n### Samples bundled with the client library\n\nThese samples can be found in the downloadable .NET client library package. For more information, see the [.NET client library developer's guide](/gdata/client-cs), or [download the .NET client library](//code.google.com/p/google-gdata).\n\n[clients/cs/samples/blogger/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/blogger)\n: Sample apps using Blogger API.\n\n[clients/cs/samples/calendar/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/calendar)\n: Sample apps using Google Calendar Data API.\n\n[clients/cs/samples/spreadsheets/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/spreadsheets)\n: Sample apps using Google Spreadsheet API.\n\n[clients/cs/samples/DocListUploader/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/DocListUploader)\n: Uploads documents to Google Docs.\n\n[clients/cs/samples/DocListExporter/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/DocListExporter)\n: Exports Google Documents in various formats.\n\n[clients/cs/samples/PhotoBrowser/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/PhotoBrowser)\n: Sample apps using Picasa Web Album API.\n\n[clients/cs/samples/YouTubeSample/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/YouTubeSample)\n: Sample apps using YouTube API.\n\n[clients/cs/samples/appsforyourdomain/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/appsforyourdomain)\n: Sample apps using G Suite API.\n\n### Other examples\n\n[Contacts Updater](//code.google.com/p/gdata-samples/source/browse/#svn/trunk/contacts/ContactsUpdater)\n: A WPF sample that demonstrates how to read and update your contacts using the Contacts API.\n A [.zip file](http://gdata-samples.googlecode.com/svn/trunk/contacts/ContactsUpdater/ContactsUpdater.zip) is also available.\n\n[Google Docs PDF Concatenator](//code.google.com/p/gdata-samples/source/browse/#svn/trunk/doclist/PdfConcatenate)\n: Concatenates PDF files together and uploads the result to Google Docs.\n A [.zip file](http://gdata-samples.googlecode.com/files/PdfConcatenate.zip) is also available.\n\nOther languages\n---------------\n\n### C++\n\n[Documents List API sample](//code.google.com/p/gdata-cpp-util/source/browse/trunk/doclist_sample.cc)\n: Allows users to view, upload, delete, and search their Google documents, spreadsheets, presentations, and folders. This sample\n also demonstrates the API's ACL functionality by listing the users who have read/write permissions.\n\n### Ruby\n\n[DocList Manager](//code.google.com/p/gdata-samples/source/browse/#svn/trunk/doclist/DocListManager)\n: Ruby on Rails sample that allows users to view and export documents.\n\n[Back to top](#top)"]]