{"id":27248163,"url":"https://github.com/sanjayojha/amazon-paapi5-php-sdk","last_synced_at":"2025-04-10T23:07:55.626Z","repository":{"id":48272847,"uuid":"238167665","full_name":"sanjayojha/amazon-paapi5-php-sdk","owner":"sanjayojha","description":"Official PHP SDK to access the Amazon Product Advertising API 5.0 (paapi5)","archived":false,"fork":false,"pushed_at":"2020-02-04T09:55:27.000Z","size":61,"stargazers_count":4,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T23:07:50.422Z","etag":null,"topics":["amazon","api","paapi5","php","sdk"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/sanjayojha.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}},"created_at":"2020-02-04T09:25:13.000Z","updated_at":"2021-10-18T01:21:24.000Z","dependencies_parsed_at":"2022-08-30T15:01:31.441Z","dependency_job_id":null,"html_url":"https://github.com/sanjayojha/amazon-paapi5-php-sdk","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjayojha%2Famazon-paapi5-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjayojha%2Famazon-paapi5-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjayojha%2Famazon-paapi5-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjayojha%2Famazon-paapi5-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanjayojha","download_url":"https://codeload.github.com/sanjayojha/amazon-paapi5-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312155,"owners_count":21082638,"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":["amazon","api","paapi5","php","sdk"],"created_at":"2025-04-10T23:07:55.105Z","updated_at":"2025-04-10T23:07:55.595Z","avatar_url":"https://github.com/sanjayojha.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# amazon-paapi5-php-sdk\nOfficial PHP SDK to access the Amazon [Product Advertising API](https://webservices.amazon.com/paapi5/documentation/index.html) 5.0 (paapi5)\n\n## Installation\n\nThe Product Advertising API PHP SDK can be installed with [Composer](https://getcomposer.org/). Run this command:\n\n```sh\n$ composer require sanjayojha/amazon-paapi5-php-sdk\n```\n## Usage\n\nSimple example for searching items.\n\n```php\n\u003c?php\n\n/**\n * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\").\n * You may not use this file except in compliance with the License.\n * A copy of the License is located at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * or in the \"license\" file accompanying this file. This file is distributed\n * on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied. See the License for the specific language governing\n * permissions and limitations under the License.\n */\n\n/*\n * ProductAdvertisingAPI\n *\n * https://webservices.amazon.com/paapi5/documentation/index.html\n */\n\n/*\n * This sample code snippet is for ProductAdvertisingAPI 5.0's SearchItems API\n *\n * For more details, refer: https://webservices.amazon.com/paapi5/documentation/search-items.html\n */\n\nuse Amazon\\ProductAdvertisingAPI\\v1\\com\\amazon\\paapi5\\v1\\api\\DefaultApi;\nuse Amazon\\ProductAdvertisingAPI\\v1\\ApiException;\nuse Amazon\\ProductAdvertisingAPI\\v1\\Configuration;\nuse Amazon\\ProductAdvertisingAPI\\v1\\com\\amazon\\paapi5\\v1\\SearchItemsRequest;\nuse Amazon\\ProductAdvertisingAPI\\v1\\com\\amazon\\paapi5\\v1\\SearchItemsResource;\nuse Amazon\\ProductAdvertisingAPI\\v1\\com\\amazon\\paapi5\\v1\\PartnerType;\nuse Amazon\\ProductAdvertisingAPI\\v1\\com\\amazon\\paapi5\\v1\\ProductAdvertisingAPIClientException;\n\nrequire_once(__DIR__ . '/vendor/autoload.php'); // change path as needed\n\n\n$config = new Configuration();\n\n/*\n * Add your credentials\n * Please add your access key here\n */\n$config-\u003esetAccessKey('\u003cYOUR ACCESS KEY\u003e');\n# Please add your secret key here\n$config-\u003esetSecretKey('\u003cYOUR SECRET KEY\u003e');\n\n# Please add your partner tag (store/tracking id) here\n$partnerTag = '\u003cYOUR PARTNER TAG\u003e';\n\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 */\n$config-\u003esetHost('webservices.amazon.com');\n$config-\u003esetRegion('us-east-1');\n\n$apiInstance = new DefaultApi(\n/*\n * If you want use custom http client, pass your client which implements `GuzzleHttp\\ClientInterface`.\n * This is optional, `GuzzleHttp\\Client` will be used as default.\n */\n    new GuzzleHttp\\Client(), $config);\n\n# Request initialization\n\n# Specify keywords\n$keyword = 'Harry Potter';\n\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 */\n$searchIndex = \"All\";\n\n# Specify item count to be returned in search result\n$itemCount = 1;\n\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 */\n$resources = array(\n    SearchItemsResource::ITEM_INFOTITLE,\n    SearchItemsResource::OFFERSLISTINGSPRICE);\n\n# Forming the request\n$searchItemsRequest = new SearchItemsRequest();\n$searchItemsRequest-\u003esetSearchIndex($searchIndex);\n$searchItemsRequest-\u003esetKeywords($keyword);\n$searchItemsRequest-\u003esetItemCount($itemCount);\n$searchItemsRequest-\u003esetPartnerTag($partnerTag);\n$searchItemsRequest-\u003esetPartnerType(PartnerType::ASSOCIATES);\n$searchItemsRequest-\u003esetResources($resources);\n\n# Validating request\n$invalidPropertyList = $searchItemsRequest-\u003elistInvalidProperties();\n$length = count($invalidPropertyList);\nif ($length \u003e 0) {\n    echo \"Error forming the request\", PHP_EOL;\n    foreach ($invalidPropertyList as $invalidProperty) {\n        echo $invalidProperty, PHP_EOL;\n    }\n    return;\n}\n\n# Sending the request\ntry {\n    $searchItemsResponse = $apiInstance-\u003esearchItems($searchItemsRequest);\n\n    echo 'API called successfully', PHP_EOL;\n    echo 'Complete Response: ', $searchItemsResponse, PHP_EOL;\n\n    # Parsing the response\n    if ($searchItemsResponse-\u003egetSearchResult() != null) {\n        echo 'Printing first item information in SearchResult:', PHP_EOL;\n        $item = $searchItemsResponse-\u003egetSearchResult()-\u003egetItems()[0];\n        if ($item != null) {\n            if ($item-\u003egetASIN() != null) {\n                echo \"ASIN: \", $item-\u003egetASIN(), PHP_EOL;\n            }\n            if ($item-\u003egetDetailPageURL() != null) {\n                echo \"DetailPageURL: \", $item-\u003egetDetailPageURL(), PHP_EOL;\n            }\n            if ($item-\u003egetItemInfo() != null\n                and $item-\u003egetItemInfo()-\u003egetTitle() != null\n                and $item-\u003egetItemInfo()-\u003egetTitle()-\u003egetDisplayValue() != null) {\n                echo \"Title: \", $item-\u003egetItemInfo()-\u003egetTitle()-\u003egetDisplayValue(), PHP_EOL;\n            }\n            if ($item-\u003egetOffers() != null\n                and $item-\u003egetOffers() != null\n                and $item-\u003egetOffers()-\u003egetListings() != null\n                and $item-\u003egetOffers()-\u003egetListings()[0]-\u003egetPrice() != null\n                and $item-\u003egetOffers()-\u003egetListings()[0]-\u003egetPrice()-\u003egetDisplayAmount() != null) {\n                echo \"Buying price: \", $item-\u003egetOffers()-\u003egetListings()[0]-\u003egetPrice()\n                    -\u003egetDisplayAmount(), PHP_EOL;\n            }\n        }\n    }\n    if ($searchItemsResponse-\u003egetErrors() != null) {\n        echo PHP_EOL, 'Printing Errors:', PHP_EOL, 'Printing first error object from list of errors', PHP_EOL;\n        echo 'Error code: ', $searchItemsResponse-\u003egetErrors()[0]-\u003egetCode(), PHP_EOL;\n        echo 'Error message: ', $searchItemsResponse-\u003egetErrors()[0]-\u003egetMessage(), PHP_EOL;\n    }\n} catch (ApiException $exception) {\n    echo \"Error calling PA-API 5.0!\", PHP_EOL;\n    echo \"HTTP Status Code: \", $exception-\u003egetCode(), PHP_EOL;\n    echo \"Error Message: \", $exception-\u003egetMessage(), PHP_EOL;\n    if ($exception-\u003egetResponseObject() instanceof ProductAdvertisingAPIClientException) {\n        $errors = $exception-\u003egetResponseObject()-\u003egetErrors();\n        foreach ($errors as $error) {\n            echo \"Error Type: \", $error-\u003egetCode(), PHP_EOL;\n            echo \"Error Message: \", $error-\u003egetMessage(), PHP_EOL;\n        }\n    } else {\n        echo \"Error response body: \", $exception-\u003egetResponseBody(), PHP_EOL;\n    }\n} catch (Exception $exception) {\n    echo \"Error Message: \", $exception-\u003egetMessage(), PHP_EOL;\n}\n```\n\nRead [Complete documentation](https://webservices.amazon.com/paapi5/documentation/with-sdk.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjayojha%2Famazon-paapi5-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanjayojha%2Famazon-paapi5-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjayojha%2Famazon-paapi5-php-sdk/lists"}