++ed by:

2 non-PAUSE users.

Igor Chudov


Net::eBay - Perl Interface to XML based eBay API.


Version 0.21


This module helps user to easily execute queries against eBay's XML API.

Getting Official Time

 use Net::eBay;
 my $eBay   = new Net::eBay; # look up ebay.ini in $ENV{EBAY_INI_FILE}, "./ebay.ini", "~/.ebay.ini"
 my $result = $eBay->submitRequest( "GeteBayOfficialTime", {} );
 print "eBay Official Time = $result->{EBayTime}.\n";

Automated bidding

eBay does not allow bidding via eBay API.

Listing Item for sale

 use Net::eBay;
 use Data::Dumper;

 # another way of creating Net::eBay object.
 my $ebay = new Net::eBay( {
                              SiteLevel => 'prod',
                              DeveloperKey => '...',
                              ApplicationKey => '...',
                              CertificateKey => '...',
                              Token => '...',
                             } ); 

 my $result = $ebay->submitRequest( "AddItem",
                       DetailLevel => "0",
                       ErrorLevel => "1",
                       SiteId = > "0",
                       Verb => "  AddItem",
                       Category => "14111",
                       CheckoutDetailsSpecified => "0",
                       Country => "us",
                       Currency => "1",
                       Description => "For sale is like new <A HREF=http://www.example.com/jhds/>thingamabob</A>.Shipping is responsibility of the buyer.",
                       Duration => "7",
                       Location => "Anytown, USA, 43215",
                       Gallery => 1,
                       GalleryURL => 'http://igor.chudov.com/images/mark_mattson.jpg',
                       MinimumBid => "0.99",
                       BuyItNowPrice => 19.99,
                       PayPalAccepted => "1",
                       PayPalEmailAddress => "ichudov\@example.com",
                       Quantity => "1",
                       Region => "60",
                       Title => "Igor's Item with Gallery xaxa",

  print "Result: " . Dumper( $result ) . "\n";

Result of submitRequest is a perl hash obtained from the response XML using XML::Simple, something like this:

 Result: $VAR1 = {
          'Item' => {
                    'Id' => '4503546598',
                    'Fees' => {
                              'FeaturedGalleryFee' => '0.00',
                              'InternationalInsertionFee' => '0.00',
                              'CurrencyId' => '1',
                              'GalleryFee' => '0.25',
                              'AuctionLengthFee' => '0.00',
                              'ProPackBundleFee' => '0.00',
                              'BorderFee' => '0.00',
                              'FeaturedFee' => '0.00',
                              'SchedulingFee' => '0.00',
                              'HighLightFee' => '0.00',
                              'FixedPriceDurationFee' => '0.00',
                              'PhotoDisplayFee' => '0.00',
                              'ListingFee' => '0.55',
                              'BuyItNowFee' => '0.00',
                              'PhotoFee' => '0.00',
                              'GiftIconFee' => '0.00',
                              'SubtitleFee' => '0.00',
                              'InsertionFee' => '0.30',
                              'ListingDesignerFee' => '0.00',
                              'BoldFee' => '0.00',
                              'ReserveFee' => '0.00',
                              'CategoryFeaturedFee' => '0.00'
                    'StartTime' => '2005-08-30 04:50:47',
                    'EndTime' => '2005-09-06 04:50:47'
          'EBayTime' => '2005-08-30 04:50:47'

See an alternative example of submitting an item using New Schema, in script ebay-add-item.pl.

If an error in parsing XML occurs, result will be simply the string that is the text representation of the answer.


new -- creates eBay API. Requires supplying of credentials: DeveloperKey, ApplicationKey, CertificateKey, Token. Net::eBay will not be created until these keys and the token are supplied.

Get them by registering at http://developer.ebay.com and self certifying. Celf certifying is a trivial process of solemnly swearing that you are ready to use their API.

The SiteLevel parameter is also mandatory and can be either 'prod' or 'dev'. prod means to use their production site (being charged real money for listings, etc), and dev means to use eBay sandbox http://sandbox.ebay.com/.

Parameters can be supplied in two ways:

1) As a hash table

2) As a filename (only argument). If filename and hash are missing, Net::eBay makes an effort to fine a ebay.ini file by looking for: $ENV{EBAY_INI_FILE}, ./ebay.ini, ~/.ebay.ini . That's the default constructor.

See SAMPLE.ebay.ini in this distribution.

Defaults and XML API Versions

This module, by default, is using the "Legacy XML API" that is set to expire in the summer of 2006. That default will change as the legacy API actually expires.

XML API Schema is set by calling setDefaults( { ... } )

See its documentation below.

ebay.ini FILE

ebay.ini is a file that lists ebay access keys and whether this is for accessing eBay production site or its developers' sandbox. Example of the file (see SAMPLE.ebay.ini):

 # dev or prod

 # your developer key

 # your application key

 # your certificate key

 # your token (a very BIG string)
This module was seen times.




Sets application defaults, most importantly the XML API version to be used.

Takes a hash argument.

The following defaults can be set:

* API -- sets eBay API version. Only two values are supported: '1' means Legacy API set to expire in the summer of 2006, '2' means the API that supersedes it. All other values are illegal.

* debug -- if debug is set to true, prints a lot of debugging information, XML sent and received etc.


  $eBay->setDefaults( { API => 2 } ); # use new eBay API
  $eBay->setDefaults( { API => 2, debug => 1 } ); # use new eBay API and also debug all calls


Sends a request to eBay. Takes a name of the API call and a hash of arguments. The arguments can be hashes of hashes and are properly translated into nested XML structures.


  TopLevel => {
                Item1 => 'hello',
                Item2 => 'world'
                Item3 => ['foo', 'bar']

it would be translated to


If an argument has XML attributes and should be formatted like this:

 <TestAttribute currencyID="USD" >abcd</TestAttribute>

(note "currencyID")

your argument should be

 TestAttribute => { _attributes => { currencyID => 'USD' }, _value => 'abcd' ),

Depending on the default API set by setDefaults (see above), XML produced will be compatible with the eBay API version selected by the user.


Returns eBay official time


Igor Chudov, <ichudov@algebra.com>


Please report any bugs or feature requests to bug-net-ebay@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-eBay. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.



Copyright 2005 Igor Chudov, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.