I tried to touch the API of ebay

Introduction

Be enrolled in the eBay Developers Program Please refer to the guide in here.

Try using the Finding API

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()

Value returned

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

I tried to touch the API of ebay
I tried to touch the COTOHA API
I tried to touch Tesla's API
I tried to correct the keystone of the image
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to touch jupyter
I tried to get the authentication code of Qiita API with Python.
I tried to get the movie information of TMDb API with Python
I tried to summarize the basic form of GPLVM
I tried to touch the CSV file with Python
I tried using the API of the salmon data project
I tried to visualize the spacha information of VTuber
I tried to erase the negative part of Meros
I tried to classify the voices of voice actors
I tried to summarize the string operations of Python
I tried to create Quip API
I tried the Naro novel API 2
I tried to touch Python (installation)
I tried the Naruro novel API
I tried to move the ball
I tried using the checkio API
I tried to estimate the interval.
I tried to find the entropy of the image with python
[Horse Racing] I tried to quantify the strength of racehorses
[First COTOHA API] I tried to summarize the old story
I tried to get the location information of Odakyu Bus
I tried to find the average of the sequence with TensorFlow
[Python] I tried to visualize the follow relationship of Twitter
[Machine learning] I tried to summarize the theory of Adaboost
[Python] I tried collecting data using the API of wikipedia
I tried to fight the Local Minimum of Goldstein-Price Function
I tried to get various information from the codeforces API
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
I tried the asynchronous server of Django 3.0
I tried to summarize the umask command
I tried to summarize the graphical modeling.
I tried to estimate the pi stochastically
I tried to make a Web API
I tried to touch Python (basic syntax)
I tried using the BigQuery Storage API
I tried to get the index of the list using the enumerate function
I tried to automate the watering of the planter with Raspberry Pi
I tried to build the SD boot image of LicheePi Nano
I tried to expand the size of the logical volume with LVM
I tried to summarize the frequently used implementation method of pytest-mock
I tried to improve the efficiency of daily work with Python
I tried to visualize the common condition of VTuber channel viewers
I tried to automatically post to ChatWork at the time of deployment with fabric and ChatWork Api
I tried to automate the construction of a hands-on environment using IBM Cloud's SoftLayer API
I tried to transform the face image using sparse_image_warp of TensorFlow Addons
I tried web scraping to analyze the lyrics.
I tried the pivot table function of pandas
I tried cluster analysis of the weather map
I tried to get the batting results of Hachinai using image processing
I tried to visualize the age group and rate distribution of Atcoder
I tried transcribing the news of the example business integration to Amazon Transcribe
I tried to notify slack of Redmine update
I tried to optimize while drying the laundry
zoom I tried to quantify the degree of excitement of the story at the meeting
I tried to estimate the similarity of the question intent using gensim's Doc2Vec