GET和POST方式请求API接口数据返回

简介: GET和POST方式请求API接口数据返回

区别:



GET在浏览器回退时是无害的,而POST会再次提交请求。


GET产生的URL地址可以被Bookmark,而POST不可以。


GET请求会被浏览器主动cache,而POST不会,除非手动设置。


GET请求只能进行url编码,而POST支持多种编码方式。


GET请求参数会被完整保留在浏览器历史记录里,而POST中的参数不会被保留。


GET请求在URL中传送的参数是有长度限制的,而POST么有。


对参数的数据类型,GET只接受ASCII字符,而POST没有限制。


GET比POST更不安全,因为参数直接暴露在URL上,所以不能用来传递敏感信息。


GET参数通过URL传递,POST放在Request body中。


特别:



GET和POST还有一个重大区别,简单的说:


GET产生一个TCP数据包;POST产生两个TCP数据包。


长的说:


对于GET方式的请求,浏览器会把http header和data一并发送出去,服务器响应200(返回数据);


而对于POST,浏览器先发送header,服务器响应100 continue,浏览器再发送data,服务器响应200 ok(返回数据)。


但是:


1. GET与POST都有自己的语义,不能随便混用。


2. 据研究,在网络环境好的情况下,发一次包的时间和发两次包的时间差别基本可以无视。而在网络环境差的情况下,两次包的TCP在验证数据包完整性上,有非常大的优点。


3. 并不是所有浏览器都会在POST中发送两次包,Firefox就只发送一次。


返回的数据都是一样的,如下:

