当前位置: 首页 > news >正文

JAVA请求示例获取1688商品详情数据API接口item_get-获得阿里巴巴商品详情(按关键词搜索商品列表)

要获取1688(阿里巴巴)的商品详情数据,你需要使用阿里巴巴开放平台提供的API接口。与淘宝开放平台类似,你需要先在阿里巴巴开放平台注册账号,创建应用,并获取app_keyapp_secret。然后,根据阿里巴巴开放平台的文档,获取access_token,并使用这个access_token来调用相应的API接口。

下面是一个使用Java语言请求阿里巴巴商品详情数据API接口item_get的示例代码。请注意,这个例子假设你已经有了有效的access_token,并且你已经阅读并理解了阿里巴巴开放平台的API文档。

请求示例,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.万邦.cn/1688/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=610947572360";JSONObject json = getRequestFromUrl(url);System.out.println(json.toString());}}

 1688.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=610947572360

参数说明:num_iid:1688商品ID
sales_data:&sales_data=1 获取近30天成交数据
agent:&agent=1 获取1688分销代发价格数据

响应参数

Version: Date:

名称类型必须示例值描述

item

item[]0宝贝详情数据

num_iid

String0610947572360宝贝ID

title

String0厂家直销小米有品Qin2 Pro智能手机学生机老人机备用机小爱同学4G商品标题

desc_short

String0商品简介

price

Float0799.00价格

total_price

Float00

suggestive_price

Float00

orginal_price

Float0799.00原价

nick

String0qin多亲科技(_sopid@BBBSvyqimnYtLnmm90B_59dsg)卖家昵称(以上2种参数都有可能输出,凡是_sopid@开头的即为加密openid)

num

Int02191

min_num

Int02最小起批量

detail_url

String0https://detail.1688.com/offer/610947572360.html宝贝链接

pic_url

String0https://cbu01.alicdn.com/img/ibank/2020/063/830/13235038360_979836901.jpg宝贝图片

brand

String0MAJE品牌

brandId

Int08879363品牌id

rootCatId

Int00顶级分类ID

cid

Int0124264005

desc

String0

item_imgs

Mix0item_imgs[]商品图片

item_weight

String0

post_fee

Float09.00邮费

express_fee

Float09.00EMS费用

ems_fee

Float09.00物流费用

shipping_to

String0广东广州白云区发货至

video

video[]0商品视频

sample_id

String0

props_name

String00:0:机身内存:64GB;1:0:颜色:铁灰色;1:1:颜色:瓷白色商品属性名

prop_imgs

prop_imgs[]0商品属性图片列表

property_alias

String00:0:64GB;1:0:铁灰色;1:1:瓷白色属性别名

props

Mix0[{"name": "品牌", "value": "other"}]商品详情

total_sold

Int01

scale

Int0

sellUnit

Int0

skus

skus[]0商品规格信息列表

seller_id

Int02206619673102卖家ID

sales

Int0100销售额

shop_id

Int0151372205店铺ID

props_list

Mix0{"0:0": "机身内存:64GB"}商品属性

tmall

Boolean0false是否天猫

data_from

String01688app错误信息

error

String0错误信息

unit

String0部;单位

is_support_mix

Boolean0true

mix_amount

Int030

mix_Begin

Int0

mix_number

Int0

sales_data

Date0

location

String0广东省 深圳市发货地

props_img

Mix0属性图片

sales_info

Mix0

desc_img

Mix0[{"https://cbu01.alicdn.com/img/ibank/2020/560/807/14112708065_979836901.jpg"}]详情图片列表

shop_item

Mix0

relate_items

Mix0

http://www.lryc.cn/news/310348.html

相关文章:

  • 安卓手机安装termux、kali linux及基本配置
  • Python 实现海康机器人工业相机 MV-CS050-10GC 的实时显示视频流及拍照功能(实时显示视频流同时可以进行拍照)
  • 武器大师——操作符详解(下)
  • 鸿蒙Harmony应用开发—ArkTS声明式开发(通用属性:Popup控制)
  • Python系列(20)—— 排序算法
  • MySQL中json类型的字段
  • 算法学习——GCD与欧拉函数
  • 40. 组合总和 II(力扣LeetCode)
  • Ubuntu上Jenkins自动化部署Gitee上SpringBoot项目
  • 延迟任务基于DeyalQueue
  • Linux 查询端口被占用命令
  • 【c++】string类---标准库中的string类
  • GO语言学习笔记(与Java的比较学习)(五)
  • Sora:探索大型视觉模型的前世今生、技术内核及未来趋势
  • 基于springboot实现图书馆管理系统项目【项目源码+论文说明】计算机毕业设计
  • MATLAB环境下基于高斯滤波器-广义拉普拉斯算子的细胞核自动检测
  • 【探索AI】十一 深度学习之第1周:深度学习概述与基础
  • 【简说八股】Spring事务失效可能是哪些原因?
  • 【语音识别】- CTC损失计算的原理
  • MySQL字符集和比较规则
  • 备忘录模式(Memento Pattern)
  • LeetCode 刷题 [C++] 第121题.买卖股票的最佳时机
  • ORACLE 基础
  • Adobe illustrator CEP插件调试
  • 学会玩游戏,智能究竟从何而来?
  • Unity 常用操作
  • 【计算机网络_应用层】协议定制序列化反序列化
  • Doris实战——银联商务实时数仓构建
  • 代码随想录算法训练营第七天
  • 文件操作和IO(2):Java中操作文件