PHP SDK

Last updated · Changelog · OpenAPI spec · Markdown

Our official PHP SDK provides easy integration for PHP applications and frameworks like Laravel, Symfony, and CodeIgniter.

  • View on GitHub
  • Packagist listing pending: install from the GitHub repository as shown below.

Installation

composer config repositories.shopsavvy vcs https://github.com/shopsavvy/sdk-php
composer require shopsavvy/shopsavvy-sdk-php

Quick Start

<?php
require_once 'vendor/autoload.php';

use ShopSavvy\Client;

// Create a new client
$client = new Client('ss_live_your_api_key_here');

// Get product details
$product = $client->getProductDetails('012345678901');
echo "Product: " . $product['data']['name'] . "\n";

// Get current offers
$offers = $client->getCurrentOffers('012345678901');
foreach ($offers['data'] as $offer) {
    echo $offer['retailer'] . ": $" . $offer['price'] . "\n";
}

// Get price history
$history = $client->getPriceHistory(
    '012345678901',
    '2024-01-01',
    '2024-01-31'
);

Laravel Integration

// config/services.php
'shopsavvy' => [
    'api_key' => env('SHOPSAVVY_API_KEY'),
],

// In your controller
use ShopSavvy\Client;

class ProductController extends Controller
{
    public function show($barcode)
    {
        $client = new Client(config('services.shopsavvy.api_key'));
        $product = $client->getProductDetails($barcode);

        return view('product.show', compact('product'));
    }
}

Features

  • PSR-4 autoloading
  • Laravel service provider
  • Guzzle HTTP client
  • Comprehensive error handling
  • Support for PHP 8.0+
  • Full PHPDoc documentation
Was this page helpful?