手把手教你调用电商API获取淘宝订单数据(内附详细源码)

接口名称:seller_order_list-获取卖出的商品订单列表

taobao.seller_order_list

公共参数

请求地址:https://api-sever.cn/taobao/seller_order_list

名称 类型 必须 描述
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版本

请求参数

请求参数:page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size=

参数说明:page:页码
&tabCode:[waitBuyerPay,waitSend,haveSendGoods,refunding,waitRate,success,closed,before3Months]
dateBegin:开始时间,dateEnd:结束时间(格式:yyyy-mm-dd hh:ii:ss)
buyerNick:买家昵称,如不填写则为当前登录用户
itemTitle:宝贝标题
orderId:订单编号
lastStartRow:查三个月前订单用到的参数
detail:此参数高级用户才支持
token:SaaS授权

授权token获取方式:

token有三种方式可以拿到:
方案一:组合接口
 buyer_token_qrcode- 获取[扫码登录方式]二维码图片 直接点击接口拿到token然后调用下面接口:
 buyer_token_qrcode_ck - 获取token[扫码登录方式] 

方案二:通过输入淘宝账号密码拿token
 buyer_token_create - 获取token 

方案三:小饼干插件模式【同时支持pc和手机端】

手把手教你调用电商API获取淘宝订单数据(内附详细源码)_第1张图片

响应参数

Version: Date:

名称 类型 必须 示例值 描述

order_id

Bigint 0 368830339413001234 订单号

deal_time

Date 0 2019-03-06 18:14:25 处理时间

buyer_nick

String 0 abc123 买家昵称

buyer_name

String 0 买家姓名

seller_id

Bigint 0 557039353 卖家id

goods

Mix 0 [{"goods_name": "爆款PP棉公仔粉红色猪表情毛绒玩具软体羽绒棉可爱猪抱枕弹力女生", "goods_id": "368830339413841880", "goods_image": "//img.alicdn.com/imgextra/i4/557039353/O1CN010aX1Is2Ixi⼀b0_!!557039353.jpg_sum.jpg", "unit_price": "28.00", "goods_count": "2", "goods_info": "颜色分类:大眼呆蒙;高度:40cm(0.4公斤)", "goods_code": "qb"}] 商品信息列表

total_price

Float 0 56.00 总价

freight

Float 0 运费

trading_status

String 0 交易成功 交易状态

countdown

String 0 剩余时间

调用示例

&secret=<您自己的apiSecret>&page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size=";
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
var_dump(curl_exec($curl));
?>

 

# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://api-服务器.cn/taobao/seller_order_list/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size="
headers = {
    "Accept-Encoding": "gzip",
    "Connection": "close"
}
if __name__ == "__main__":
    r = requests.get(url, headers=headers)
    json_obj = r.json()
    print(json_obj)
//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-服务器.cn/taobao/seller_order_list/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size=";
	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;
}

你可能感兴趣的:(淘宝API接口,数据库,windows,服务器,网络爬虫,数据挖掘,python)