Browse and Search Categories with Browse Nodes

Use browse node IDs to find books based on categories.

Just as Amazon has alphanumeric IDs for every item they sell, they also have ID numbers representing each subject area to which items belong. Once you know the browse node IDs for subject areas you’re interested in, you can bypass the standard search forms and perform narrow, specialized searches from a URL.

Finding Browse Node IDs

The first trick is finding the browse node IDs. They’re not quite as easy to come by as ASINs because they don’t appear in URLs as frequently. They also don’t seem to follow any logical pattern, so there’s no way to guess. Instead you can browse the “category tree” that Amazon has made available through their Associates program. You don’t have to be an associate to browse the tree, however; you can reach it at http://associates.amazon.com/exec/panama/associates/resources/build-links/amazon-recommends/browse-bestsellers.html.

Once at this page you’ll see a list of the highest product category levels: Baby, Books, Camera, Cell Phones, and so on. Click Books and you’ll start to see browse node codes in the URL; in this case:

http://associates.amazon.com/exec/panama/associates/resources/build-links/[RETURN]
amazon-recommends/browse-bestsellers.html/086-9645301-8693838?t=&node=1000
               [RETURN]
&mode=browse-books

The only section we’re concerned with is the node= and its value. The node here is 1000 and represents all books. On this page the categories are refined further under books: Arts & Photography, Biographies & Memoirs, Business & Investing, etc. Click on the entry “Science Fiction & Fantasy.” Once again you’ll see a new node value in the URL, 25. You can continue to drill this way and find IDs. As you do so, you’ll soon find yourself a few levels deep, for example, All Products Books Subjects Science Fiction & Fantasy Fantasy Magic & Wizards. Checking the URL, the node ID in this case is 16205.

Warning

Browse node IDs are constantly in flux. As product hierarchies change and evolve, the browse nodes evolve along with them. Remember that browse node IDs are temporary guides, not permanent markers. It’s a good idea to frequently check to make sure any browse node IDs you’re using are still being used by Amazon.

Not all browse node IDs are available through this interface, but it’s a good place to start looking for them.

Perform a Keyword Search Within a Browse Node

If you’d like to limit a search to a narrowly defined category, you can do so through the URL if you know the browse node. As with finding product detail pages, it’s just a matter of knowing the proper URL patterns (supplied by Bruce Bracken and James Crowley at Amazon) and filling in values in the proper places. Using our previous example, we can perform a search for “merlin” inside of browse node 16205, “Magic & Wizards.” The URL is:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=merlin&field-browse=16205

Instead of finding all products across every category with the keyword “merlin”, this URL shows us only those books within a specific category.

You can also search for multiple keywords by separating them with punctuation. The pipe symbol (|) means “or,” and a comma (,) means “and.” So if you wanted to find every book within “Magic & Wizards” that contains either “king” or “merlin”, separate the terms in the URL like so:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=merlin|king&field-browse=16205

If you’d like to find every book that has both terms:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=merlin,king&field-browse=16205

Both the “or” and “and” operators also work if you want to browse with multiple browse node codes. Say you want to list books that contain the keyword “merlin” in both the “Magic & Wizards” (16205) category or “Epic Fantasy” (16197) category. You would combine them with the pipe:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=merlin&field-browse=16205|16197

If you want to find books that are specifically listed in both of those subject areas, you would use the “and” operation with a comma:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=merlin&field-browse=16205,16197

Find Every Item Within a Browse Node

Instead of narrowing down your search results, suppose you’d like to see every product within a specific category. The URL is the same as the keyword search; you just replace the keyword with a dash (-) followed by any string of characters. So the following URL would return every book within the “Magic & Wizards” category:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=-junk&field-browse=16205

Sort Your Browse Node Search Results

By default, the search results for any of the URLs above are returned in the order of “featured items”—those items Amazon most wants you to know about. You could always re-sort your results with the drop-down menu Amazon provides, as shown in Figure 1-14.

Sorting Amazon search results

Figure 1-14. Sorting Amazon search results

But you can save yourself a step by sorting results in your initial request. The rank variable allows you to specify the sort. The values available for books are summarized in Table 1-2.

Table 1-2. Specifying sort order using the rank URL variable

Rank value

Sort order

pmrank

Featured Items

salesrank

Best-Selling

reviewrank

Average Customer Review

pricerank

Price (Low to High)

-pricerank

Price (High to Low)

daterank

Publication Date

titlerank

Alphabetical (A-Z)

-titlerank

Alphabetical (Z-A)

All you need to do is append the sort method to the end of the URL. To get every item from within the “Magic & Wizards” browse node, sorted by publication date, use the following URL:

http://amazon.com/exec/obidos/search-handle-url/index=books[RETURN]
&field-keywords=-junk&field-browse=16205&rank=daterank

Tip

Each variable/value pair in a URL is separated by ampersands (&). If you’re experiencing problems when you add a new variable, make sure it’s separated from the previous variable/value pair with an &.

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.