{"id":21391848,"url":"https://github.com/gatsby-lee/paapi5-python-sdk","last_synced_at":"2025-03-16T13:25:59.394Z","repository":{"id":214929341,"uuid":"737684792","full_name":"Gatsby-Lee/paapi5-python-sdk","owner":"Gatsby-Lee","description":"Amazon Product Advertising API 5.0","archived":false,"fork":false,"pushed_at":"2024-01-01T06:57:48.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T01:13:34.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gatsby-Lee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-01T04:28:36.000Z","updated_at":"2024-01-01T04:34:07.000Z","dependencies_parsed_at":"2024-01-01T07:39:38.388Z","dependency_job_id":null,"html_url":"https://github.com/Gatsby-Lee/paapi5-python-sdk","commit_stats":null,"previous_names":["gatsby-lee/paapi5-python-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gatsby-Lee%2Fpaapi5-python-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gatsby-Lee%2Fpaapi5-python-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gatsby-Lee%2Fpaapi5-python-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gatsby-Lee%2Fpaapi5-python-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gatsby-Lee","download_url":"https://codeload.github.com/Gatsby-Lee/paapi5-python-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243873849,"owners_count":20361717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T13:38:08.698Z","updated_at":"2025-03-16T13:25:59.368Z","avatar_url":"https://github.com/Gatsby-Lee.png","language":"Python","readme":"# Product Advertising API 5.0 SDK for Python\n\n[![pypi version](http://img.shields.io/pypi/v/paapi5-python-sdk.svg?style=flat)](https://pypi.python.org/pypi/paapi5-python-sdk/)\n[![pypi downloads](https://img.shields.io/pypi/dm/paapi5-python-sdk.svg.svg?style=flat)](https://pypi.python.org/pypi/paapi5-python-sdk/)\n\nThis repository contains the official Product Advertising API 5.0 Python SDK called **paapi5-python-sdk** that allows you to access the [Product Advertising API](https://webservices.amazon.com/paapi5/documentation/index.html) from your Python app.\n\n## Requirements\n\nPython 2.7 and 3.4+\n\n## Installation \u0026 Usage\n\n### pip install\n\nYou can directly install it from pip using:\n\n```sh\npip install paapi5-python-sdk\n```\n\nOr, you may also install directly from Github\n\n```sh\npip install git+https://github.com/amzn/paapi5-python-sdk.git\n```\n\n(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/amzn/paapi5-python-sdk.git`)\n\nThen import the package:\n\n```python\nimport paapi5_python_sdk\n```\n\n### Setuptools\n\nInstall via [Setuptools](http://pypi.python.org/pypi/setuptools).\n\n```sh\npython setup.py install --user\n```\n\n(or `sudo python setup.py install` to install the package for all users)\n\nThen import the package:\n\n```python\nimport paapi5_python_sdk\n```\n\n## Getting Started\n\nPlease follow the [installation procedure](#installation--usage) and then run the following:\n\nSimple example for [SearchItems](https://webservices.amazon.com/paapi5/documentation/search-items.html) to discover Amazon products with the keyword 'Harry Potter' in Books category:\n\n```python\nfrom paapi5_python_sdk.api.default_api import DefaultApi\nfrom paapi5_python_sdk.models.partner_type import PartnerType\nfrom paapi5_python_sdk.rest import ApiException\nfrom paapi5_python_sdk.models.search_items_request import SearchItemsRequest\nfrom paapi5_python_sdk.models.search_items_resource import SearchItemsResource\n\n\ndef search_items():\n\n    \"\"\" Following are your credentials \"\"\"\n    \"\"\" Please add your access key here \"\"\"\n    access_key = \"\u003cYOUR ACCESS KEY\u003e\"\n\n    \"\"\" Please add your secret key here \"\"\"\n    secret_key = \"\u003cYOUR SECRET KEY\u003e\"\n\n    \"\"\" Please add your partner tag (store/tracking id) here \"\"\"\n    partner_tag = \"\u003cYOUR PARTNER TAG\u003e\"\n\n    \"\"\" PAAPI host and region to which you want to send request \"\"\"\n    \"\"\" For more details refer: https://webservices.amazon.com/paapi5/documentation/common-request-parameters.html#host-and-region\"\"\"\n    host = \"webservices.amazon.com\"\n    region = \"us-east-1\"\n\n    \"\"\" API declaration \"\"\"\n    default_api = DefaultApi(\n        access_key=access_key, secret_key=secret_key, host=host, region=region\n    )\n\n    \"\"\" Request initialization\"\"\"\n\n    \"\"\" Specify keywords \"\"\"\n    keywords = \"Harry Potter\"\n\n    \"\"\" Specify the category in which search request is to be made \"\"\"\n    \"\"\" For more details, refer: https://webservices.amazon.com/paapi5/documentation/use-cases/organization-of-items-on-amazon/search-index.html \"\"\"\n    search_index = \"Books\"\n\n    \"\"\" Specify item count to be returned in search result \"\"\"\n    item_count = 1\n\n    \"\"\" Choose resources you want from SearchItemsResource enum \"\"\"\n    \"\"\" For more details, refer: https://webservices.amazon.com/paapi5/documentation/search-items.html#resources-parameter \"\"\"\n    search_items_resource = [\n        SearchItemsResource.ITEMINFO_TITLE,\n        SearchItemsResource.OFFERS_LISTINGS_PRICE,\n    ]\n\n    \"\"\" Forming request \"\"\"\n    try:\n        search_items_request = SearchItemsRequest(\n            partner_tag=partner_tag,\n            partner_type=PartnerType.ASSOCIATES,\n            keywords=keywords,\n            search_index=search_index,\n            item_count=item_count,\n            resources=search_items_resource,\n        )\n    except ValueError as exception:\n        print(\"Error in forming SearchItemsRequest: \", exception)\n        return\n\n    try:\n        \"\"\" Sending request \"\"\"\n        response = default_api.search_items(search_items_request)\n\n        print(\"API called Successfully\")\n        print(\"Complete Response:\", response)\n\n        \"\"\" Parse response \"\"\"\n        if response.search_result is not None:\n            print(\"Printing first item information in SearchResult:\")\n            item_0 = response.search_result.items[0]\n            if item_0 is not None:\n                if item_0.asin is not None:\n                    print(\"ASIN: \", item_0.asin)\n                if item_0.detail_page_url is not None:\n                    print(\"DetailPageURL: \", item_0.detail_page_url)\n                if (\n                    item_0.item_info is not None\n                    and item_0.item_info.title is not None\n                    and item_0.item_info.title.display_value is not None\n                ):\n                    print(\"Title: \", item_0.item_info.title.display_value)\n                if (\n                    item_0.offers is not None\n                    and item_0.offers.listings is not None\n                    and item_0.offers.listings[0].price is not None\n                    and item_0.offers.listings[0].price.display_amount is not None\n                ):\n                    print(\n                        \"Buying Price: \", item_0.offers.listings[0].price.display_amount\n                    )\n        if response.errors is not None:\n            print(\"\\nPrinting Errors:\\nPrinting First Error Object from list of Errors\")\n            print(\"Error code\", response.errors[0].code)\n            print(\"Error message\", response.errors[0].message)\n\n    except ApiException as exception:\n        print(\"Error calling PA-API 5.0!\")\n        print(\"Status code:\", exception.status)\n        print(\"Errors :\", exception.body)\n        print(\"Request ID:\", exception.headers[\"x-amzn-RequestId\"])\n\n    except TypeError as exception:\n        print(\"TypeError :\", exception)\n\n    except ValueError as exception:\n        print(\"ValueError :\", exception)\n\n    except Exception as exception:\n        print(\"Exception :\", exception)\n\nsearch_items()\n```\n\nComplete documentation, installation instructions, and examples are available [here](https://webservices.amazon.com/paapi5/documentation/index.html).\n\n## License\n\nThis SDK is distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), see LICENSE.txt and NOTICE.txt for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgatsby-lee%2Fpaapi5-python-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgatsby-lee%2Fpaapi5-python-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgatsby-lee%2Fpaapi5-python-sdk/lists"}