Temu是拼多多旗下的跨境电商平台。该平台于2022年9月1日正式在美国上线,主要通过网站和APP进行运营,主要面向海外消费者。
TEMU以“Team Up,Price Down”为口号,旨在通过高效的供应链和物流体系,为消费者提供高性价比的商品。其商品种类丰富,包括服装、鞋包、家居、数码、美妆等,满足了消费者的多样化需求。
Temu跨境电商平台提供了按关键字搜索商品的API接口,该接口允许用户或第三方服务通过发送HTTP请求,根据指定的关键字搜索商品,并返回与关键字相关的商品列表信息。
1.请求参数
请求参数:q=shoe&start_price=&end_price=&page=&list_id=&cat=&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=
参数说明:q:搜索关键字
cat:分类ID
start_price:开始价格
end_price:结束价格
list_id:列表id
sort:排序[bid,_bid,bid2,_bid2,_sale,_credit]
(bid:总价,bid2:商品价格,sale:销量,credit信用,加_前缀为从大到小排序)
2.请示示例
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.fan-b.com/temu/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=shoe&start_price=&end_price=&page=&list_id=&cat=&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
3.返回结果
{
"items": {
"page": 1,
"page_size": 120,
"has_more": true,
"data_from": "app",
"item": [
{
"title": "2022 Minimalist Mens Fashion Ultra Thin Watches Simple Men Business Stainless Steel Mesh Belt Quartz Watch",
"pic_url": "https:\/\/img.kwcdn.com\/product\/Fancyalgo\/VirtualModelMatting\/c7ef2fecd0a44b17857a152b674969fb.jpg",
"price": "2.09",
"orginal_price": "2.09",
"sales": "90K+",
"num_iid": 601099512645657,
"detail_url": "https:\/\/www.temu.com\/2022-minimalist-mens-fashion-ultra-thin-watches-simple-men-business-stainless-steel-mesh-belt-quartz-watch-g-601099512645657.html?&top_gallery_url=https%3A%2F%2Fimg.kwcdn.com%2Fproduct%2FFancyalgo%2FVirtualModelMatting%2Fc7ef2fecd0a44b17857a152b674969fb.jpg&spec_gallery_id=7257449&refer_page_sn=10009&refer_source=0&freesia_scene=2&_oak_freesia_scene=2&_oak_rec_ext_1=MjA5",
"list_id": "896ae23b45bdb231845f7d33fb5eaadc_1708653658747"
},
{
"title": "POEDAGAR Waterproof Luminous Calendar Mens Quartz Watch Stainless Steel Wrist Watch, Ideal choice for Gifts",
"pic_url": "https:\/\/img.kwcdn.com\/product\/Fancyalgo\/VirtualModelMatting\/af19f3e3847f330cebe874a0665b4ad2.jpg",
"price": "8.98",
"orginal_price": "8.98",
"sales": "20K+",
"num_iid": 601099520399445,
"detail_url": "https:\/\/www.temu.com\/poedagar-waterproof-luminous-calendar-mens-quartz-watch-stainless-steel-wrist-watch-g-601099520399445.html?&top_gallery_url=https%3A%2F%2Fimg.kwcdn.com%2Fproduct%2FFancyalgo%2FVirtualModelMatting%2Faf19f3e3847f330cebe874a0665b4ad2.jpg&spec_gallery_id=2011275199&refer_page_sn=10009&refer_source=0&freesia_scene=2&_oak_freesia_scene=2&_oak_rec_ext_1=ODk4",
"list_id": "896ae23b45bdb231845f7d33fb5eaadc_1708653658747"
}
]
}
}
4.应用场景
Temu跨境电商API按关键字搜索商品的功能可以应用于多个场景,如用户搜索商品、数据分析与市场调研以及第三方应用或服务集成等。通过该API接口,用户可以快速找到感兴趣的商品,商家可以了解用户的搜索习惯和偏好从而优化商品列表和营销策略,而第三方应用或服务则可以为用户提供更加便捷的购物体验。
综上所述,Temu跨境电商API按关键字搜索商品的返回值包含了丰富的商品信息字段,可以满足不同应用场景的需求。在使用该API接口时,需要根据实际情况构造合适的请求参数并处理返回的响应数据。