CAFECA-IO / BAIFA

https://baifa.vercel.app
GNU General Public License v3.0
0 stars 0 forks source link

API 規格(理解範圍/學習&確認撰寫規格) #337

Closed godmmt closed 1 year ago

godmmt commented 1 year ago

API 規格

認識理解 API 查找相關資料文件


參考資料: 《精通 API 架構》

預計參考網路文章:

godmmt commented 1 year ago

API 簡介|《精通 API 架構》導論

在軟體架構領域,有一些術語難以定義。就像 API,也就是 application programing interface(應用程式介面)。這個概念最早出現在非常久遠的 80 年前。已經存在很長時間的術語最終會被過度使用,並且在不同的問題空間有多種含義。我們認為 API 代表的是:

廣義上來講,API 可以分為兩大類,取決於 API 的呼叫是在行程內(in process)還是在行程外(out of process)。 這裡的行程是指作業系統(OS)的行程。

舉例來說,從一個類別到另一個類別的 Java 方法調用(method invocation)是行程內的 API 調用,因爲該呼叫是由進行呼叫的同一行程來處理的。 一個 .NET 應用程式使用 HTTP 程式庫呼叫外部的類 REST API 則是行程外的 API 調用,因爲該呼叫是由一個額外的外部行程所處理,而非由進行呼叫的行程處理。 行程外的 API 呼叫將涉及穿越網路的資料,那可能是區域網路、虛擬私有雲(virtual private cloud,VPC)網路、或網際網路(internet)。

godmmt commented 1 year ago

相關名詞解釋|ChatGPT






godmmt commented 1 year ago

相關名詞解釋|《精通 API 架構》導論


godmmt commented 1 year ago

相關名詞解釋|ChatGPT


godmmt commented 1 year ago

相關名詞解釋|ChatGPT


godmmt commented 1 year ago

以下內容的資料來源:淺談 API 與 RESTful API

API

其實概念就非常雷同,我們今天如果要寫信給朋友,就會請郵差依照我們提供的地址寄送給朋友,然後朋友就會依據信件內容回覆給我們。 我們套入程式的角度來看就像是:使用者(我)、郵差(API)、朋友(主機)

RESTful API

簡單來講 RESTful API 是一個 API 設計風格

早期我們在開發 API 的時候可能會是像以下這樣子來命名:

看起來是相當直覺沒有錯,但如果是採用 RESTful API 的話,它則會長得像是以下:

我們可以看到 RESTful API 風格的設計方式具有以下優勢:

除此之外這邊也要注意一下 RESTful API 的一些設計重點:

因此採用 RESTful API 風格設計是為了盡可能統一且可擴充,對於開發者來講也可以透過該 API 很直覺的理解到用途。

godmmt commented 1 year ago

take 8 hrs remain 4 hrs

godmmt commented 1 year ago

主任務:開 API 規格

子任務:


通常開 API 的流程是:等UI/UX畫面出來後,按照畫面開 API 規格

Luphia commented 1 year ago
  1. UI/UX 畫面出來就能討論 API 了,不用等畫面刻完
godmmt commented 1 year ago
  1. UI/UX 畫面出來就能討論 API 了,不用等畫面刻完

好的,瞭解了,謝謝。

godmmt commented 1 year ago

了解專案內容 卡在安裝開發環境 https://github.com/CAFECA-IO/BAIFA/issues/341 以及


主任務更新為:

remain 8 hrs

godmmt commented 1 year ago
  1. List all URLs in BAIFA

    ignore root URL: https://baifa-boy6tsv96-cafeca.vercel.




  1. List all APIs for each URLs

check them bellow:

godmmt commented 1 year ago

The way to quickly open the latest deployment

Here: 截圖 2023-11-24 上午9 56 53

And go here: 截圖 2023-11-24 上午9 54 47

godmmt commented 1 year ago

Page Title (html head title tag) : Home - BAIFA

截圖 2023-11-24 下午1 31 40

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app (英文)

  1. search 關鍵字提示 API ( request when input content change ) (input)

    • Method=GET
    • service root URL/api/v1/suggestions/:search-input?
    • Path Parameters : search-input
    • Response :

      {
        "suggestions": ["app", "apple", "apple pie", "android", "avocado"]
      }
  2. search 回傳搜尋結果 API (request when button is clicked) (button)

    轉跳到下方的 URL,並將 input value 用 params 傳遞 :

    https://baifa-boy6tsv96-cafeca.vercel.app/en/app/searching-result?search=2300

    進入此 URL 後自動打 API :

    • Method=GET
    • service root URL/api/v1/search/:search-input?
    • Path Parameters : search-input
    • Response :

      {
        "success": true,
        "value": [
          {
            "id": 0,
            "name": "Bitcoin",
            "blocks": 2,
            "transactions": 6
          },
          {
            "id": 1,
            "name": "Binance",
            "blocks": 1,
            "transactions": 1
          }
              // ...
        ]
      }
  3. 區塊鏈/加密貨幣/黑名單用戶 API

    • Method=GET
    • service root URL/api/v1/home-features
    • 畫面炫染後自動打 API
    • Response :

      {
          {
            "id": 0,
            "name": "Chains",
          ~~~~  "count": 5
          },
          {
            "id": 1,
            "name": "Crypto Currencies",
            "count": 5
          },
          {
            "id": 2,
            "name": "Black List",
            "count": 7
          }
      }
godmmt commented 1 year ago

Page Title (html head title tag) : Chains - BAIFA

image URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains

  1. Explore Blockchains API

    • Method=GET
    • service root URL/api/v1/chains-all
    • 畫面炫染後自動打 API
    • Response :

      {
        "success": true,
        "value": [
          {
            "id": 0,
            "name": "iSunCloud",
            "blocks": 2,
            "transactions": 6
          },
          {
            "id": 1,
            "name": "Ethereum",
            "blocks": 2,
            "transactions": 6
          },
          {
            "id": 2,
            "name": "Bitcoin",
            "blocks": 2,
            "transactions": 6
          },
          {
            "id": 3,
            "name": "Tether",
            "blocks": 4,
            "transactions": 7
          },
          {
            "id": 4,
            "name": "Binance",
            "blocks": 1,
            "transactions": 1
          }
        ]
      }
godmmt commented 1 year ago

Page Title : iSunCloud - BAIFA

image

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/isun

  1. Blocks API

    • Method=GET
    • service root URL/api/v1/isuncloud/blocks?start-date=:startTimestamp&end-date=:endTimestamp
    • Query Parameters : start-dateend-datestartTimestamp變數直接抓當下時間戳記,endTimestamp可以設定成往前幾個天數)
    • Response :

      {
          {
          "id": 230021,
          "date": 1679998900,
          "category": "Blocks",
          "stability_level":"High"
          },
          {
          "id": 230676,
          "date": 1679978920,
          "category": "Blocks",
          "stability_level": "Medium"
          }
          // ...
      }
  2. Blocks API query by Date (日曆功能)

    • Method=GET
    • service root URL/api/v1/isuncloud/blocks?start-date=:startTimestamp&end-date=:endTimestamp
    • Query Parameters : start-dateend-date
    • Response :

      {
          {
              "id": 230021,
              "date": 1679998900,
              "category": "Blocks",
              "stability_level":"High"
          },
          // ...
      }
  3. Transactions API

    • Method=GET
    • service root URL/api/v1/isuncloud/transations?start-date=:startTimestamp&end-date=:endTimestamp
    • Query Parameters : start-dateend-datestartTimestamp變數直接抓當下時間戳記,endTimestamp可以設定成往前幾個天數)
    • Response :

      {
          {
              "id": 990071,
            "date": 1692342345,
            "category": "Transactions",
            "stste": "success"
              "asset_type":"Crypto Currency"
          },
          {
              "id": 930291,
            "date": 1689352675,
            "category": "Evidence",
            "state": "false",
              "asset_type":"Crypto Currency"
          },
          {
          "id": 930032,
              "date": 1688342795,
              "category": "Transactions",
              "state": "pending"
          "asset_type":"NFT"
          }
          // ...
      }
  4. Transactions API query by Date (日曆功能)

    • Method=GET
    • service root URL/api/v1/isuncloud/transations?start-date=:startTimestamp&end-date=:endTimestamp
    • Query Parameters : start-dateend-date
    • Response :

      {
          {
          "id": 990071,
           "date": 1692342345,
           "category": "Transactions",
           "stste": "success"
          "asset_type":"Crypto Currency"
          },
          // ...
      }
godmmt commented 1 year ago

Page Title (html head title tag) : Block 230676 - BAIFA

image

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/isun/block/230676

前一個URL點選後,將 230676 這個 block id 用params傳至這個URL

  1. Block API

    • Method=GET
    • service root URL/api/v1/isuncloud/block/:block-id
    • Response :

      {
        "id": 230021,
        "date": 1679998900,
        "stability_level":"High",
        "management-team":[],
        "content":[{},{},{}],
        "miner_and_reward":{},
        "size": 3523
      }
godmmt commented 1 year ago
godmmt commented 1 year ago

Page Title (html head title tag) : Home - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app (英文)、 https://baifa-boy6tsv96-cafeca.vercel.app/app (正體中文)、 https://baifa-boy6tsv96-cafeca.vercel.app/cn/app (簡體中文)

畫面: image

Page Title (html head title tag) : Chains - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains

畫面: image

Page Title (html head title tag) : iSunCloud - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/isun

畫面 : image

Page Title (html head title tag) : Block 230676 - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/isun/block/230676

畫面: image

Page Title (html head title tag) : Transaction List of Block 230676 - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/transaction-list?blockId=230676

畫面:

Page Title (html head title tag) : Transaction 916841 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/btc/transaction/916841

Currency List - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/currencies

Bitcoin - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/currencies/btc

Address 110029 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/btc/address/110029

godmmt commented 1 year ago

14 APIs : for now total used 16 hours (total: 10 URLs) 5 URLs remaining : need more 4 hours

godmmt commented 1 year ago

更新:

Home - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app


Chains - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains


iSunCloud - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/isun


Block 230676 - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/isun/block/230676


Transaction List of Block 230676 - BAIFA

URL : https://baifa-boy6tsv96-cafeca.vercel.app/en/app/transaction-list?blockId=230676


Transaction 916841 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/btc/transaction/916841


Currency List - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/currencies


Bitcoin - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/currencies/btc


Address 110029 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/btc/address/110029


Interaction List of Address 110029 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/btc/address/110029/interaction?type=address


Transaction History of Address 114007 and Address 110029 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/transaction-list?addressId=114007&addressId=110029


Contract 311382 - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/chains/btc/contract/311382


Red Flag of Bitcoin - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/currencies/btc/red-flag


Black List - BAIFA

URL: https://baifa-boy6tsv96-cafeca.vercel.app/en/app/blacklist

godmmt commented 1 year ago

done.

19 APIs : total used 20 hours (total: 15 URLs)

godmmt commented 1 year ago

this issue total used : 37 hours