PHPackages                             sambo-search/sambo-search-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sambo-search/sambo-search-client

ActiveLibrary[API Development](/categories/api)

sambo-search/sambo-search-client
================================

PHP API Client for Sambo-Search API

0.2.1(1y ago)17MITPHPPHP &gt;=8.1

Since Jun 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Sambo-Search/sambo-search-client)[ Packagist](https://packagist.org/packages/sambo-search/sambo-search-client)[ RSS](/packages/sambo-search-sambo-search-client/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Sambo-Search PHP Client
=======================

[](#sambo-search-php-client)

[![Unit Tests](https://github.com/sambo-search/sambo-search-client/actions/workflows/ci.yml/badge.svg)](https://github.com/sambo-search/sambo-search-client/actions/workflows/ci.yml/badge.svg)

Synopsis
--------

[](#synopsis)

This is a simple PHP client for the Sambo-Search API. It simplifies the usage of the API by providing many helper functions and easy access to the API suite.

Prerequisites
-------------

[](#prerequisites)

- PHP &gt;= 8.1
- Composer

Install
-------

[](#install)

Install via Composer:

```
composer require sambo-search/sambo-search-client
```

Usage
-----

[](#usage)

*If you are not sure where to find your shops' public key, open the Sambo-Search Dashboard and navigate to [Account &gt; Shops](https://dashboard.sambo-search.com/account/shops)*.

### Sending a simple search request

[](#sending-a-simple-search-request)

1. Create a new `Client` instance: ```
    $client = \SamboSearch\Client\Client::getInstance([
        'public_key' => ''
    ]);
    ```
2. Build your search request: ```
    $request = $client->buildSearchRequest();
    $request->setQuery('backpack') // Search query
        ->setFilter('color', 'Black'); // Filters
    ```
3. Send request and parse response: ```
    /** @var \SamboSearch\Client\Response\SearchResponse $response */
    $response = $client->send($request);

    $products = $response->getProducts();
    foreach ($products as $product) {
        echo 'ID: ' . $product->getId() . "\n";
        echo 'Name: ' . $product->getName() . "\n";
    }
    ```

Full example (same as from above, but with imports):

```
