# php_api
**Repository Path**: wengo/php_api
## Basic Information
- **Project Name**: php_api
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-01-20
- **Last Updated**: 2024-11-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README

Keepa API Framework
==============================
This framework is intended for users of the Keepa API.
Requirements
==============================
All needed requirements (php version/external libraries) you find in can find in [composer.json](https://github.com/keepacom/php_api/blob/master/composer.json) or on [packagist](https://packagist.org/packages/keepa/php_api)
Features
--------
* Parses API response to easy to use PHP objects
* Provides methods that facilitate the work with price history data
Composer
-----
```bash
composer require keepa/php_api:*
```
Quick Example
==============
Make an API request
---------------------------
```php
sendRequestWithRetry($r);
switch ($response->status) {
case ResponseStatus::OK:
// iterate over received product information
foreach ($response->products as $product){
if ($product->productType == ProductType::STANDARD || $product->productType == ProductType::DOWNLOADABLE) {
//get basic data of product and print to stdout
$currentAmazonPrice = ProductAnalyzer::getLast($product->csv[CSVType::AMAZON], CSVTypeWrapper::getCSVTypeFromIndex(CSVType::AMAZON));
//check if the product is in stock -1 -> out of stock
if ($currentAmazonPrice == -1) {
echo sprintf("%s %s is currently not sold by Amazon (out of stock) %s",$product->asin,$product->title,PHP_EOL);
} else {
echo sprintf("%s %s Current Amazon Price: %s %s",$product->asin,$product->title,$currentAmazonPrice,PHP_EOL);
}
// get weighted mean of the last 90 days for Amazon
$weightedMean90days = ProductAnalyzer::calcWeightedMean($product->csv[CSVType::AMAZON], KeepaTime::nowMinutes(),90, CSVTypeWrapper::getCSVTypeFromIndex(CSVType::AMAZON));
} else {
}
}
break;
default:
print_r($response);
}
```