- How do I install and set up caponica/amazon-paa in a Laravel project?
- Install via Composer with `composer require caponica/amazon-paa`, then configure AWS credentials (Access Key ID, Secret Key, and Associate Tag) in your `.env` file under `services.amazon.paa`. Bind the client to Laravel’s service container in a service provider for dependency injection.
- Which Laravel versions does this package support?
- The package is framework-agnostic but works seamlessly with Laravel 8+. For Laravel 9+, replace Guzzle with Laravel’s built-in HTTP client by extending the client class. No Laravel-specific dependencies exist, so it’s compatible with any modern Laravel version.
- What Amazon PAA endpoints does this package support out of the box?
- The package supports core endpoints like `ItemLookup`, `ItemSearch`, `CartCreate`, and `Offers` for fetching product details, prices, and promotional data. Advanced or niche endpoints (e.g., `BrowseNodeLookup`) may require custom extensions or direct API calls.
- How do I handle AWS Signature Version 4 authentication securely?
- Store your AWS credentials in Laravel’s `.env` file and restrict access via environment variables. Use IAM roles with least-privilege permissions for the PAA API. The package abstracts the signing process, but ensure your credentials are never hardcoded or exposed in logs.
- Does this package handle Amazon’s rate limits (e.g., 1 request/second for ItemSearch)?
- No, the package does not include built-in retry logic. Implement exponential backoff or queue delayed jobs (e.g., Laravel Queues) to manage rate limits. Monitor Amazon’s API responses for `ThrottledRequestError` and retry accordingly.
- Can I use this package for bulk product data fetching (e.g., 100+ items)?
- The package is not optimized for bulk operations. For high-volume requests, consider batching calls manually or using parallel processing with Laravel’s concurrency features. However, Amazon’s rate limits may still require queued or delayed execution.
- How do I customize error handling for Amazon-specific errors (e.g., InvalidParameterValue)?
- Extend the package’s error classes to map Amazon errors to Laravel exceptions. For example, catch `AmazonPaaException` and throw custom exceptions like `InvalidParameterException` with user-friendly messages. Log errors for observability.
- Is there built-in caching for API responses to reduce costs and improve performance?
- No, caching is not built into the package. Implement Laravel’s cache driver (e.g., Redis or file cache) to store responses for non-real-time use cases. Cache keys should include product identifiers and a TTL to respect Amazon’s data freshness requirements.
- What are the alternatives to caponica/amazon-paa for Laravel?
- Alternatives include the official AWS SDK for PHP (which is heavier) or community packages like `spatie/amazon-product-advertising-api`. However, this package stands out for its simplicity and focus on Laravel-friendly integration without external dependencies.
- How do I test this package in a Laravel application before production?
- Use Laravel’s HTTP testing tools to mock API responses or set up a staging environment with real AWS credentials (sandbox mode if available). Test edge cases like throttling, invalid parameters, and rate limits. Validate responses against Amazon’s API documentation.