Hack 92 Automatically Relist Unsuccessful Auctions


Save time by automatically relisting auctions that have received no bids or have a reserve that wasn't met.

Most of the time, when an auction ends without receiving any bids or with a reserve that wasn't met, sellers end up relisting the item. But this can be rather laborious, especially if you have more than a few auctions to relist.

The following script will relist for you, and when run on a regular basis, say, every day, you'll never have to manually relist an auction again.

require 'ebay.pl';

$localfile = "autorelist.txt";     [1]
$today = &formatdate(time);
$yesterday = &formatdate(time - 86400);

my $page_number = 1;
while (1) {
    my $rsp = call_api({ Verb => 'GetSellerList',
                  DetailLevel => 8,
                       UserId => $user_id,
                  EndTimeFrom => $yesterday,
                    EndTimeTo => $today,
                   PageNumber => $page_number

    if ($rsp->{Errors}) {
      last PAGE;
    foreach (@{$rsp->{SellerList}{Item}}) {
      my %i = %$_;
      ($id, $bidder) = @i{qw/Id HighBidder/};

      if ($bidder->{User}{Email} !~ "\@") {     [2]
        open (INFILE,"$localdir/$localfile");
          while ( $line = <INFILE> ) {
            if ($line eq "$id\n") { goto SKIP; }     [3]
        close (INFILE);

        my $rsp = call_api({Verb => 'RelistItem',     [4]
                     DetailLevel => 0,
                          SiteId => $site_id,
                          ItemId => $id
        if ($rsp->{Errors}) {
        } else {
          print "Relisted item $id as #$rsp->{Item}[0]{Id}\n";
          open (OUTFILE,">>$localdir/$localfile");
            print OUTFILE "$id\n";     [5]
          close (OUTFILE);
    last PAGE unless $rsp->{SellerList}{HasMoreItems};

This script starts by listing all your auctions that have ended in the last 24 hours, similarly to [Hack #87]. For information on scheduling this script to run at regular intervals, see [Hack #17]. If you decide to have the script run less frequently, say, once a week, make sure to increase the window of dates accordingly for which auctions are retrieved.

The script determines that an auction ended unsuccessfully if the high bidder's email address is not specified, or, more specifically, that the email address field does not contain an @ sign (line [2]). For auctions that have received no bids, the HighBidder.User.Email field will be empty, or, if the reserve wasn't met, it will be set to "Invalid Request."

Then, the script checks to see if the auction has been previously relisted [3]; if it hasn't, the script proceeds to relist the auction [4]. If the relist operation is successful, a confirmation is shown and the auction number is recorded [5] into the filename specified on line [1]. (Note that there's no need to use the VerifyAddItem API call to confirm a successful relist, since the script already checks for errors.)

8.12.1 Hacking the Hack

If you don't want to automatically relist each and every unsuccessful auction, you can set restrictions. For example, you may not wish to relist any item under five dollars or any item that has already been relisted three times.

One thing you can do to improve the success of your relisted auctions is to lower the starting bid and/or reserve price. Now, if you don't explicitly specify the value of a particular option for the relisted auction, the script will simply use the value from the original auction. But, for example, if you specify a new starting bid or reserve price (perhaps 15% lower than the previous values) on line [4], those values will be used for the new auction. Most of the input arguments available for the AddItem API call (discussed in [Hack #88]) can be used in RelistItem as well; see the API documentation for details.

    Evaluation has »ЕРСВЧР¶expired.