阿里巴巴中国站按图搜索1688商品(拍立淘) API 返回值说明

2023-12-13 09:43:06

item_search_img-按图搜索1688商品(拍立淘)

1688.item_search_img

公共参数? ?点此获取key

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

请求参数

请求参数:imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!!2200811456689.jpg

参数说明:imgid:图片地址(使用淘宝upload_img接口上传图片,返回图片地址)
如:https://img.alicdn.com/imgextra/i3/15353738/TB2HDHAqN9YBuNjy0FfXXXIsVXa_!!15353738-0-beehive-scenes.jpg

响应参数

Version: Date:

名称类型必须示例值描述

items

items[]0按图搜索1688商品

real_total_results

Int080宝贝真实数量

total_results

Int043搜索数量

pagecount

Int01总页数

error

String0错误代码

data_from

String0

item

item[]0宝贝详情数据

title

String0外贸儿童短袖T恤 夏季热销套装 时尚儿童T宝贝标题

pic_url

String0https://cbu01.alicdn.com/img/ibank/2016/998/799/2913997899_1588191881.jpg宝贝图片

price

Float07.00价格

sales

Int05销量

num_iid

Bigint0529502304128宝贝ID

turnHead

String023.5%回头率

seller_nick

String0中山市汇锦制衣有限公司卖家昵称

area

String0广东中山市店铺所在地

detail_url

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

请求示例

curl

-- 请求示例 url 默认请求参数已经URL编码处理
curl -i "https://api-gw.seaver.cn/1688/item_search_img/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!!2200811456689.jpg"

PHP

<?php

// 请求示例 url 默认请求参数已经URL编码处理
// 本示例代码未加密secret参数明文传输,若要加密请参考:https://open.onebound.cn/help/demo/sdk/demo-sign.php
$method = "GET";
$url = "https://api-seaver.cn/1688/item_search_img/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!!2200811456689.jpg";
$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));
?>

Python

# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://api-seaver.cn/1688/item_search_img/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!!2200811456689.jpg"
headers = {
    "Accept-Encoding": "gzip",
    "Connection": "close"
}
if __name__ == "__main__":
    r = requests.get(url, headers=headers)
    json_obj = r.json()
    print(json_obj)

?java

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-seaver.cn/1688/item_search_img/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!!2200811456689.jpg";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

?

文章来源:https://blog.csdn.net/Jernnifer_mao/article/details/134880727
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。