作为互联网企业,调用淘宝APP中的数据是非常常见的。那么如何调用呢?
公共参数
请求地址:申请调用地址
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
key | String | 是 | 调用key(点*击*注*册*免*费*调*用) |
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=520813250866
参数说明:num_iid:淘宝商品ID
响应参数
Version: Date:
名称 | 类型 | 必须 | 示例值 | 描述 |
---|---|---|---|---|
item |
Mix | 0 | 获得淘宝app商品详情原数据 |
调用示例
Curl PHP PHPsdk JAVA C# Python Golang javascript JS-SDK Ruby Swift Objective-C C C++ Node.JS Kotlin Rust R MATLAB
Curl
-- 请求示例 url 默认请求参数已经URL编码处理 curl -i "https://api-gw.onebound.cn/taobao/item_get_app/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=520813250866"
PHP
&secret=<您自己的apiSecret>&num_iid=520813250866";
$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));
?>
api_url = "http://api-gw.onebound.cn/";
$obapi->api_urls = array("http://api-gw.onebound.cn/","http://api-1.onebound.cn/");//备用API服务器
$obapi->api_urls_on = true;//当网络错误时,是否启用备用API服务器
$obapi->api_key = "<您自己的apiKey>";
$obapi->api_secret = "<您自己的apiSecret>";
$obapi->api_version ="";
$obapi->secache_path ="runtime/";
$obapi->secache_time ="86400";
$obapi->cache = true;
$api_data = $obapi->exec(
array(
"api_type" =>"taobao",
"api_name" =>"item_get_app",
"api_params"=>array (
'num_iid' => '520813250866',
)
)
);
var_dump($api_data);
?>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.PrintWriter;
import java.net.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://api-gw.onebound.cn/taobao/item_get_app/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=520813250866";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
响应示例
{
"item": {
"apiStack": [
{
"name": "esi",
"value": {
"consumerProtection": {
"items": [
{
"title": "付款后48小时内发货"
},
{
"desc": "8天退货,退货邮费买家承担",
"title": "8天退货"
},
{
"desc": "商品在运输途中出现破损的,消费者可向卖家提出补寄申请,可补寄1次,补寄邮费由买家承担",
"title": "1次破损补寄"
},
{
"desc": "购买该商品,每笔成交都会有相应金额捐赠给公益。感谢您的支持,愿公益的快乐伴随您每一天。",
"title": "公益宝贝"
},
{
"title": "集分宝"
},
{
"title": "支付宝支付"
}
],
"passValue": "all"
},
"debug": {
"app": "alidetail",
"host": "[email protected]"
},
"delivery": {
"addressWeexUrl": "https://market.m.taobao.com/apps/market/detailrax/address-picker.html?spm=a2116h.app.0.0.16d957e9nDYOzv&wh_weex=true",
"areaId": "330102",
"completedTo": "杭州 上城 小营",
"extras": [],
"from": "广东深圳",
"overseaContraBandFlag": "false",
"postage": "快递: 快递包邮",
"to": "杭州上城"
},
"diversion": {
"detailTopSearch": {
"url": "https://s.m.taobao.com/h5entry?g_channelSrp=detail&placeholder=合法刀 随身&showText=合法刀 随身&g_historyOn=true&g_csearchdoor_spm=a2141.13130650&itemId=520813250866&detailShopId=127203758"
},
"productRecommend": {
"preloadUrl": "https://gw.alicdn.com/tfs/TB1PS8nBAPoK1RjSZKbXXX1IXXa-1125-1335.png?getAvatar=avatar",
"request": {
"api": "mtop.relationrecommend.WirelessRecommend.recommend",
"params": {
"appId": "10777",
"from": "dinamicX",
"params": "{\"itemid\":520813250866,\"spm\":\"0.0.0.0.hUro0P\",\"sellerid\":2596264565,\"appId\":\"10777\"}"
},
"version": "2.0"
},
"template": {
"android": "https://ossgw.alicdn.com/rapid-oss-bucket/template_online/tb_shop_recommend/64005743/tb_shop_recommend_android.xml",
"ios": "https://ossgw.alicdn.com/rapid-oss-bucket/template_online/tb_shop_recommend/64005743/tb_shop_recommend_ios.plist",
"name": "tb_shop_recommend",
"version": "37"
}
}
},
"extendedData": [],
"feature": {
"UTABForceNewSku": "true",
"bigImageSkuProp": "true",
"cainiaoNoramal": "true",
"dailyPrice": "true",
"enableDpbModule": "false",
"freshmanRedPacket": "true",
"guessYouLike": "true",
"hasCoupon": "true",
"hasNewCombo": "false",
"hasSku": "true",
"newAddress": "true",
"newIndicator": "true",
"newPrice": "true",
"newTaobaoActivity": "true",
"noShareGroup": "true",
"openAddOnTools": "false",
"openGradient": "true",
"openNewSku": "true",
"promotion2018": "true",
"promotion2019": "true",
"showSku": "true",
"showSkuThumbnail": "true",
"superActTime": "false",
"taobao2018": "true"
},
"gallery": [],
"hybrid": {
"shopRecommendItems": {
"height": "445",
"spm": "",
"url": "https://market.m.taobao.com/apps/market/detailrax/recommend-shop-bigpage.html?spm=a2116h.app.0.0.16d957e9B7oLGw&wh_weex=true&sellerId=2596264565&itemId=520813250866&detail_v=3.1.1&selfRmdFlag=true"
}
},
"item": {
"couponUrl": "//h5.m.taobao.com/present/hongbao.html?sellerId=2596264565",
"picGallaryOverScroll": {
"mainPic": {
"action": [
{
"fields": {
"url": "https://market.m.taobao.com/app/detail-project/pages/pages/banner-recommend?wx_navbar_hidden=true&_wx_statusbar_hidden=true&wh_weex=true&sellerId=2596264565&shopId=127203758&itemId=520813250866&spm=a2141.7631564&detailAlgoParam=&list_param=&abtest=76992_63166&detailUniqueId=02288d69701058eca52532215b7fed17"
},
"type": "open_url"
},
{
"fields": {
"trackName": "Page_Detail_Button-ItemDetailRecommend",
"trackParams": {
"spm": "a2141.7631564"