|
| 1 | +# Migration guide |
| 2 | + |
| 3 | +This guide explains how to proceed with the migration from version 3.x to version 4.x of your current code. |
| 4 | +If you are still using the old version, it is highly recommended to update, since you wont get any future |
| 5 | +updates nor new features. |
| 6 | + |
| 7 | +## Changelog summary |
| 8 | + |
| 9 | +- Added type hinting to help you code. |
| 10 | +- Added compatibility with all arguments from the official API. |
| 11 | +- Now the full information from the API is returned, instead of a trimmed version. |
| 12 | +- Added custom exceptions to help with error handling. |
| 13 | +- Added models for some attributes. |
| 14 | +- Adjusted all methods and models to meet Amazon API standards. |
| 15 | +- Changed module name from amazon to amazon_paapi to avoid module clashes. |
| 16 | +- Compatibility with Python 3.6 or later. |
| 17 | + |
| 18 | +## How to upgrade? |
| 19 | + |
| 20 | +Upgrading to the last version of this module is as easy as running this pip command: |
| 21 | + |
| 22 | + pip install python-amazon-paapi --upgrade |
| 23 | + |
| 24 | +## What should I change in my current code? |
| 25 | + |
| 26 | +### Imports |
| 27 | + |
| 28 | +First of all, you should change your import of the AmazonApi class: |
| 29 | + |
| 30 | +```python |
| 31 | +from amazon.paapi import AmazonApi -> from amazon_paapi import AmazonApi |
| 32 | +from amazon.tools import get_asin -> from amazon_paapi import get_asin |
| 33 | +``` |
| 34 | + |
| 35 | +### Methods |
| 36 | + |
| 37 | +Some of the methods has been renamed and the parameters has changed to follow the official Amazon API standards. |
| 38 | +So in order to adapt your code, you should first update your methods as follow: |
| 39 | + |
| 40 | +```python |
| 41 | +get_product() -> get_items() |
| 42 | +get_products() -> get_items() |
| 43 | +search_products() -> search_items() |
| 44 | +get_browsenodes() -> get_browse_nodes() |
| 45 | +``` |
| 46 | + |
| 47 | +As you can check, `get_product` has been deprecated and now `get_items` is also used for getting only one result. |
| 48 | +So if you were using this method, you should keep in mind that the new method will return an array containing the |
| 49 | +result. An easy way of handling this could be: |
| 50 | + |
| 51 | +```python |
| 52 | +result = get_product(asin) -> result = get_items(asin)[0] |
| 53 | +``` |
| 54 | + |
| 55 | +Regarding parameters, you can check the [AmazonApi documentation](/amazon_paapi) for the complete reference. |
| 56 | + |
| 57 | +### Results |
| 58 | + |
| 59 | +Results has been changed from previous version, so you will need to adapt how you process them. This change |
| 60 | +follows the official Amazon Product Advertising API documentation, so you can |
| 61 | +[check it](https://webservices.amazon.com/paapi5/documentation/operations.html) for reference. Just note that |
| 62 | +documentation uses `CamelCase` names, but this module uses `snake_case`: |
| 63 | + |
| 64 | + ItemInfo.ContentInfo -> item_info.content_info |
| 65 | + Offers.Listings.Price -> offers.listings.price |
| 66 | + |
| 67 | +Type hints has been added to the new version, so it is highly recommended to use an IDE that includes code |
| 68 | +completion features, like [Visual Studio Code](https://code.visualstudio.com/). |
| 69 | + |
| 70 | +### Throttling |
| 71 | + |
| 72 | +Throttling parameter now represents the seconds to wait between API calls instead of the frequency. So make sure |
| 73 | +to adapt the value to your needs. |
| 74 | + |
| 75 | +```python |
| 76 | +amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=4) # Makes 1 request every 4 seconds |
| 77 | +amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=0) # No wait time between requests |
| 78 | +``` |
| 79 | + |
| 80 | +### Serializer for Django |
| 81 | + |
| 82 | +The serializer for Django is not available for this new version. If you want to help with the migration, send a |
| 83 | +pull request and will be added on future updates. |
| 84 | + |
| 85 | +### I need more help |
| 86 | + |
| 87 | +You can always ask for help in our [Telegram group](https://t.me/PythonAmazonPAAPI) or raise an issue on |
| 88 | +[Github](https://github.com/sergioteula/python-amazon-paapi/issues) for help. If you find that this |
| 89 | +guide could be improved somehow, feel free to send a pull request with your changes. |
0 commit comments