This library provides a wrapper to the eBay APIs.
You can instantiate API requests using shorthand class methods defined on Ebay
.
Ebay.finding # returns a new Ebay::Finding instance
eBay APIs require developer keys.
You can provide these globally with the environment variables EBAY_APP_ID
, EBAY_DEV_ID
, and EBAY_CERT_ID
.
If you prefer not to use environment variables, you can provide your keys globally with:
Ebay.configure do |config|
config.app_id = 'YOUR APP ID'
config.dev_id = 'YOUR DEV ID'
config.cert_id = 'YOUR CERT ID'
end
Finally, you can provide your keys individually to the request when instantiating it. This is what you will want to do if you are using multiple sets of credentials.
Please note that each API names keys differently.
request = Ebay.finding(security_appname: 'YOUR APP ID')
In the examples below, we will assume we are providing our keys with environment variables.
The eBay APIs return responses in XML or JSON format.
You can override the default format of an API when instantiating the request.
require 'json'
# the Finding API returns XML by default
request = Ebay.finding(response_data_format: 'JSON')
response = request.find_items_by_keywords('iphone')
JSON.parse(response)
The Browse API allows your buyers to search eBay items by keyword and category. It also allows them to view and add items to their eBay shopping cart.
require 'ebay/browse'
require 'ebay/oauth/client_credentials_grant'
access_token = Oauth::ClientCredentialsGrant.new.mint_access_token
request = Ebay.browse(campaign_id: '123', country: 'US', zip: '19406',
access_token: access_token)
response = request.search(q: 'iphone')
The Finding API lets you search and browse for items listed on eBay and provides useful metadata to refine searches.
require 'ebay/finding'
request = Ebay.finding
response = request.find_items_by_keywords('iphone')
The Merchandising API retrieves information about products or item listings on eBay to help you sell more merchandise to eBay buyers.
require 'ebay/merchandising'
request = Ebay::Merchandising.new
response = request.get_most_watched_items
The eBay Shopping API makes it easy to search for things on eBay.
require 'ebay/shopping'
request = Ebay::Shopping.new
response = request.find_products('QueryKeywords' => 'tolkien')