JD最常用的API接口(获得JD商品详情 按关键字搜索商品 按图搜索京东商品(拍立淘)i 获得店铺的所有商品 获取商品历史价格信息获取推荐商品列表 获取购买到的商品订单列表)

京东作为电商平台,近几年用户、业务持续增长,访问量持续上升,随着这些业务的发展,围绕京东平台的API业务应运而生。

京东平台API,就是为了解放客户端与服务端而存在的。对于客户端,使开放给客户端的接口标准统一,以降低客户端的接入成本;对于服务端,使服务端无需关注接口暴露在公网面临的问题而着眼于业务的实现,来提升开发效率。

那么京东平台都有哪些好用的API接口呢?

京东获得JD商品详情 API 返回值说明

item_get-获得JD商品详情 

onebound.jd.item_get

公共参数

名称类型必须描述
keyString调用key(点*击*注*册*免*调*用)
secretString调用密钥
api_nameStringAPI接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等]
cacheString[yes,no]默认yes,将调用缓存的数据,速度比较快
result_typeString[json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读
langString[cn,en,ru]翻译语言,默认cn简体中文
versionStringAPI版本

请求参数

请求参数:num_iid=10335871600

参数说明:num_iid:JD商品ID

响应参数

名称类型是否隐私示例值描述
itemsitems[]获得JD商品详情
num_iidBigint29186819959商品ID
titleStringMOCO2018夏季新品时尚V领条纹连衣裙 摩安珂 蓝白条色 S商品标题
desc_shortString商品简介
priceFloat719.0价格
total_priceFloat0
suggestive_priceFloat0
orginal_priceFloat1199.00原价
nickStringMO&Co.官方旗舰店掌柜昵称
numInt999
min_numInt0
detail_urlStringhttp://item.jd.com/29186819959.html商品链接
pic_urlString//img14.360buyimg.com/n0/jfs/t22033/147/1051007175/85125/c44dd0df/5b1f2855Ncbe35858.jpg商品图片
brandString品牌名称
brandIdInt品牌ID
rootCatIdInt1343顶级分类ID
cidInt9719
crumbsMix[]
created_timeString
modified_timeString
delist_timeString
descString
desc_imgMix[]
item_imgsMix[{ "url": "//img14.360buyimg.com/n0/jfs/t22033/147/1051007175/85125/c44dd0df/5b1f2855Ncbe35858.jpg"}]商品图片
item_weightString
item_sizeString
locationString发货地
post_feeFloat6.00物流费用
express_feeFloat6.00快递费用
ems_feeFloat6.00EMS费用
shipping_toString发货至
has_discountBooleanfalse
videoMix[]商品视频
is_virtualString
sample_idString商品风格标识ID
is_promotionBoolean
props_nameString0:0:尺码:S;0:1:尺码:XS;0:2:尺码:M;0:3:尺码:L;0:4:尺码:XL商品属性名
prop_imgsMix{"prop_img": []}商品属性图片列表
property_aliasString0:0:S;0:1:XS;0:2:M;0:3:L;0:4:XL商品属性别名
propsMix[{ "name": "尺码","value": "S XS M L XL" }]商品详情
total_soldInt
skusMix{"sku": [{"price": "719.00", "orginal_price": "1199.00", "properties": "0:0", "properties_name": "0:0:尺码:S", "quantity": 99, "sku_id": 29186819959, "sku_url": "http://item.jd.com/29186819959.html"}]商品规格信息
seller_idInt卖家ID
salesInt销量
shop_idInt店铺ID
props_listMix{"0:0": "尺码:S"}商品属性
seller_infoMix{"level": null, "shop_type": null, "user_num_id": 57467, "cid": null, "delivery_score": null, "item_score": null, "score_p": null, "zhuy": "//moco.jd.com", "search_id": "", "nick": "MO&Co.官方旗舰店", "shop_name": "MO&Co.官方旗舰店", "title": "MO&Co.官方旗舰店" }卖家信息
tmallBooleanfalse是否天猫
errorString错误信息
warningString警告信息
url_logMix[]
props_imgMix[]属性图片
shop_itemMix[]
relate_itemsMix[]

请求示例

-- 请求示例 url 默认请求参数已经URL编码处理
curl -i "https://api-gw.onebound.cn/taobao/brand_cat_top/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&"
<?php

// 请求示例 url 默认请求参数已经URL编码处理
// 本示例代码未加密secret参数明文传输,若要加密请参考:https://open.onebound.cn/help/demo/sdk/demo-sign.php
$method = "GET";
$url = "https://api-gw.onebound.cn/taobao/brand_cat_top/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&";
$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));
?>
<?php
//定义缓存目录和引入文件
define("DIR_RUNTIME","runtime/");
define("DIR_ERROR","runtime/");
define("SECACHE_SIZE","0");
//SDK下载地址 https://open.onebound.cn/help/demo/sdk/onebound-api-sdk.zip
include ("ObApiClient.php");

$obapi = new otao\ObApiClient();
$obapi->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" =>"brand_cat_top",
	                "api_params"=>array (
)
                )
            );
 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/brand_cat_top/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值