首页 > 大数据 > 数据挖掘 > 阿里巴巴国际站交易历史 API 返回值说明
阿里巴巴国际站交易历史API的返回值通常包含丰富的交易数据,以下是对其返回值的详细说明,并附有示例代码。
公共参数
key:调用key,必须以GET方式拼接在URL中。secret:调用密钥。api_name:API接口名称,包括在请求地址中,如
transaction_history。cache:是否使用缓存数据,可选值为
yes或
no,默认为
yes。result_type:返回数据格式,可选值为
json、
jsonu、
xml、
serialize、
var_export,默认为
json。
jsonu输出的内容中文可以直接阅读。lang:翻译语言,可选值为
cn(简体中文)、
en(英文)、
ru(俄文),默认为
cn。version:API版本。请求参数
company_url:公司域名,用于指定要查询交易历史的阿里巴巴国际站公司。响应参数
amt:交易金额。buyerCountry:买家国籍的缩写。countryFullName:买家国籍的全称。currency:交易使用的货币。logisticsType:物流类型。tradeDate:交易日期的时间戳。以下是一个使用Python语言调用阿里巴巴国际站交易历史API并解析返回值的示例代码:
python复制代码
|
|
import requests |
|
|
import json |
|
|
|
|
|
# 定义API请求地址和参数 |
|
|
url = "https://api-gw.onebound.cn/alibaba/transaction_history/" |
|
|
params = { |
|
|
'key': '<您自己的apiKey>', |
|
|
'secret': '<您自己的apiSecret>', |
|
|
'company_url': 'sheenstar.en.alibaba.com' # 替换为您要查询的公司域名 |
|
|
} |
|
|
|
|
|
# 发送HTTP GET请求 |
|
|
response = requests.get(url, params=params) |
|
|
|
|
|
# 检查请求是否成功 |
|
|
if response.status_code == 200: |
|
|
# 解析JSON格式的响应内容 |
|
|
response_data = json.loads(response.text) |
|
|
|
|
|
# 打印交易历史数据 |
|
|
for transaction in response_data.get('transactions', []): # 假设返回的数据中包含'transactions'字段 |
|
|
print(f"交易金额: {transaction['amt']}") |
|
|
print(f"买家国籍缩写: {transaction['buyerCountry']}") |
|
|
print(f"买家国籍全称: {transaction['countryFullName']}") |
|
|
print(f"交易货币: {transaction['currency']}") |
|
|
print(f"物流类型: {transaction['logisticsType']}") |
|
|
print(f"交易日期: {transaction['tradeDate']}") |
|
|
print("-" * 40) |
|
|
else: |
|
|
print(f"请求失败,状态码: {response.status_code},错误信息: {response.text}") |
注意:
<您自己的apiKey>和
<您自己的apiSecret>需要替换为您实际的API调用密钥。company_url参数需要替换为您要查询的阿里巴巴国际站公司的域名。response_data.get('transactions', [])是基于假设返回的数据中包含
transactions字段来解析的,实际使用时需要根据API文档和返回值结构进行适当调整。通过以上说明和示例代码,您可以了解阿里巴巴国际站交易历史API的返回值结构和如何使用Python语言进行调用和解析。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70042344/viewspace-3056881/ ,如需转载,请注明出处,否则将追究法律责任。