Be enrolled in the eBay Developers Program Please refer to the guide in here.
Finding API Product search function on the eBay platform You can get search results for products listed on eBay with the API
I will run it with python
ebay_api.py
import requests
import csv
appkey =Obtained APP KEY
keywords =Keywords you want to search
URL = "http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords"\
"&SERVICE-VERSION=1.0.0"\
f"&SECURITY-APPNAME={appkey}"\
"&RESPONSE-DATA-FORMAT=JSON"\
"&REST-PAYLOAD"\
f"&keywords={keywords}"
def get_page():
request = requests.get(URL)
products = request.json()
for item in (products["findItemsByKeywordsResponse"][0]["searchResult"][0]["item"]):
itemId = item["itemId"][0]
title = item["title"][0]
currency = item["sellingStatus"][0]["currentPrice"][0]["@currencyId"]
price = item["sellingStatus"][0]["currentPrice"][0]["__value__"]
data = {
"itemId": itemId,
"title": title,
"currency": currency,
"price": price
}
with open("eBayAPI.csv", "a") as csvfile:
row = [
data["itemId"],
data["title"],
data["currency"],
data["price"]
]
writer = csv.writer(csvfile)
writer.writerow(row)
if __name__ == "__main__":
get_page()
def get_page():
request = requests.get(URL)
products = request.json()
print(products)
The value returned here is returned in this way.
{
"findItemsByKeywordsResponse": [{
"ack": ["Success"],
"version": ["1.13.0"],
"timestamp": ["2021-01-07T03:03:03.718Z"],
"searchResult": [{
"@count": "100",
"item": [
{
"itemId": ["303483892785"],
"title": ["Spider-man retro Marvel Legends Venom Miles Morales Spiderverse Gwen Stacy UPICK"],
"globalId": ["EBAY-US"],
"primaryCategory": [{
"categoryId": ["158671"],
"categoryName": ["Comic Book Heroes"]
}],
"galleryURL": ["https://thumbs1.ebaystatic.com/pict/04040_0.jpg "],
"viewItemURL": ["https://www.ebay.com/itm/Spider-man-retro-Marvel-Legends-Venom-Miles-Morales-Spiderverse-Gwen-Stacy-UPICK-/303483892785?var=0"],
"autoPay": ["true"],
"postalCode": ["951**"],
"location": ["San Jose,CA,USA"],
"country": ["US"],
"shippingInfo": [{
"shippingServiceCost": [{
"@currencyId": "USD",
"__value__": "5.99"
}],
"shippingType": ["FlatDomesticCalculatedInternational"],
"shipToLocations": ["Worldwide"],
"expeditedShipping": ["false"],
"oneDayShippingAvailable": ["false"],
"handlingTime": ["1"]
}],
"sellingStatus": [{
"currentPrice": [{
"@currencyId": "USD",
"__value__": "12.95"
}],
"convertedCurrentPrice": [{
"@currencyId": "USD",
"__value__": "12.95"
}],
"sellingState": ["Active"],
"timeLeft": ["P5DT0H12M28S"]
}],
"listingInfo": [{
"bestOfferEnabled": ["false"],
"buyItNowAvailable": ["false"],
"startTime": ["2020-02-12T03:15:31.000Z"],
"endTime": ["2021-01-12T03:15:31.000Z"],
"listingType": ["FixedPrice"],
"gift": ["false"], "watchCount": ["502"]
}],
"returnsAccepted": ["false"],
"condition": [{
"conditionId": ["3000"],
"conditionDisplayName": ["Used"]
}],
"isMultiVariationListing": ["true"],
"topRatedListing": ["false"]
},
{
"itemId": ["133473696803"]...
Please extract the required value by yourself.
This time, I am trying to get the product ID, product name, currency, price
.
itemId = item["itemId"][0]
title = item["title"][0]
currency = item["sellingStatus"][0]["currentPrice"][0]["@currencyId"]
price = item["sellingStatus"][0]["currentPrice"][0]["__value__"]
After that, the acquired product information is output as csv.
It seems that you can also search by filter or search in a specific store. I think that market research will be easier if it is used well.
Next, I will write about the article on ebaysdk.
Recommended Posts