京东商品详情数据获取item_get-获得JD商品详情,Java请求示例API接口

要获取京东商品详情数据,您通常需要使用京东开放平台的API。这里提供一个基本的Java请求示例,展示如何调用item_get接口(或类似的接口,因为API可能会更新)来获取JD商品详情。

首先,确保您已经在京东开放平台注册了开发者账号,并获取了必要的API密钥(如App Key和App Secret)。

以下是一个简单的Java代码示例,演示如何发送HTTP请求以获取商品详情:

请求示例,API接口接入Anzexi58

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/jd/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=10335871600";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

onebound.jd.item_get

公共参数

名称类型必须描述
keyString调用key(必须以GET方式拼接在URL中)
secretString调用密钥WeChat18305163218
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

响应参数

Version: Date:

名称类型必须示例值描述

items

items[]0获得JD商品详情

num_iid

Bigint029186819959商品ID

title

String0MOCO2018夏季新品时尚V领条纹连衣裙 摩安珂 蓝白条色 S商品标题

desc_short

String0商品简介

price

Float0719.0价格

total_price

Float00

suggestive_price

Float00

orginal_price

Float01199.00原价

nick

String0MO&Co.官方旗舰店掌柜昵称

num

Int0999库存

min_num

Int00

detail_url

String0http://item.jd.com/29186819959.html商品链接

pic_url

String0//img14.360buyimg.com/n0/jfs/t22033/147/1051007175/85125/c44dd0df/5b1f2855Ncbe35858.jpg商品图片

brand

String0品牌名称

brandId

Int0品牌ID

rootCatId

Int01343顶级分类ID

cid

Int09719分类ID

crumbs

Mix0[]

created_time

String0

modified_time

String0

delist_time

String0

desc

String0

desc_img

Mix0[]

item_imgs

Mix0[{ "url": "//img14.360buyimg.com/n0/jfs/t22033/147/1051007175/85125/c44dd0df/5b1f2855Ncbe35858.jpg"}]商品图片

item_weight

String0

item_size

String0

location

String0发货地

post_fee

Float06.00物流费用

express_fee

Float06.00快递费用

ems_fee

Float06.00EMS费用

shipping_to

String0发货至

has_discount

Boolean0false

video

Mix0[]商品视频

is_virtual

String0

sample_id

String0商品风格标识ID

is_promotion

Boolean0

props_name

String00:0:尺码:S;0:1:尺码:XS;0:2:尺码:M;0:3:尺码:L;0:4:尺码:XL商品属性名

prop_imgs

Mix0{"prop_img": []}商品属性图片列表

property_alias

String00:0:S;0:1:XS;0:2:M;0:3:L;0:4:XL商品属性别名

props

Mix0[{ "name": "尺码","value": "S XS M L XL" }]商品详情

total_sold

Int0

skus

Mix0{"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_id

Int0卖家ID

sales

Int0销量

shop_id

Int0店铺ID

props_list

Mix0{"0:0": "尺码:S"}商品属性

seller_info

Mix0{"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.官方旗舰店" }卖家信息

tmall

Boolean0false是否天猫

error

String0错误信息

warning

String0警告信息

url_log

Mix0[]

props_img

Mix0[]属性图片

shop_item

Mix0[]

relate_items

Mix0[]

 

 

  • 25
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值