{
  "item": {
    "num_iid": "652874751412",
    "title": "北欧轻奢布艺沙发 小户型简约现代客厅ins风网红款三双人订制沙发",
    "desc_short": "",
    "price": "480.00",
    "total_price": 0,
    "suggestive_price": 0,
    "orginal_price": "3400.00",
    "nick": "惜情yqq1127",
    "num": 1550,
    "min_num": 0,
    "detail_url": "https://item.taobao.com/item.htm?id=652874751412",
    "pic_url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg",
    "brand": "#0 工厂",
    "brandId": null,
    "rootCatId": "50008164",
    "cid": "50020632",
    "crumbs": [],
    "created_time": "",
    "modified_time": "",
    "delist_time": "",
    "desc": "<div > \n   <div >\n    <img src=\"http://img.alicdn.com/imgextra/i3/2568161054/O1CN01LFmSOU1Jem9QOjMPb_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i3/2568161054/O1CN014vyOOT1Jem9DpHz3Y_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i1/2568161054/O1CN01B3PpsA1Jem9N8V7uf_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i2/2568161054/O1CN015JbyeY1Jem9MZshUt_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HXSoxx1Jem9RvgzHN_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i3/2568161054/O1CN01IEultA1Jem9MdEx8R_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i3/2568161054/O1CN0176K98O1Jem9QOjE69_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i4/2568161054/O1CN013Pxp1O1Jem9RvgeTv_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i1/2568161054/O1CN01SfyZ8M1Jem9QOi1Gx_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i4/2568161054/O1CN01bb1POa1Jem9Sdgve2_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i3/2568161054/O1CN018Eo9dV1Jem9KV0y79_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i1/2568161054/O1CN01vuEofr1Jem9Nzy9xY_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i4/2568161054/O1CN01qw9sAi1Jem8wkNKpy_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HeFhFw1Jem8rLnjBY_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i2/2568161054/O1CN01SNgjoi1Jem9QOil15_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i2/2568161054/O1CN01RXf3RA1Jem9DpHVwj_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i4/2568161054/O1CN01gZmZjt1Jem9ISThgm_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i2/2568161054/O1CN01YL0FHM1Jem9PQTjX9_!!2568161054.jpg\"  />\n    <img src=\"http://img.alicdn.com/imgextra/i4/2568161054/O1CN01UhsEhZ1Jem8yvJIhZ_!!2568161054.jpg\"  />\n   </div> \n  </div><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-4.6438c7992c849&p=1778786741&k=i_key&t=1681442715\" style=\"display:none\" />",
    "desc_img": [
      "http://img.alicdn.com/imgextra/i3/2568161054/O1CN01LFmSOU1Jem9QOjMPb_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i3/2568161054/O1CN014vyOOT1Jem9DpHz3Y_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01B3PpsA1Jem9N8V7uf_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i2/2568161054/O1CN015JbyeY1Jem9MZshUt_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HXSoxx1Jem9RvgzHN_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i3/2568161054/O1CN01IEultA1Jem9MdEx8R_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i3/2568161054/O1CN0176K98O1Jem9QOjE69_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i4/2568161054/O1CN013Pxp1O1Jem9RvgeTv_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01SfyZ8M1Jem9QOi1Gx_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01bb1POa1Jem9Sdgve2_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i3/2568161054/O1CN018Eo9dV1Jem9KV0y79_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01vuEofr1Jem9Nzy9xY_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01qw9sAi1Jem8wkNKpy_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i1/2568161054/O1CN01HeFhFw1Jem8rLnjBY_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i2/2568161054/O1CN01SNgjoi1Jem9QOil15_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i2/2568161054/O1CN01RXf3RA1Jem9DpHVwj_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01gZmZjt1Jem9ISThgm_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i2/2568161054/O1CN01YL0FHM1Jem9PQTjX9_!!2568161054.jpg",
      "http://img.alicdn.com/imgextra/i4/2568161054/O1CN01UhsEhZ1Jem8yvJIhZ_!!2568161054.jpg"
    ],
    "item_imgs": [
      {
        "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg"
      },
      {
        "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01kjOfNb1Jem9DmWn8Y_!!2568161054.jpg"
      },
      {
        "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN01HoB9ha1Jem9DmWn8r_!!2568161054.jpg"
      },
      {
        "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN011PjP2P1Jem9MXEUFT_!!2568161054.jpg"
      },
      {
        "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01KUfBFL1Jem9KTTMn1_!!2568161054.jpg"
      }
    ],
    "item_weight": "",
    "item_size": "",
    "location": "江苏南通",
    "post_fee": "",
    "express_fee": null,
    "ems_fee": "",
    "shipping_to": "",
    "has_discount": "true",
    "video": {
      "url": null
    },
    "is_virtual": "",
    "sample_id": "",
    "is_promotion": "true",
    "props_name": "31480:14306495906:几人坐:脚踏90*60*48cm;31480:14306495907:几人坐:双人165*95*67cm;31480:14306495908:几人坐:三人210*95*67cm;31480:14306495909:几人坐:单人100*95*67cm;31480:21480914361:几人坐:四人位240*95*67cm;31480:21480914362:几人坐:大四人320*95*76cm;31480:1387571900:几人坐:3米贵妃沙发;31480:32527954:几人坐:定制尺寸;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
    "prop_imgs": {
      "prop_img": [
        {
          "properties": "1627207:28321",
          "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
        }
      ]
    },
    "property_alias": "",
    "props": [
      {
        "name": "品牌",
        "value": "#0 工厂"
      },
      {
        "name": "型号",
        "value": "520"
      },
      {
        "name": "材质",
        "value": "木"
      },
      {
        "name": "木质材质",
        "value": "松木"
      },
      {
        "name": "面料",
        "value": "绒布"
      },
      {
        "name": "风格",
        "value": "北欧"
      },
      {
        "name": "几人坐",
        "value": "脚踏90*60*48cm,双人165*95*67cm,三人210*95*67cm,单人100*95*67cm,四人位240*95*67cm,大四人320*95*76cm,3米贵妃沙发,定制尺寸"
      },
      {
        "name": "颜色分类",
        "value": "乳白色"
      },
      {
        "name": "填充物",
        "value": "海绵"
      },
      {
        "name": "结构工艺",
        "value": "木质工艺"
      },
      {
        "name": "是否可定制",
        "value": "是"
      },
      {
        "name": "沙发组合形式",
        "value": "U形"
      },
      {
        "name": "是否可拆洗",
        "value": "是"
      },
      {
        "name": "适用对象",
        "value": "成年人"
      },
      {
        "name": "是否带储物空间",
        "value": "否"
      },
      {
        "name": "产地",
        "value": "上海"
      },
      {
        "name": "地市",
        "value": "上海市"
      },
      {
        "name": "区县",
        "value": "奉贤区"
      },
      {
        "name": "是否组装",
        "value": "否"
      },
      {
        "name": "出租车是否可运输",
        "value": "否"
      },
      {
        "name": "填充物硬度",
        "value": "软"
      },
      {
        "name": "款式定位",
        "value": "经济型"
      }
    ],
    "total_sold": null,
    "skus": {
      "sku": [
        {
          "price": "480",
          "total_price": 0,
          "orginal_price": "480",
          "properties": "31480:14306495906;1627207:28321",
          "properties_name": "31480:14306495906:几人坐:脚踏90*60*48cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "4881047531343"
        },
        {
          "price": "1688",
          "total_price": 0,
          "orginal_price": "1688",
          "properties": "31480:14306495907;1627207:28321",
          "properties_name": "31480:14306495907:几人坐:双人165*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "150",
          "sku_id": "4881047531344"
        },
        {
          "price": "2088",
          "total_price": 0,
          "orginal_price": "2088",
          "properties": "31480:14306495908;1627207:28321",
          "properties_name": "31480:14306495908:几人坐:三人210*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "4881047531345"
        },
        {
          "price": "968",
          "total_price": 0,
          "orginal_price": "968",
          "properties": "31480:14306495909;1627207:28321",
          "properties_name": "31480:14306495909:几人坐:单人100*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "4881047531346"
        },
        {
          "price": "2388",
          "total_price": 0,
          "orginal_price": "2388",
          "properties": "31480:21480914361;1627207:28321",
          "properties_name": "31480:21480914361:几人坐:四人位240*95*67cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "5039985183001"
        },
        {
          "price": "3188",
          "total_price": 0,
          "orginal_price": "3188",
          "properties": "31480:21480914362;1627207:28321",
          "properties_name": "31480:21480914362:几人坐:大四人320*95*76cm;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "5039985183002"
        },
        {
          "price": "3400",
          "total_price": 0,
          "orginal_price": "3400",
          "properties": "31480:1387571900;1627207:28321",
          "properties_name": "31480:1387571900:几人坐:3米贵妃沙发;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "5039984824000"
        },
        {
          "price": "3000",
          "total_price": 0,
          "orginal_price": "3000",
          "properties": "31480:32527954;1627207:28321",
          "properties_name": "31480:32527954:几人坐:定制尺寸;1627207:28321:颜色分类:乳白色 尺寸颜色可定制",
          "quantity": "200",
          "sku_id": "5039985183003"
        }
      ]
    },
    "seller_id": "2568161054",
    "sales": 35,
    "shop_id": "567158267",
    "props_list": {
      "31480:14306495906": "几人坐:脚踏90*60*48cm",
      "31480:14306495907": "几人坐:双人165*95*67cm",
      "31480:14306495908": "几人坐:三人210*95*67cm",
      "31480:14306495909": "几人坐:单人100*95*67cm",
      "31480:21480914361": "几人坐:四人位240*95*67cm",
      "31480:21480914362": "几人坐:大四人320*95*76cm",
      "31480:1387571900": "几人坐:3米贵妃沙发",
      "31480:32527954": "几人坐:定制尺寸",
      "1627207:28321": "颜色分类:乳白色 尺寸颜色可定制"
    },
    "seller_info": {
      "nick": "惜情yqq1127",
      "item_score": "4.9 ",
      "score_p": "4.9 ",
      "delivery_score": "4.9 ",
      "shop_type": "C",
      "user_num_id": "2568161054",
      "sid": "567158267",
      "title": "现代布艺沙发",
      "zhuy": "https://shop567158267.taobao.com/",
      "shop_name": "现代布艺沙发"
    },
    "tmall": false,
    "error": "",
    "warning": "",
    "url_log": [],
    "fav_count": "7436",
    "fans_count": "644",
    "freight": "平邮: 快递包邮",
    "props_imgs": {
      "prop_img": [
        {
          "properties": "1627207:28321",
          "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
        }
      ]
    },
    "_ddf": "fu",
    "promo_type": null,
    "props_img": {
      "1627207:28321": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
    },
    "format_check": "ok",
    "shop_item": [],
    "relate_items": []
  },
  "error": "",
  "secache": "4ad7ad2480af253fec9c2fd4daa266bb",
  "secache_time": 1681442715,
  "secache_date": "2023-04-14 11:25:15",
  "translate_status": "",
  "translate_time": 0,
  "language": {
    "default_lang": "cn",
    "current_lang": "cn"
  },
  "reason": "",
  "error_code": "0000",
  "cache": 0,
  "api_info": "today:30 max:10100 all[69=30+21+18];expires:2030-12-31",
  "execution_time": "1.872",
  "server_time": "Beijing/2023-04-14 11:25:15",
  "client_ip": "106.6.33.181",
  "call_args": {
    "num_iid": "652874751412",
    "is_promotion": "1"
  },
  "api_type": "taobao",
  "translate_language": "zh-CN",
  "translate_engine": "baidu",
  "server_memory": "0.94MB",
  "request_id": "gw-4.6438c7992c849",
  "last_id": "1677743647"
}

