Hack 88 Submit an Auction Listing


Use AddItem to start new listings and make scheduling easier.

eBay's Turbo Lister, introduced in [Hack #73], is an API-based tool used to submit new listings to eBay. It provides a complete interface with which the user can create and modify listings, as well as a database engine that stores them. (Factoid: 35% of eBay listings are reportedly submitted with the API, including those uploaded with Turbo Lister.)

All the work is done by the AddItem API call, illustrated by this extremely simple script:

require 'ebay.pl';

$category    = shift @ARGV;
$title        = shift @ARGV;
$description = shift @ARGV;
$minimum_bid = shift @ARGV;
              or die "Usage: $0 category title description minimumbid";

$country = 'us';
$location = 'My home town';
$duration = 7;
$quantity = 1;
$currency = 1;

my $rsp = call_api({ Verb => 'AddItem',     [1]
              DetailLevel => 0,
                   SiteId => $site_id,
                 Category => $category,
 CheckoutDetailsSpecified => 0,
                  Country => $country,
                 Currency => $currency,
              Description => $description,
                 Duration => $duration,
                 Location => $location,
               MinimumBid => $minimum_bid,
             PaymentOther => 1,
                 Quantity => $quantity,
                   Region => 0,
                    Title => $title,
if ($rsp->{Errors}) {
} else {
    print "New listing created: #$rsp->{Item}[0]{Id}\n";     [2]
    print "Ends $rsp->{Item}[0]{EndTime}\n";

The simplest way to use this script is to call it from the command line, like this:

additem.pl 7276 'Little Red Steam Shovel' 'My description...' 5.00

However, it will probably make more sense to call it from another script or program, especially since you'll likely want more of a description than simply "My description . . . " and more options than the four required by this sample script.

Although AddItem calls do not count against your daily (or monthly) API call allotment, the listing fees normally associated with starting new auctions still apply. The same goes for the RelistItem call, discussed in [Hack #92].

8.8.1 Hacking the Hack

Of the more than 120 individual input fields supported by the AddItem call, only 11 are required: Category, CheckoutDetailsSpecified, Country, Currency, Description, Duration, Location, MinimumBid, Quantity, Region, and Title. But when submitting a live listing, you'll most likely want to include as many options as possible, everything from the shipping charges to the extra-cost listing upgrades. Refer to the API documentation for a complete listing, and place any additional fields alongside the others on line [1].

As discussed in [Hack #99], it's important to save as much retrieved information as possible so that you can reduce the number of subsequent API calls needed. If you submit listings only with the AddItem API call (never through eBay.com), you should record the item numbers it returns ($rsp->{Item}[0]{Id}) for further use. This would reduce (or eliminate) your need for the GetSellerList API call ? used in so many of the hacks in this chapter ? at least when it comes to retrieving a listing of your own auctions.

8.8.2 See Also

The eBay API SDK comes with the eBay Sample Selling Application, a Microsoft Visual Studio .NET-based listing creation tool similar to Turbo Lister. Those interested in creating a similar tool will want to poke around in the included C source code.