List Several Items for Sale at Once

If you’re ready to do serious business through Amazon, a Pro-Merchant subscription allows you to list hundreds or even thousands of items in one fell swoop.

Listing one or two books with Amazon’s standard listing form [Hack #49] is fine, but once you reach a dozen or so it can be tedious. Amazon has a tool called Book Loader that volume sellers can use to upload their entire inventory of books in a machine-readable format.

Tip

You need to be a Pro-Merchant subscriber Section 4.2 Section 4.2 to use this hack. Bulk upload tools are available only with a subscription.

The Book Loader is a specialized version of another bulk-listing tool that Amazon offers called Inventory Loader (http://www.amazon.com/exec/obidos/tg/browse/-/1161312/). The Book Loader contains fields specific to books, such as author, publisher, and binding. The Inventory Loader format is more generic to handle a wide range of items.

The loading process involves entering all of your product data into a spreadsheet, saving it in a tab-delimited file, and sending it to the Amazon server. Unfortunately, populating the spreadsheet with all the required information can be just as tedious as listing the items individually.

Tip

If you’d like to see a sample Book Loader spreadsheet with all of the data fields available, send a blank email to . You’ll quickly receive a reply with a blank Excel template attached.

Because we know that the final format Amazon needs is a tab-delimited file, it’s possible to script the process of putting it together. This hack takes a list of ASINs, looks up or prompts for any required information, and leaves you with a file that you can upload to Amazon with all of your sale items.

The Code

Save the following code to a text file called create_bulk.pl . You’ll need a Web Services developer’s token and affiliate tag Section 6.4, so be sure to include them in the script.

#!/usr/bin/perl
# create_bulk.pl
# A script to create an Amazon Marketplace Bulk Load file.
# Usage: perl create_bulk.pl <asin file>

#Your Amazon developer's token
my $dev_token='insert developer token';

#Your Amazon affiliate tag
my $af_tag='insert affiliate tag';

#A Random Sku Suffix
my $sku = "SKU";

#Take the query from the command-line
my $asinfile =shift @ARGV or die "Usage:perl create_bulk.pl <asin file>\n";

#Use the XML::Parser Perl module
use strict;
use XML::Simple;
use LWP::Simple;

#Open output file for writing, and set column headers
open(BULKFILE, ">bulkfile.tab");
print BULKFILE 
"product-id\tauthor\ttitle\tpublisher\tpub-date\tbinding\tsku\tprice\[RETURN]
titem-condition\n";

#Loop through the ASINs, Looking up details
open(ASINFILE, "<".$asinfile);
while(<ASINFILE>) {
    my($asin) = $_;
    chomp($asin);
   
    #Assemble the URL
    my $url = "http://xml.amazon.com/onca/xml3?" . 
           "t=" . $af_tag . 
           "&dev-t=" . $dev_token .
           "&type=heavy" .
           "&f=xml" .
           "&AsinSearch=" . $asin,
           "&offer=used";
    
    my $content = get($url);
    die "Amazon service unavailable." unless $content;
    
    my $xmlsimple = XML::Simple->new('forcearray' => 1);
    my $response = $xmlsimple->XMLin($content);
    foreach my $result (@{$response->{Details}}) {
      #Print out the main bits of each result
      print BULKFILE
      $result->{Asin}[0] . "\t",
      $result->{Authors}[0]->{Author}[0]||$result->{Artists}[0]->[RETURN]
{Artist}[0]||"n/a",
      "\t" . $result->{ProductName}[0],
      "\t" . $result->{Manufacturer}[0],
      "\t" . $result->{ReleaseDate}[0],
      "\t" . $result->{Media}[0],
      "\t" . $asin . "-" . $sku;
      print "\nSet Price ",
      "(around ".$result->{UsedPrice}[0].")",
      " for\n",
      $result->{ProductName}[0].": ";
      chomp(my $price = <STDIN>);
      print BULKFILE "\t".$price."\t2\n";
    }
}
close(BULKFILE);

Note that the Web Services call uses the offer=used option so the product includes information related to used items, in this case <UsedPrice>. This information helps you determine how to price your item. This script could be combined with finding average prices [Hack #53] to provide even more pricing information.

Running the Hack

The first thing you need in order to run this script is a text file with the ASINs of products you’d like to sell. Create a file called asin.txt with each ASIN on its own line, like so:

0596004478
B000002UB3

Then run create_bulk.pl from the command line, passing the name of the ASIN file:

               perl create_bulk.pl asin.txt

As you run the script, it will contact Amazon via their Web Services API and collect information about the book. You’ll be prompted to enter your selling price, and the script will display the current lowest used price for the book at this time to give you an idea of what it’s selling for. The script will then create a file called bulkfile.tab that you can upload to Amazon.

Uploading the File

To upload bulkfile.tab to Amazon, visit your seller profile (http://www.amazon.com/seller-account/) and click “List single items or upload multiple items.” Choose “Book Loader” from the righthand, multiple-item column.

You’ll also need to set a few options on the upload form shown in Figure 4-6. The file type is “Standard Book”; you can read more about the format at Amazon’s help page for the Book Loader format (http://www.amazon.com/exec/obidos/tg/browse/-/1161328/). Select the upload option as “Add/Modify/Delete” and click “Browse . . . " to find bulkfile.tab on your local filesystem.

Book Loader upload form

Figure 4-6. Book Loader upload form

Once your file is uploaded, it takes Amazon some time to process the file— the bigger your file, the more time it takes. You can check its status and see its eventual results by clicking “Review your Inventory Uploads” from your seller’s account home page (http://www.amazon.com/seller-account/). If something went wrong, Amazon will spell out the errors in detail. If everything went right, all of your items will be listed for sale on Amazon!

Get Amazon 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.