API
API 代表 應用程式介面.
API 是您可以 從從網站或資料庫取得資訊的方式。
While cloud storage is usually internal information shared within your app, APIs allow your solution to access external information from the internet.
Let’s say you are building a solution to help people decide what to wear based on the weather. You could spend lots of time uploading data about the weather into a database, but there are many websites that show the weather.
更好的解決方案是使用 API 從天氣網站擷取資料,並透過您的應用程式顯示給使用者。
要使用 API,您必須
- 尋找使用 API 的網站。這裡有一份 清單 按主題列出的可用公開 API。
- 閱讀他們的說明文件,瞭解如何使用他們的 API。大多數網站都會提供範例。
- 有些網站要求您在註冊 API 金鑰後才能使用其 API。 請注意,有些 API 需要付費才能使用。
- 將 API 程式碼納入 Thunkable。
以下是一些教程,可為您提供在 Thunkable 中使用 Web API 的練習。
注意! 在此處列出的一些教程中,Web API 元件顯示在「設計器」視窗中。但是,在當前版本的 Thunkable 中,您將在 Blocks Editor 的 Advanced 下找到 Web API 元件。
按兩下“+”以添加Web API元件。您可以在顯示的屬性視窗中或代碼中新增 URL 和查詢參數。對塊進行編碼應該是相同的。
以下是 FruityVice為香蕉返回的 JSON 字串。
{ "genus": "Musa",
"name": "Banana",
"id": 1,
"family": "Musaceae",
"order": "Zingiberales",
"nutritions":
{ "carbohydrates": 22,
"protein": 1,
"fat": 0.2,
"calories": 96,
"sugar": 17.2
}
}
希望您成功添加了第二個含有 API 資訊的營養標籤!
如果您想查看可能的解決方案,請按一下此按鈕。
Using APIs in your solution can be a very powerful tool, but it is not easy to implement!
您必須花時間閱讀網站的 API 文件,以瞭解如何取得您需要的資訊。
關鍵術語的審查
- 應用程式介面(API) – 一種可從其他網站或資料庫擷取資訊,並將其應用於您的數位解決方案的方法
我們正在更新本網站,以反映我們的新方向。Technovation 的全新品牌形象與擴大的使命已於 technovation.org 正式上線。您的課程與競賽資源仍可在此處查閱。
查看最新動態