0.0
The project is in a healthy, maintained state
Ruby gem for integrating with eBay REST APIs. Supports Browse API, Finding API, and Taxonomy API with OAuth 2.0 authentication.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.0
~> 2.8
~> 13.0
~> 3.12
~> 1.50
~> 3.18

Runtime

>= 0.1
~> 0.21
~> 2.6
 Project Readme

ebay-api-ruby Gem Version

A modern Ruby gem for the eBay REST APIs. Supports the Browse API, Marketplace Insights API, and Taxonomy API with OAuth 2.0 authentication.

Deprecation Notice: The eBay Finding API has been shut down. All Ebay::Finding methods now emit deprecation warnings and will be removed in v1.0.0. See Migration Guide below.

Installation

Add this line to your application's Gemfile:

gem 'ebay-api-ruby'

And then execute:

bundle install

Or install it yourself:

gem install ebay-api-ruby

Configuration

require 'ebay'

Ebay.configure do |config|
  config.client_id = ENV['EBAY_CLIENT_ID']
  config.client_secret = ENV['EBAY_CLIENT_SECRET']
  config.marketplace_id = 'EBAY_US'             # Default
  config.timeout = 30                            # Default
end

Sandbox Mode

Ebay.configure do |config|
  config.client_id = ENV['EBAY_SANDBOX_CLIENT_ID']
  config.client_secret = ENV['EBAY_SANDBOX_CLIENT_SECRET']
  config.sandbox!
end

Usage

Browse API

Search for items, get item details, and search by image.

browse = Ebay::Browse.new

# Search items
results = browse.search(q: "vintage rolex", limit: 10)
results['itemSummaries'].each do |item|
  puts "#{item['title']} - #{item['price']['value']} #{item['price']['currency']}"
end

# Get a specific item
item = browse.get_item("v1|123456789|0")

# Get items by group
items = browse.get_items_by_item_group("group123")

# Search by category (no keywords required)
results = browse.search_by_category("9355", limit: 10)

# Search by image
results = browse.search_by_image(Base64.encode64(File.read("watch.jpg")))

Marketplace Insights API

Search sold/completed items for price history and market data.

insights = Ebay::MarketplaceInsights.new

# Search sold items
sold = insights.search(q: "pokemon base set charizard")
sold['itemSales'].each do |item|
  puts "#{item['title']} - sold for #{item['lastSoldPrice']['value']}"
end

# With filters
sold = insights.search(q: "vintage rolex", category_ids: "31387", limit: 20)

Finding API (Deprecated)

The Finding API has been shut down by eBay. All methods emit deprecation warnings. Use Browse and Marketplace Insights APIs instead. See Migration Guide.

Taxonomy API

Get category trees and browse category hierarchies.

taxonomy = Ebay::Taxonomy.new

# Get default category tree ID for a marketplace
tree_info = taxonomy.get_default_category_tree_id("EBAY_US")
tree_id = tree_info['categoryTreeId']

# Get the full category tree
tree = taxonomy.get_category_tree(tree_id)

# Get a subtree
subtree = taxonomy.get_category_subtree(tree_id, "9355")

Authentication

The gem handles OAuth 2.0 Client Credentials authentication automatically. Tokens are cached and refreshed when expired.

client = Ebay.client

# Manual authentication (usually not needed)
client.authenticate!

# Direct API calls
result = client.get("/buy/browse/v1/item_summary/search", q: "test")
result = client.post("/some/endpoint", { data: "value" })

Error Handling

begin
  browse.search(q: "test")
rescue Ebay::AuthenticationError => e
  puts "Auth failed: #{e.message}"
rescue Ebay::NotFoundError => e
  puts "Not found: #{e.message} (#{e.status_code})"
rescue Ebay::RateLimitError => e
  puts "Rate limited. Retry after: #{e.retry_after}"
rescue Ebay::ValidationError => e
  puts "Validation error: #{e.errors}"
rescue Ebay::APIError => e
  puts "API error: #{e.message} (#{e.status_code})"
rescue Ebay::ConfigurationError => e
  puts "Config error: #{e.message}"
end

Migrating from the Finding API

The eBay Finding API has been shut down. Here's how to migrate to the replacement APIs:

Finding (old) Replacement (new)
finding.find_items_by_keywords("query") browse.search(q: "query")
finding.find_completed_items("query") insights.search(q: "query")
finding.find_items_by_category("9355") browse.search_by_category("9355")
finding.find_items_advanced(keywords: "q", categoryId: "9355") browse.search(q: "q", category_ids: "9355")

Key differences:

  • Auth: No more app_id — all APIs use OAuth 2.0 (client_id + client_secret)
  • Response format: Clean REST JSON instead of the old nested XML-style format
  • Filters: Browse API uses a filter parameter (e.g., filter: "price:[10..50],priceCurrency:USD") instead of Finding's itemFilter syntax

Development

git clone https://github.com/esouza/ebay-api-ruby.git
cd ebay-api-ruby
bundle install
bundle exec rspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/esouza/ebay-api-ruby. See CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License.