# Best Programming Practices

The following best practices describe how you can increase the effectiveness of your Creators API applications.

### Read the Creators API License Agreement & Terms and Conditions

The Creators API License Agreement & Terms and Conditions spell out in detail the limitations that Amazon enforces on all Creators API applications. All Creators API applications should direct sales to Amazon and thus earn Associate fees. Application that do not have this purpose or do not meet other Creators API Terms and Conditions will be blocked from accessing Creators API.

### Use our SDK

Our SDK will help you integrate with Creators API quickly. It takes away all the heavy lifting from you including access token generation, request serialization and response de-serialization. It provides flexibility through allowing you to choose from different access methods based on your needs and preferences. Refer [using sdk](en-us/get-started/using-sdk.md) section for more details.

### Cache access tokens until they expire

Access tokens are valid for 1 hour (`expires_in: 3600`) and are designed to be reused across requests. Fetch a new token only when the current one is close to expiry — not on every API call. Share the cached token across all processes or containers using the same Client ID.

Re-fetching tokens per request will hit the v2.x Cognito [token endpoint rate limit](en-us/troubleshooting/error-codes-and-messages#token-endpoint-rate-limiting). The official [SDKs](en-us/get-started/using-sdk) handle token caching and renewal for you.

### Use your Partner tag correctly in Creators API requests

You must use the correct Partner tag when using Creators API. Incorrect information will lead to loss of Associate fees.

Required to earn advertising fees, your Partner tag uniquely identifies your Associate store and must be registered through the Amazon Associates program (see [Sign up as an Amazon Associate](en-us/onboarding/sign-up-as-an-amazon-associate)). This tag is included in each Creators API request and automatically added to all vended links. When customers use these links to visit Amazon and make qualifying purchases, you'll receive Associate fees. **Important: Alterations of any kind to vended links will lead to missing attribution and loss of Associate fees.** Amazon also uses your Partner tag to monitor API usage and adjust your access accordingly.

### Understand available operations, parameters and their usage

Creators API provides multiple [operations](en-us/api-reference/operations.md) to facilitate product discovery. Common and operation specific parameters allows you to provide inputs on expected response. Using the right operations and parameters can dramatically enhance your customer’s shopping experience and increase your Associate commissions.

### Use the right Resource

Creators API allows you to ask for specific information, reducing response time, payload size and processing time on your side. A [Resource](en-us/api-reference/resources.md) is a granular collection of data returned by Creators API. Creators API, when provided with list of Resources, will only return the information you seek. We recommend that you specify only the necessary Resources that return the information your application needs, which will optimize latency and improve your application response time.

### Use multiple ASINs and BrowseNodes in requests

Use multiple ASINs in [GetItems](en-us/api-reference/operations/get-items.md) and multiple BrowseNodeIds in [GetBrowseNodes](en-us/api-reference/operations/get-browse-nodes) operation requests to reduce the number of requests made to Creators API. This will help you increase throughput from API and optimally use the request limits allocated to you.

Example: You can request information of up to 10 ASINs in a single request with GetItems operation, instead of making 10 individual requests with 1 ASIN. Please refer to [GetItems Operation Guide](en-us/api-reference/operations/get-items.md) and [operations documentation](en-us/api-reference/operations.md) for more details.

### Apply fine-grained request rate controls

Creators API request allocations are given in transactions per second (TPS). To make optimal use of your allocation, you 
will need to spread out your calls over the course of a day. Consistent traffic sent over all 24 hours will maximize 
the number of calls that can be made each day.

This needs to be tightly controlled down to the second. If your system is sending more than the allocated TPS within 
any given second, those extra requests will be throttled.

### Use caches carefully

Cache plays a critical role in keeping call to Creators API under control and lead to faster response time for your application. Creators API responses can be cached on your end under the guidelines defined in the [License Agreement](en-us/license-agreement.md). It is against the Creators API Terms and Conditions to cache customer information derived from Amazon.

#### How to cache

Any caching mechanism of your preference can be used, which allows you to cache Fields/Nodes/Resources in Creators API response. Using cache would require defining time (Time To Live/TTL) for which these values are to be cached, they depend on Fields/Nodes/Resources as some of them are more volatile as compared to others.

Please refer following table to configure cache times for mentioned Fields/Nodes/Resources and their children.

| Fields/Nodes/Resources | Cache time (TTL) |
| :--- | :--- |
| Offers | 1 hour |
| BrowseNodeInfo | 1 hour |
| All other Fields/Nodes/Resources (example: BrowseNodes, DetailPageURL, Images, ItemInfo) | 1 day |

#### How to use cache

When your application receives a request, before making a Creators API call first check if all required resources are present in cache. If yes, serve request for your application using the cached information. If not, make the request to Creators API and use the response to serve your application request. Add response values for each of the requested Resources to cache with mentioned in the above cache time outs. For your next request, again check cache if some of resources required are present in cache. If some are and some are not make the request to Creators API for only the Resources missing in the cache. This will improve your application response time significantly.

### Handling web crawler traffic

Web crawlers can eat into your request rates. You can address them by using measures like robot.txt.

