想了解API介面,這一篇夠了

API技術開發者發表於2023-02-20

API介面:


API介面是什麼?


API全稱是:Application Programming Interface,即:應用程式介面。開發人員可以使用這些API介面進行程式設計開發,而又無需訪問原始碼,或理解內部工作機制的細節。


比較常見的現實場景是,在開發安卓應用時需要使用到安卓系統提供的API,在進行Windows桌面應用開發時需要用到微軟系統提供的API,在進行微信小程式開發時可使用微信開放介面API。

想了解API介面,這一篇夠了

更為常見的是,API介面很可能是遠端的服務端API,其背後採用Java、PHP、C#、Pyhon、C/C++、Ruby、Scala等一種或多種後端語言開發搭建,提供了資料儲存、通訊、各類服務等功能。一般是使用HTTP協議進行通訊,使用JSON格式序列化返回介面結果和資料。


API介面的地位與作用


API介面是專案開發過程中必要的組成部分之一,是客戶端應用與服務端應用通訊和橋樑。


除此之外,從專業角度來說,API不僅代表著介面本身,還蘊含了服務端的整體系統架構、資料儲存、服務端管理、第三方系統的整合等,只是對外看來,表現出來的是API介面。


可以說,API介面直接使用方是客戶端應用,地位是客戶端與服務端之間的通訊橋樑,是資訊化的橋樑,所擔負的作用是把業務功能透過介面服務形式具體化,為應用程式設計開發提供技術支援。

請求示例  請求介面

Curl PHP PHPsdk JAVA C# Python

-- 請求示例 url 預設請求引數已經URL編碼處理

curl -i "您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=652874751412&is_promotion=1"

響應示例