效果展示


49ec05b86597677c8aca5c7f93f4749.png

相关文章
|
12天前
|
人工智能 自然语言处理 API
Multimodal Live API:谷歌推出新的 AI 接口,支持多模态交互和低延迟实时互动
谷歌推出的Multimodal Live API是一个支持多模态交互、低延迟实时互动的AI接口,能够处理文本、音频和视频输入,提供自然流畅的对话体验,适用于多种应用场景。
60 3
Multimodal Live API:谷歌推出新的 AI 接口,支持多模态交互和低延迟实时互动
|
1天前
|
数据采集 数据可视化 前端开发
怎么通过API获取电竞赛事实时数据
选择合适的电竞数据API是开发电竞应用的关键。主流API包括OP.GG、Liquipedia、Stratz、Riot Games和熊猫比分,涵盖LOL、DOTA2等游戏的实时数据。注册并获取API密钥后,需仔细阅读文档,了解资源、请求方法、必需参数及响应格式。编写代码调用API时,注意优化请求频率,避免封禁。最后,通过Web界面或可视化工具展示数据,如React/D3.js、Tableau等。示例代码展示了如何使用熊猫比分API获取即将开始的比赛信息。
|
7天前
|
前端开发 API 数据库
Next 编写接口api
Next 编写接口api
|
8天前
|
数据采集 监控 数据挖掘
常用电商商品数据API接口(item get)概述,数据分析以及上货
电商商品数据API接口(item get)是电商平台上用于提供商品详细信息的接口。这些接口允许开发者或系统以编程方式获取商品的详细信息,包括但不限于商品的标题、价格、库存、图片、销量、规格参数、用户评价等。这些信息对于电商业务来说至关重要,是商品数据分析、价格监控、上货策略制定等工作的基础。
|
13天前
|
XML JSON 缓存
阿里巴巴商品详情数据接口(alibaba.item_get) 丨阿里巴巴 API 实时接口指南
阿里巴巴商品详情数据接口(alibaba.item_get)允许商家通过API获取商品的详细信息,包括标题、描述、价格、销量、评价等。主要参数为商品ID(num_iid),支持多种返回数据格式,如json、xml等,便于开发者根据需求选择。使用前需注册并获得App Key与App Secret,注意遵守使用规范。
|
12天前
|
JSON API 开发者
淘宝买家秀数据接口(taobao.item_review_show)丨淘宝 API 实时接口指南
淘宝买家秀数据接口(taobao.item_review_show)可获取买家上传的图片、视频、评论等“买家秀”内容,为潜在买家提供真实参考,帮助商家优化产品和营销策略。使用前需注册开发者账号,构建请求URL并发送GET请求,解析响应数据。调用时需遵守平台规定,保护用户隐私,确保内容真实性。
|
12天前
|
搜索推荐 数据挖掘 API
淘宝天猫商品评论数据接口丨淘宝 API 实时接口指南
淘宝天猫商品评论数据接口(Taobao.item_review)提供全面的评论信息,包括文字、图片、视频评论、评分、追评等,支持实时更新和高效筛选。用户可基于此接口进行数据分析,支持情感分析、用户画像构建等,同时确保数据使用的合规性和安全性。使用步骤包括注册开发者账号、创建应用获取 API 密钥、发送 API 请求并解析返回数据。适用于电商商家、市场分析人员和消费者。
|
25天前
|
API 网络安全
发送UDP数据免费API接口教程
此API用于向指定主机发送UDP数据,支持POST或GET请求。需提供用户ID、密钥、接收IP及端口、数据内容等参数。返回状态码和信息提示。示例中含公共ID与KEY,建议使用个人凭证以提高调用频率。
44 13
|
22天前
|
JSON API 开发工具
淘宝实时 API 接口丨淘宝商品详情接口(Taobao.item_get)
淘宝商品详情接口(Taobao.item_get)允许开发者获取商品的详细信息,包括基本信息、描述、卖家资料、图片、属性及销售情况等。开发者需注册账号、创建应用并获取API密钥,通过构建请求获取JSON格式数据,注意遵守平台规则,合理使用接口,确保数据准确性和时效性。
|
22天前
|
JSON API 数据格式
获取商品详情API的请求格式是什么
获取商品详情API的请求格式通常依赖于特定的电商平台或服务提供商,但一般遵循类似的结构。以下是一个概括性的说明,以及针对几个主流电商平台的示例: