tags:

views:

283

answers:

3

I have a 10 digit string being passed to me, and I want to verify that it is a valid ASIN before doing more processing and/or redirection.

I know that a non ISBN ASIN will always be non-numeric and 10 characters in length

I just want to be able to tell if the item being passed is a valid ASIN or is it just a search string after I have already eliminated that it could be a ISBN.

For example "SOUNDBOARD" is a search term while "B000J5XS3C" is an ASIN and "1412775884" is an ISBN.

Is there a lightweight way to check ASIN?

A: 

maybe you could check on the amazon site whether the ASIN exists.

http://www.amazon.com/dp/YOUR10DIGITASIN

this URL return a http-statuscode=200 when the product exists and a 404 if that was not a valid ASIN.

flurin
Yeah, I was thinking about that but wasn't sure if Amazon would want me to hit the site that way and generate possibly thousands of 404 errors. Guess I should ask them =)
RAD Moose
This worked, except note that some returned a 301 response. However, this seems to be outside of the TOS for Amazon's site. =/
RAD Moose
A: 

Did you know that Amazon offers an API, including an Amazon Associates Web Service, that allows you to interactive programatically with Amazon. I suspect that will solve your problem (in some fashion). Check out the Amazon Web Services home page for more info.

Brian Agnew
Yes, the Product Advertising API (which is not listed in the AWS home page but is linked via the Amazon Associates area) has replaced the Amazon Associates Web Service. It requires a bit of overhead, and I would have to cache any requests so as to not make duplicate requests within a certain time period. It looks like this might be the only 'official' way (although flurin's alternative is a lot easier.)
RAD Moose
The caching requirement does not seem to be in place for this use of the Product Advertisng API.
RAD Moose
A: 

"this URL return a http-statuscode=200 when the product exists and a 404 if that was not a valid ASIN."

this will NOT work, since according to the docs ASINs are region specific (check it for yourself if you don't believe). you can only verify an asin from - let's say - amazon.co.uk at amazon.co.uk, so you also have to know whre the ASIN comes from.

however, in your case you're better off having three input fields - one for each search. or (much better) one field an three radio buttons. alternatively, you could check the string angainst a dictionary... but guessing is alsways VERY bad engineering.

moreover, there is no lightweight way to check an asin for validity

dsa