Amazon is the third major example in this chapter. Not only is Amazon a popular e-commerce site, but it is an e-commerce platform this is easily remixed with other content. Although you will study the Amazon APIs later in this book, you’ll focus here on Amazon from the view of an end user. Moreover, the goal in this section is not to learn all the features of Amazon but rather to study its URL language.
Note | |
---|---|
Although Amazon sells merchandise other than books, I use books in my examples. Moreover, I focus on Amazon, the site geared to the United States instead of Amazon’s network of sites aimed to customers outside the United States. |
The strategy you’ll follow here is to discern the key entities of the Amazon site through a combination of using and experimenting with the site, sifting through documentation, and seeing what other users have done. You will see that figuring out the structure of Amazon’s URLs is not as straightforward as working through the Flickr URL language. Since some of the conclusions here are not supported by official documentation from Amazon, I cannot make any long-term guarantee behind the URLs.
It doesn’t take much analysis of Amazon to see that the central entity of the site is an item for sale (akin to a photo in Flickr). By looking at the URL of a given item and looking throughout a page describing it, you will see that Amazon uses an Amazon Standard Identification Number (ASIN) as a unique identifier for its products.[40]
http://www.amazon.com/gp/product/{ASIN}
Take for instance, Czesl´aw Mil´osz’s New and Collected Poems (paperback edition), which has an ISBN-10 of 0060514485. You can find it on Amazon here:
http://www.amazon.com/gp/product/0060514485
It is important to know that the way to link to Amazon has changed in the past and will likely continue to change. For instance, you can also link to the book with this:
http://www.amazon.com/exec/obidos/ASIN/0060514485
or even with this shorter form:
http://amazon.com/o/ASIN/0060514485
Using this syntax would ideally be founded on some official documentation from Amazon. Where would you find definitive documentation on how to structure a link to a product of a given ASIN? My search through the Amazon developers’ site led to the technical documentation,[41][42][43]
Let’s apply this approach to other functions of Amazon. For instance, can you generate a URL for a full-text search? Go to Amazon, and enter your favorite search term. Take for example, flower
. When I hit Submit, I got the following URL:
If I did the search again, say in a different browser, I got another URL:
Notice where things are similar and where they are different. Looking for what’s common (the http://amazon.com/s
prefix and the ?url=search-alias%3Daps&field-keywords=?
flower&Go.x=0&Go.y=0&Go=Go
argument), I eliminated the sections that were different to get the following:
http://amazon.com/s/?url=search-alias%3Daps&field-keywords=flower&Go.x=0&Go.y=0&Go=Go
This URL seemed to work fine. You can even eliminate &Go.x=0&Go.y=0&Go=Go
to boil the request down to this:
http://amazon.com/s/?url=search-alias%3Daps&field-keywords=flower
So, how do you limit the search to books? Going to Amazon, selecting the Book section, and using the flower
keyword, you can get to the following URL:
Stripping away the parameters as before gave me this:
http://amazon.com/s/?url=search-alias%3Dstripbooks&field-keywords=flower
This trick works for the other departments. For example, to do a search on flowers
in Home & Garden, use this:
http://amazon.com/s/?url=search-alias%3Dgarden&field-keywords=flower
Based on these experiments, I would conclude that the URL for searching for a keyword in a department is as follows:
http://amazon.com/s/?url=search-alias%3D{amazon-dept}&field-keywords={keyword}
Let’s run through the syntax of other organizational structures.
You can find the Wish List section at the following URL:
http://www.amazon.com/gp/registry/wishlist/
If you are logged in, you will see a list of your lists on the left. Look at the URL of one of the lists, which will look something like the one for my public wish list:
http://www.amazon.com/gp/registry/wishlist/1U5EXVPVS3WP5/ref=cm_wl_rlist_go/?102-5889202-4328156
Now look at another. I surmised that since the number on the right (102-5889202-4328156
) remained the same and the other number (1U5EXVPVS3WP5
) changed for each list, the unique 1U5EXVPVS3WP5
is the identifier for the list. You can point to a list using its list identifier by entering something similar to the following:
http://www.amazon.com/gp/registry/wishlist/1U5EXVPVS3WP5
Hence, you can conclude that the URL for a wish list is as follows:
http://www.amazon.com/gp/registry/wishlist/{wishlist-id}
Tags are a recent introduction to Amazon. You will see links like the following:
http://www.amazon.com/tag/czeslaw%20milosz/ref=tag_dp_ct/102-8204915-1347316
which can be reduced (following the strategy you took for other parts of Amazon) to this:
http://www.amazon.com/tag/czeslaw%20milosz/
The URL for books that correspond to a tag is as follows:
http://www.amazon.com/tag/{tag}/
In looking through the Browse Subject section of Amazon (http://www.amazon.com/?Subjects-Books/b/?ie=UTF8&node=1000
), you can find a link such as the following:
This refers to the Computers & Internet Section, which you can reduce to the following:
http://www.amazon.com/b/?ie=UTF8&node=5
from which you can conclude that the URL for a section is as follows:
http://www.amazon.com/b/?ie=UTF8&node={node-number}
Caution | |
---|---|
The fact that the node is specified by number corresponding to its order by alphabetical listing rather than a unique key makes me concerned about the long-term stability of the link. Will 5 always refer to computers, or if there is another section added that goes before it alphabetically, will the link break? |
There are plenty of other entities whose URL structures can be discerned, including the following:
Listmania lists:
http://www.amazon.com/lm/{list-mania-id}/
For example:
So You’d Like To guides:
http://www.amazon.com/gp/richpub/syltguides/fullview/{slltg-id}
For example:
http://www.amazon.com/gp/richpub/syltguides/fullview/3T3I3YDBG889B
Personal profiles:
http://www.amazon.com/gp/pdp/profile/{user-id}/
For example:
Similar items for a book:
http://amazon.com/sim/{ISBN-10}/1/ref=pd_sexpl_esi/
For example:
In Chapter 1, you already studied how the Amazon URL language is used by the LibraryLookup bookmarklet to mash up Amazon and library catalogs. Linking to Amazon resources by a tag enables tag-based mashups, which I will describe in Chapter 3.