Best Programming Practices
Topics
The following checklist of best practices describes how you can increase the effectiveness of your Product Advertising API (Product Advertising API) 4.0 applications.
Read the Product Advertising API Terms and Conditions
The Product Advertising API Terms and Conditions spell out in detail the limitations that Amazon enforces on all Product Advertising API applications. The thrust of all Product Advertising API applications should be to direct sales to Amazon and thus earn Associate sales commissions. If your application is designed around another purpose, please reconsider and make sure your proposed Product Advertising API application falls within the guidelines of the Product Advertising API Terms and Conditions. Applications that do not meet the Product Advertising API Terms and Conditions will be blocked from accessing Product Advertising API.
Use the Latest API Version
Product Advertising API makes frequent releases. Each release either adds functionality or increases the accuracy, speed, and stability of Product Advertising API. Most releases do all of these. Go to http://aws.amazon.com/resources frequently for documentation about the latest release.
To use the latest version of the API, you must include the
Version
parameter in your requests. Otherwise, Product Advertising API uses the default
API version, which is from 2005-10-05.
Product Advertising API 3.0 has been deprecated and will be shut down at the end of March 2008. Make sure you develop against Product Advertising API 4.0.
Understand Available Operations
Product Advertising API provides many different operations to facilitate product discovery. Using the right operations can dramatically enhance your customer’s shopping experience and increase your Associate commissions. See the API Reference for a full description of all Product Advertising API operations. Some enable you to:
Task | Operations |
---|---|
Find products and categories |
ItemSearch ,
ItemLookup , and
BrowseNodeLookup
|
Find similar items |
SimilarityLookup ,
TagLookup
|
View wishlists and registries |
ListLookup
|
Provide shopping cart functionality for your application or web site |
CartCreate ,
CartAdd ,
CartModify , and
CartGet
|
Use the Right Response Group
One of the great features of Product Advertising API is the control you have over the amount of information returned in responses. A response group is a collection of data returned by Product Advertising API. Product Advertising API has over 55 response groups, each serving a different need. So, you can get exactly the information you need and no more.
We recommend that you specify response groups that return only the information your application needs. Response groups, such as Large, ItemAttributes, and MerchantItemAttributes, return lots of data. Such large data sets sometimes incur performance penalties both in Product Advertising API fulfilling the request and in your application’s processing of the response.
Use Your Associate Tag in Product Advertising API Requests
To earn commissions for selling Amazon items, you must register with Amazon as an Associate. Go to http://amazon.com/associates. In return, you receive an Associate tag, which identifies you. By including your Associate tag in each Product Advertising API request, you receive commissions for customer purchases.
Amazon also uses your Associate tag to monitor your use of Product Advertising API, which helps us determine how to improve our web service.
Handling Errors
Make sure your application handles errors gracefully. One way to do that is to check
the status of the
IsValid
element.
IsValid
is returned with every request. If its value is “False,” there will be an error message
with a description of why your request was not valid.
It’s generally a good practice to log any unexpected error that is returned by Product Advertising API. Errors are returned with an error code and message. The code is a descriptive string that identifies the error. The error message is a more ‘human friendly’ message that can be displayed to your customers. Your application should be able to handle expected error messages.
Your application, for example, should display error messages that are meaningful to the customer. For example, when Product Advertising API responds with the error, “AWS.ECommerceService.NoExactMatches,” your application should display an explanation, such as, “We did not find any matches for your request.”
If your application exceeds the number of allowed requests submitted per second, Product Advertising API returns a 503 error, which means that Product Advertising API is restricting the number of requests it is processing from your application. The Product Advertising API Terms and Conditions outline the number of allowed requests permitted per second.
Use Caches Carefully
It is against the Product Advertising API Terms and Conditions to cache customer information derived from Amazon.
You can enhance the performance of your application by caching identifiers, such as
the
CartId
,
HMAC
, and
PurchaseURL
.
Use the Correct AWSAccessKeyId
To become an Product Advertising API developer, you must register with Amazon.
Go to
http://aws.amazon.com
and create a web service account. Your account contains an
AWSAccessKeyId
and a
SecretKey
. Every Product Advertising API request you submit
must include the
AWSAccessKeyId
. Because your account is linked to your e-mail
address, Amazon can contact you easily
Community Forums
Product Advertising API has an active and passionate developer community. It’s a great place to get API questions answered or share ideas with other developers. To join, go to http://developer.amazonwebservices.com/connect/forum.jspa?forumID=9