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 ...
Get eBay Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.