1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 淘宝商品历史价格接口/商品历史价走势接口对接代码分享

淘宝商品历史价格接口/商品历史价走势接口对接代码分享

时间:2024-01-18 02:19:10

相关推荐

淘宝商品历史价格接口/商品历史价走势接口对接代码分享

一、淘宝商品历史价格接口/商品历史价走势接口对接参数如下:

点击获取key和secret

1.请求参数

请求参数:num_iid=584458528092

参数说明:num_iid:商品id

2.响应参数:

名称类型必须示例值描述num_iidBigint0584458528092宝贝IDtitleString0女装 SUPIMA COTTON圆领T恤(短袖) 413674 优衣库UNIQLO商品标题detail_urlString0/item.htm?id=584458528092宝贝链接pic_urlString0宝贝图片lower_priceFloat039.00最低价lower_dateString0-12-22最低价日期current_priceFloat039.00当前价change_price_remarkString0itemMix0{"date": "-06-25", "price": "39.00", "discount": "",}价格信息

3.请求示例(CURL、PHP 、PHPsdk 、Java 、C# 、Python):

import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.Reader;import .URL;import java.nio.charset.Charset;import org.json.JSONException;import org.json.JSONObject;import java.io.PrintWriter;import .URLConnection;public class Example {private static String readAll(Reader rd) throws IOException {StringBuilder sb = new StringBuilder();int cp;while ((cp = rd.read()) != -1) {sb.append((char) cp);}return sb.toString();}public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {URL realUrl = new URL(url);URLConnection conn = realUrl.openConnection();conn.setDoOutput(true);conn.setDoInput(true);PrintWriter out = new PrintWriter(conn.getOutputStream());out.print(body);out.flush();InputStream instream = conn.getInputStream();try {BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));String jsonText = readAll(rd);JSONObject json = new JSONObject(jsonText);return json;} finally {instream.close();}}public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {URL realUrl = new URL(url);URLConnection conn = realUrl.openConnection();InputStream instream = conn.getInputStream();try {BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));String jsonText = readAll(rd);JSONObject json = new JSONObject(jsonText);return json;} finally {instream.close();}}public static void main(String[] args) throws IOException, JSONException {// 请求示例 url 默认请求参数已经URL编码处理String url = "https://获取key/taobao/item_history_price/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=584458528092";JSONObject json = getRequestFromUrl(url);System.out.println(json.toString());}}

4.响应示例:

{code: 200,msg: "请求成功【success】",total_results: "7",data: {item_id: "570759102711",max_price: "128.00",min_price: "34.90",last_date: "-05-20",total: "7",price_list: {-06-30: "39.90",-04-16: "128.00",-04-30: "39.90",-05-04: "128.00",-05-13: "34.90",-05-17: "39.90",-05-19: "34.90"}}}

该接口可以获取淘宝天猫商品实时月销量和交易成功销量。可用于做一般销量监控、短视频带货销量监控,代购业务,商城建设需要数据业务,数据分析等业务,希望以上接口代码对接能够帮助到有需要的朋友。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。