伴随着社交网络、大数据、云计算和搜索引擎等互联网应用技术的快速发展,各类应用软件的规模在日益庞大,我们需要把复杂系统划分成小的组成部分,因此编程接口的设计就显得十分重要。程序设计的实践中,编程接口的设计首先要使系统的职责得到合理划分,良好的接口设计可以降低系统各部分的相互依赖,提高组成单元的内聚性,降低组成单元间的耦合程度,从而提高系统的维护性和扩展性。
公共参数
请求地址: https://api-gw.onebound.cn/taobao/item_history_price
| 名称 | 类型 | 必须 | 描述 |
|---|---|---|---|
| key | String | 是 | 调用key(必须以GET方式拼接在URL中) |
| secret | String | 是 | 调用密钥 |
| api_name | String | 是 | API接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等] |
| cache | String | 否 | [yes,no]默认yes,将调用缓存的数据,速度比较快 |
| result_type | String | 否 | [json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读 |
| lang | String | 否 | [cn,en,ru]翻译语言,默认cn简体中文 |
| version | String | 否 | API版本 |
响应参数
请求参数:num_iid=584458528092
参数说明:num_iid:商品id
Version: Date:
| 名称 | 类型 | 必须 | 示例值 | 描述 |
|---|---|---|---|---|
| num_iid | Bigint | 0 | 584458528092 | 宝贝ID |
| title | String | 0 | 女装 SUPIMA COTTON圆领T恤(短袖) 413674 优衣库UNIQLO | 商品标题 |
| detail_url | String | 0 | https://item.taobao.com/item.htm?id=584458528092 | 宝贝链接 |
| pic_url | String | 0 | 宝贝图片 | |
| lower_price | Float | 0 | 39.00 | 最低价 |
| lower_date | String | 0 | 2020-12-22 | 最低价日期 |
| current_price | Float | 0 | 39.00 | 当前价 |
| change_price_remark | String | 0 | ||
| item | Mix | 0 | {"date": "2020-06-25", "price": "39.00", "discount": "",} | 价格信息 |
请求示例
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;
private const String method = "GET";
static void Main(string[] args)
{String bodys = "";// 请求示例 url 默认请求参数已经做URL编码String url = "https://api-gw.onebound.cn/taobao/item_history_price/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=584458528092";HttpWebRequest httpRequest = null;HttpWebResponse httpResponse = null; if (url.Contains("https://")){ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));}else{httpRequest = (HttpWebRequest)WebRequest.Create(url);}httpRequest.Method = method;if (0 < bodys.Length){byte[] data = Encoding.UTF8.GetBytes(bodys);using (Stream stream = httpRequest.GetRequestStream()){stream.Write(data, 0, data.Length);}}try{httpResponse = (HttpWebResponse)httpRequest.GetResponse();}catch (WebException ex){httpResponse = (HttpWebResponse)ex.Response;}Console.WriteLine(httpResponse.StatusCode);Console.WriteLine(httpResponse.Method);Console.WriteLine(httpResponse.Headers);Stream st = httpResponse.GetResponseStream();StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));Console.WriteLine(reader.ReadToEnd());Console.WriteLine("\n");
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{return true;
}