skip to Main Content

I’m trying to use R to conduct searches in eBay on the site’s API. However, I’m at a complete loss as to how to do this.

I’m familiar with using other APIs in R, e.g. Twitter and Instagram. Some of these searches can be conducted using dedicated libraries (twitteR, streamR, etc.), but I’ve also had to cobble stuff together with httr and RCurl. Unfortunately, I’m having absolutely no luck with such approaches on ebay. I’ve tried:

getURL(''http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords
           &SERVICE-VERSION=1.0.0
           &SECURITY-APPNAME=My_App_ID
           &GLOBAL-ID=EBAY-US
           &RESPONSE-DATA-FORMAT=JSON
           &callback=_cb_findItemsByKeywords
           &REST-PAYLOAD
           &keywords=harry%20potter
           &paginationInput.entriesPerPage=3')

It didn’t work. I also tried:

 url <- "http://svcs.ebay.com/services/search/FindingService/v1"
 xml.request <- "<?OPERATION-NAME=findItemsByKeywords
 &SERVICE-VERSION=1.0.0
 &SECURITY-APPNAME=My_App_ID
 &GLOBAL-ID=EBAY-US
 &RESPONSE-DATA-FORMAT=XML
 &callback=_cb_findItemsByKeywords
 &REST-PAYLOAD
 &keywords=harry%20potter
 &paginationInput.entriesPerPage=3>"

 myheader=c(Connection="close", 
 'Content-Type' = "application/xml",
 'Content-length' =nchar(xml.request))

  data =  getURL(url = url,
           postfields=xml.request,
           httpheader=myheader,
           verbose=TRUE)

No luck with this either. Basically, I have no idea what I’m doing. Can anyone help?

2

Answers


  1. url <- 'http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=USER_ADD_ID&GLOBAL-ID=EBAY-US&keywords=macbook+refurbished&paginationInput.entriesPerPage=10'
    
    getURL(url)
    
    > getURL(url)
    [1] "<?xml version='1.0' encoding='UTF-8'?><findItemsByKeywordsResponse xmlns="http://www.ebay.com/marketplace/search/v1/services"><ack>Success</ack><version>1.13.0</version><timestamp>2016-12-05T18:48:43.170Z</timestamp><searchResult count="10"><item><itemId>152233530373</itemId><title>Apple Macbook Air 11.6" 1.3 GHz Core i5 128 GB SSD, 4GB RAM, Yosemite- MD711LL/A</title><globalId>EBAY-US</globalId><subtitle>OS Upgraded to 10.10 Yosemite l Cosmetic Condition 8/10</subtitle><primaryCategory><categoryId>111422</categoryId><categoryName>Apple Laptops</categoryName></primaryCategory><galleryURL>http://thumbs2.ebaystatic.com/m/mpUZSSnEfwJ5YOFJ8JzcmXw/140.jpg</galleryURL><viewItemURL>http://www.ebay.com/itm/Apple-Macbook-Air-11-6-1-3-GHz-Core-i5-128-GB-SSD-4GB-RAM-Yosemite-MD711LL-A-/152233530373</viewItemURL><productId type="ReferenceID">160128184</productId><paymentMethod>PayPal</paymentMethod><autoPay>true</autoPay><location>USA</location><country>US</country><shippingInfo><shipp... <truncated>
    

    Reference Getting Started with the Finding API: Finding Items by Keywords

    Login or Signup to reply.
  2. I have wrapped ebay’s Finding API with a new R package called ebayr, with a httr::GET call. See here: https://github.com/gsimchoni/ebayr

    You’ll need to get your token from https://go.developer.ebay.com/ and you’re good to go.

    Here’s also a blog post for inspiration: http://giorasimchoni.com/2017/12/19/2017-12-19-e-is-for-elephant-the-ebayr-package/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search