Skip to Main Content
eBay Hacks
book

eBay Hacks

by David A. Karp
August 2003
Beginner content levelBeginner
368 pages
9h 38m
English
O'Reilly Media, Inc.
Content preview from eBay Hacks

Retrieve Details About an Auction

Use the GetItem API call to get listing details.

The GetItem API call is used to retrieve all the details of a listing, including the title, description, starting price, category, and about 180 other individual bits of information.

Here’s a simple script that, when provided with the item number, returns the title, seller ID, amount of time left, number of bids, and the current price.

#!/usr/bin/perl
require 'ebay.pl';

$item_id = shift @ARGV or die "Usage: $0 itemnumber";

my $rsp = call_api({ Verb => 'GetItem',     [1]
              DetailLevel => 0,
                       Id => $item_id
});

if ($rsp->{Errors}) {
  print_error($rsp)
} else {
  my %i = %{$rsp->{Item}[0]};
my ($price, $currency, $bids, $time_left, $seller, $title) =     [2]
         @i{qw/CurrentPrice CurrencyId BidCount TimeLeft Seller Title/};

$d = $time_left->{Days};     [3]
  $h = $time_left->{Hours};
  $m = $time_left->{Minutes};
  $s = $time_left->{Seconds};
  $seller_id = $seller->{User}{UserId};
  $seller_fb = $seller->{User}{Feedback}{Score};
  
  print "Item #$item_id: $title\n";
  print "For sale by $seller_id ($seller_fb)\n";
  print "Currently at $currency$price, $bids bids\n";
  
  if ($d > 0) { print "$d days, $h hours left.\n"; }
  elsif ($h > 0) { print "$h hours, $m minutes left.\n"; }
  elsif ($s > 0) { print "$m minutes, $s seconds left.\n"; }
  else { print "auction ended.\n"; }
}

This script is fairly straightforward. The GetItem API call is submitted on line [1], and the desired fields are extracted on line [2]. Naturally, you can specify any of the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

eBay Hacks, 2nd Edition

eBay Hacks, 2nd Edition

David A. Karp

Publisher Resources

ISBN: 0596005644Catalog PageErrata