[ 筆記 ] API 文件 範例


Posted by krebikshaw on 2020-07-05

以下內容是參考 此篇文章 之紀錄。

其餘 API 文件相關筆記會紀錄於此

Restaurant API

最新版本: v3.0

Restaurant API 為幫助開發者,獲取及使用全台的餐廳資料,如果需要進行新增、刪除、更改資料的功能,必須要先申請 token 以獲得權限。

使用說明

說明 Method token path 參數
獲取所有餐廳 GET /restaurant _limit:限制回傳資料數量,上限 100
獲取單一餐廳 GET /restaurant/:id
新增餐廳 POST 必須 /restaurant name: 餐廳名
刪除餐廳 DELETE 必須 /restaurant/:id
更改餐廳資訊 PATCH 必須 /restaurant/:id name: 餐廳名

Request 參數說明

  • _limit: int
  • name: string

Get Start

Base URL: https://restaurant.com

Example GetResturant Request
你可以選擇其中一種方式,獲得前 3 家餐廳的資料。

  1. 於終端機使用 curl 發 request

    curl -X GET "https://restaurant.com/restaurant?_limit=3"
    
  2. 在 Node.js 環境下,使用 npm 套件:request 發送 HTTP request

    const request = require('request');
    request.get(
    'https://restaurant.com/restaurant?_limit=3', (error, response, body) => {
     console.log(JSON.parse(body));
    },
    );
    

Example GetResturant Response
Response 欄位說明

  • id: 餐廳編號
  • name: 餐廳名稱
  • phone: 餐廳電話
  • address: 餐廳地址
  • price: 餐廳價位

    [
    {
     "id": "1",
     "name": "Just Happy Pizza",
     "phone": "0987123456",
     "address": "台北市好好吃街25號",
     "price": "$$$$$$$$$$"
    },
    {
     "id": "2",
     "name": "Good To Eat Bistro",
     "phone": "0971234856",
     "address": "台北市吃不飽街1號",
     "price": "$"
    },
    {
     "id": "3",
     "name": "Not Awesome at all Bakery",
     "phone": "0934567890",
     "address": "台北市掰不下去街10號",
     "price": "$$$$$"
    },
    ]
    

#API







Related Posts

F2E合作社|共用項目margin與padding|Bootstrap 5網頁框架開發入門

F2E合作社|共用項目margin與padding|Bootstrap 5網頁框架開發入門

js筆記---function()

js筆記---function()

基礎 HTML &  CSS

基礎 HTML & CSS


Comments