{

    "item": {

      "num_iid": "520813250866",

      "title": "三刃木過安檢創意迷你鑰匙扣鑰匙隨身多功能小刀包郵",

      "desc_short": "",

      "price": 25.8,

      "total_price": 0,

      "suggestive_price": 0,

      "orginal_price": "25.80",

      "nick": "歡樂購客棧",

      "num": "832",

      "min_num": 0,

      "detail_url": "

      "pic_url": "//img.alicdn.com/imgextra/i4/2596264565/TB2p30elFXXXXXQXpXXXXXXXXXX_!!2596264565.jpg",

      "brand": "三刃木",

      "brandId": "4036703",

      "rootCatId": "50013886",

      "cid": "50014822",

      "favcount": "4824",

      "fanscount": "1469",

      "crumbs": [],

      "created_time": "",

      "modified_time": "",

      "delist_time": "",

      "desc": "<p style=\"text-align:center;\"><span style=\"color:#ff0000;\"><span style=\"font-size:24.0px;\"><strong>小店所有產品都支援刻字,如需刻字,拍之前聯絡客服即可。</strong></span></span></p> <p style=\"text-align:center;\"><span style=\"font-size:18.0px;\"><strong>炎炎夏日來臨,一把隨身攜帶行動式的摺疊小刀,<span style=\"color:#ff0000;\">帶開瓶器功能</span>,喝酒不用愁。(鑰匙刀不帶開瓶器功能)</strong></span></p> <p style=\"text-align:center;\"><strong style=\"color:#000000;line-height:1.5;\"><span style=\"font-size:18.0px;\"><span style=\"line-height:18.0px;\">可以當吊牌項鍊裝飾,也可當鑰匙扣掛飾, 水果刀 開瓶器 戶外防身.</span></span></strong></p> <p style=\"text-align:center;\"><strong style=\"line-height:1.5;\"><span style=\"font-size:24.0px;\">部分客戶跟我們反映鏈子質量還不夠好,因此小店已重新訂購一批質量更好的鏈子贈送,<span style=\"color:#ff0000;\">加量不加價</span>,只為讓你買的更舒心,戴的更放心。</span></strong></p> <p style=\"text-align:center;\"><span style=\"font-size:36.0px;\"><strong>購買就送<span style=\"color:#ff0000;\">工具刀卡和鏈子</span>一條</strong></span></p> <p style=\"text-align:center;\"><span style=\"font-size:36.0px;\"><strong><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2Sci2jXXXXXXFXpXXXXXXXXXX_!!2596264565.png\" size=\"611x442\"> </strong></span></p> <p style=\"text-align:center;\"><span style=\"font-size:18.0px;\"><strong>璀璨鑽石套餐包含【SK016D鑰匙扣+GJ019C+GJ017D工具卡】</strong></span><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2wWohmXXXXXX8XXXXXXXXXXXX_!!2596264565.jpg\" size=\"750x600\" /></p> <p style=\"text-align:center;\"><span style=\"font-size:18.0px;\"><strong>超凡大師套餐包括【304不鏽鋼鑰匙扣+GJ019C+GJ017D工具卡】</strong></span><a href=\"//item.taobao.com/item.htm?id=520798805877\" target=\"_blank\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2_uiXnFXXXXXBXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"float:none;margin:0.0px;\" /></a></p> <p style=\"text-align:center;\">&nbsp;</p> <p style=\"text-align:center;\"><span style=\"font-size:18.0px;\"><strong>最強王者套餐包括【鈦鋼鑰匙扣+GJ019C+GJ017D工具卡】<a href=\"//item.taobao.com/item.htm?id=520801586805\" target=\"_blank\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2Gm9xnFXXXXbmXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"float:none;margin:0.0px;\" /></a> </strong></span></p> <p style=\"text-align:center;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB28Ox4b77OyuJjSsplXXXqdpXa_!!2596264565.jpg\" size=\"749x553\"> <img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2.mTddVXXXXbeXpXXXXXXXXXX_!!2596264565.jpg\" style=\"line-height:1.5;\" size=\"750x653\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB21Ro.jl0lpuFjSszdXXcdxFXa_!!2596264565.jpg\" size=\"750x653\"> <img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2q9CelVXXXXcUXXXXXXXXXXXX_!!2596264565.jpg\" size=\"750x340\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB21EX9lVXXXXaXXpXXXXXXXXXX_!!2596264565.jpg\" size=\"750x416\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2udCylVXXXXXgXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2EARxjB8lpuFjSspaXXXJKpXa_!!2596264565.jpg\" size=\"750x515\"> <img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2ssuwlVXXXXafXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2nAHqgyC9MuFjSZFoXXbUzFXa_!!2596264565.jpg\" size=\"750x606\"> <img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2ahCelVXXXXc_XXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2w1JnjwRkpuFjy1zeXXc.6FXa_!!2596264565.jpg\" size=\"750x469\"> <img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2C902lVXXXXbnXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2sGR3lVXXXXblXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2ZBGxlVXXXXXMXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2MjWklVXXXXcaXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2UgV3lVXXXXbdXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2ip5XlVXXXXX2XpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"> <img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2sMTBdVXXXXXlXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2d3HfdVXXXXahXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2AVbBdVXXXXXkXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2nf_wdVXXXXaMXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2dLYddVXXXXbtXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2H1_adVXXXXbWXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2eBzsdVXXXXbuXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2dOTndVXXXXcCXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2fK2tdVXXXXbkXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB29zjedVXXXXaFXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\"><img align=\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2i7rmdVXXXXcTXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\" /></p>",

      "item_imgs": [

        {

          "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2p30elFXXXXXQXpXXXXXXXXXX_!!2596264565.jpg"

        },

        {

          "url": "//img.alicdn.com/imgextra/i2/2596264565/TB2onxRlVXXXXcDXpXXXXXXXXXX_!!2596264565.jpg"

        },

        {

          "url": "//img.alicdn.com/imgextra/i1/2596264565/TB2a.x.lVXXXXXPXpXXXXXXXXXX_!!2596264565.jpg"

        },

        {

          "url": "//img.alicdn.com/imgextra/i2/2596264565/TB2iWE6bKZkyKJjSszbXXblwFXa_!!2596264565.jpg"

        },

        {

          "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2j2cTXib_F1JjSZFzXXc6KXXa_!!2596264565.jpg"

        }

      ],

      "item_weight": "0",

      "item_size": "",

      "location": "廣東深圳",

      "post_fee": "",

      "express_fee": "0.00",

      "ems_fee": "",

      "shipping_to": "廣東廣州白雲區",

      "has_discount": "false",

      "video": [],

      "is_virtual": "",

      "sample_id": "",

      "is_promotion": "false",

      "props_name": "1627207:1347647754:顏色分類:長方形帶開瓶器+送工具刀卡+鏈子;1627207:1347647753:顏色分類:橢圓形帶開瓶器+送工具刀卡+鏈子;1627207:1195392087:顏色分類:GJ018X鑰匙刀+送工具刀卡+鏈子;1627207:1331112595:顏色分類:超凡大師套餐【送工具卡+鏈子】;1627207:1331112594:顏色分類:最強王者套餐【送工具卡+鏈子】;1627207:1331264247:顏色分類:璀璨鑽石套餐【送工具卡+鏈子】",

      "prop_imgs": {

        "prop_img": [

          {

            "properties": "1627207:1347647754",

            "url": "//img.alicdn.com/imgextra/i3/2596264565/TB2.XeblVXXXXXkXpXXXXXXXXXX_!!2596264565.jpg"

          },

          {

            "properties": "1627207:1347647753",

            "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2dTrjdVXXXXXBXpXXXXXXXXXX_!!2596264565.jpg"

          },

          {

            "properties": "1627207:1195392087",

            "url": "//img.alicdn.com/imgextra/i2/2596264565/TB2j22kdVXXXXXdXpXXXXXXXXXX_!!2596264565.jpg"

          },

          {

            "properties": "1627207:1331112595",

            "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2_uiXnFXXXXXBXXXXXXXXXXXX_!!2596264565.jpg"

          },

          {

            "properties": "1627207:1331112594",

            "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2Gm9xnFXXXXbmXXXXXXXXXXXX_!!2596264565.jpg"

          },

          {

            "properties": "1627207:1331264247",

            "url": "//img.alicdn.com/imgextra/i3/2596264565/TB2wWohmXXXXXX8XXXXXXXXXXXX_!!2596264565.jpg"

          }

        ]

      },

      "property_alias": "1627207:1347647754:長方形帶開瓶器+送工具刀卡+鏈子;1627207:1347647753:橢圓形帶開瓶器+送工具刀卡+鏈子;1627207:1195392087:GJ018X鑰匙刀+送工具刀卡+鏈子;1627207:1331112595:超凡大師套餐【送工具卡+鏈子】;1627207:1331112594:最強王者套餐【送工具卡+鏈子】;1627207:1331264247:璀璨鑽石套餐【送工具卡+鏈子】",

      "props": [

        {

          "name": "品牌",

          "value": "三刃木"

        },

        {

          "name": "產地",

          "value": "中國"

        },

        {

          "name": "顏色分類",

          "value": "長方形帶開瓶器+送工具刀卡+鏈子,橢圓形帶開瓶器+送工具刀卡+鏈子,GJ018X鑰匙刀+送工具刀卡+鏈子,超凡大師套餐【送工具卡+鏈子】,最強王者套餐【送工具卡+鏈子】,璀璨鑽石套餐【送工具卡+鏈子】"

        },

        {

          "name": "吊牌價",

          "value": "46"

        },

        {

          "name": "功能數量",

          "value": "5個及以下"

        },

        {

          "name": "貨號",

          "value": "GJ019C"

        },

        {

          "name": "附加功能",

          "value": "開瓶器,刀,螺絲刀,鑰匙圈,其他"

        }

      ],

      "total_sold": "1",

      "skus": {

        "sku": [

          {

            "price": "39",

            "orginal_price": "39.00",

            "properties": "1627207:1347647754",

            "properties_name": "1627207:1347647754:顏色分類:長方形帶開瓶器+送工具刀卡+鏈子",

            "quantity": "104",

            "sku_id": "3166598625985"

          },

          {

            "price": "39",

            "orginal_price": "39.00",

            "properties": "1627207:1347647753",

            "properties_name": "1627207:1347647753:顏色分類:橢圓形帶開瓶器+送工具刀卡+鏈子",

            "quantity": "370",

            "sku_id": "3166598625984"

          },

          {

            "price": "25.8",

            "orginal_price": "25.80",

            "properties": "1627207:1195392087",

            "properties_name": "1627207:1195392087:顏色分類:GJ018X鑰匙刀+送工具刀卡+鏈子",

            "quantity": "34",

            "sku_id": "3144644292458"

          },

          {

            "price": "73.8",

            "orginal_price": "73.80",

            "properties": "1627207:1331112595",

            "properties_name": "1627207:1331112595:顏色分類:超凡大師套餐【送工具卡+鏈子】",

            "quantity": "157",

            "sku_id": "3161300228970"

          },

          {

            "price": "91.8",

            "orginal_price": "91.80",

            "properties": "1627207:1331112594",

            "properties_name": "1627207:1331112594:顏色分類:最強王者套餐【送工具卡+鏈子】",

            "quantity": "0",

            "sku_id": "3161300228969"

          },

          {

            "price": "63.8",

            "orginal_price": "63.80",

            "properties": "1627207:1331264247",

            "properties_name": "1627207:1331264247:顏色分類:璀璨鑽石套餐【送工具卡+鏈子】",

            "quantity": "167",

            "sku_id": "3161107666655"

          }

        ]

      },

      "seller_id": "2596264565",

      "sales": "1",

      "shop_id": "127203758",

      "props_list": {

        "1627207:1347647754": "顏色分類:長方形帶開瓶器+送工具刀卡+鏈子",

        "1627207:1347647753": "顏色分類:橢圓形帶開瓶器+送工具刀卡+鏈子",

        "1627207:1195392087": "顏色分類:GJ018X鑰匙刀+送工具刀卡+鏈子",

        "1627207:1331112595": "顏色分類:超凡大師套餐【送工具卡+鏈子】",

        "1627207:1331112594": "顏色分類:最強王者套餐【送工具卡+鏈子】",

        "1627207:1331264247": "顏色分類:璀璨鑽石套餐【送工具卡+鏈子】"

      },

      "seller_info": {

        "title": "歡樂購客棧",

        "shop_name": "歡樂購客棧",

        "sid": "127203758",

        "zhuy": "//shop127203758.taobao.com",

        "level": "12",

        "shop_type": "C",

        "user_num_id": "2596264565",

        "nick": "歡樂購客棧",

        "cid": null,

        "delivery_score": "4.8 ",

        "item_score": "4.8 ",

        "score_p": "4.8 "

      },

      "tmall": "false",

      "error": "",

      "warning": "",

      "url_log": [],

      "stuff_status": "",

      "shopinfo": {

        "shop_name": "歡樂購客棧",

        "shop_id": "127203758"

      },

      "data_from": "mtop",

      "method": "item_mtop:item_get",

      "promo_type": null,

      "props_img": {

        "1627207:1347647754": "//img.alicdn.com/imgextra/i3/2596264565/TB2.XeblVXXXXXkXpXXXXXXXXXX_!!2596264565.jpg",

        "1627207:1347647753": "//img.alicdn.com/imgextra/i4/2596264565/TB2dTrjdVXXXXXBXpXXXXXXXXXX_!!2596264565.jpg",

        "1627207:1195392087": "//img.alicdn.com/imgextra/i2/2596264565/TB2j22kdVXXXXXdXpXXXXXXXXXX_!!2596264565.jpg",

        "1627207:1331112595": "//img.alicdn.com/imgextra/i4/2596264565/TB2_uiXnFXXXXXBXXXXXXXXXXXX_!!2596264565.jpg",

        "1627207:1331112594": "//img.alicdn.com/imgextra/i4/2596264565/TB2Gm9xnFXXXXbmXXXXXXXXXXXX_!!2596264565.jpg",

        "1627207:1331264247": "//img.alicdn.com/imgextra/i3/2596264565/TB2wWohmXXXXXX8XXXXXXXXXXXX_!!2596264565.jpg"

      },


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70026036/viewspace-2935965/,如需轉載,請註明出處,否則將追究法律責任。

相關文章