一、接口概述
eBay的Finding API提供findItemsByKeywords方法,支持通过关键词检索商品列表。该接口采用REST架构,返回标准JSON/XML格式数据,日均调用限额5000次(生产环境需申请提升配额)。
二、核心参数说明
必需参数:
keywords = "智能手机" # URL编码后的搜索词
service_version = "1.0.0"
security_appname = "YourAppID" # 开发者账号申请的AppID
可选参数:
paginationInput.entriesPerPage = 20 # 每页结果数(1-100)
itemFilter(0).name = "Condition" # 商品条件筛选
itemFilter(0).value = "New"
outputSelector = "SellerInfo" # 返回额外字段
三、Python调用示例
import requests
from urllib.parse import quote
def ebay_search(keyword, app_id):
endpoint = "https://svcs.ebay.com/services/search/FindingService/v1"
params = {
"OPERATION-NAME": "findItemsByKeywords",
"SERVICE-VERSION": "1.13.0",
"SECURITY-APPNAME": app_id,
"RESPONSE-DATA-FORMAT": "JSON",
"keywords": quote(keyword),
"paginationInput.entriesPerPage": 10
}
response = requests.get(endpoint, params=params)
return response.json()
# 使用示例
result = ebay_search("无线耳机", "YOUR_APP_ID")
print(result["findItemsByKeywordsResponse"][0]["searchResult"][0]["item"])
四、返回数据处理
典型响应结构包含:
searchResult.item: 商品对象数组
sellingStatus.currentPrice: 当前价格
viewItemURL: 商品详情页链接
condition.conditionDisplayName: 商品状态说明
五、最佳实践建议
实现请求重试机制(HTTP 503错误时)
使用outputSelector按需获取字段减少带宽
本地缓存高频搜索词结果
遵守每分钟600次/每日5000次的调用限制