Fork Allegro API client from ircykk - add support to Laravel 6

v1.22.0 2019-12-09 17:33 UTC


Allegro API client library, written with PHP.


  • PHP >= 5.6 || PHP >= 7.0
  • HTTP client


  • REST and SOAP WebApi
  • Sandbox support
  • Auto-complete
  • PSR compatible


Via Composer:

composer require ircykk/allegro-api

Library is build on top of HTTPlug, we need to install HTTP client.

composer require php-http/guzzle6-adapter "^1.1"

Developer Documentation

Usage of client

Authentication with OAuth


// Composer autoload
require_once __DIR__.'/vendor/autoload.php';

$credentials = ...

$client = new \bbcreation\AllegroApi\Client($credentials);

// Redirect to allegro for authenticate and get back with code
if (!isset($_GET['code'])) {
    header('Location: '.$client->getAuthUrl());
} else {
    $token = $client->fetchAccessTokenWithAuthCode($_GET['code']);

    // Store access token...

We have $token->access_token for authenticate all our future requests.

See example.

Client credentials flow

In order to access to public available resources such as categories or offers use client credentials flow:

$token = $client->fetchAccessTokenWithClientCredentials();

Device flow

To use browserless device flow use getAuthUserCode() method to get user_code and verification uri:

$code = $client->getAuthUserCode();

and then after user authenticate device you can fetch acces_token:

$code = ...

$token = $client->fetchAccessTokenWithDeviceCode($code->device_code);

Making Requests


// Composer autoload
require_once __DIR__.'/vendor/autoload.php';

$credentials = ...
$token = ...

$client = new \bbcreation\AllegroApi\Client($credentials);

$categories = $client->sale()->categories()->all();

Making SOAP Requests

$credentials = ...

// WebApi SOAP client
$soapClient = new \bbcreation\AllegroApi\WebapiClient($credentials);

$categories = $soapClient->webApi()->getCatsDataLimit(0, 10);


In order to use Sandbox environment just set Credentials property $sandbox to true.

$credentials = new \bbcreation\AllegroApi\Credentials(
    true // Sandbox

Cache usage

Use any PSR-6 compatible library to cache requests.

In this example we use Symfony Cache, to install just run:

$ composer require symfony/cache
$credentials = ...
$client = new Client($credentials);

$cache = new FilesystemAdapter();
$client->addCache($cache, ['default_ttl' => 3600]);

See example.


Use any PSR-3 logger library for example Monolog, to install just run:

$ composer require monolog/monolog
$credentials = ...
$client = new Client($credentials);

$logger = new Logger('api');
    new StreamHandler(__DIR__.'/api.log', Logger::DEBUG)
$loggerPlugin = new LoggerPlugin($logger);

See example.


Thanks to HTTPlug library can be customized easily, for example to set language use HeaderDefaultsPlugin plugin:

$headerDefaultsPlugin = new HeaderDefaultsPlugin([
    'Accept-Language' => 'en-US'

See full list of available HTTPlug plugins.


  • Tests
  • Documentation


Feel free to contribute.


API client build on top of HTTPlug and inspired by KnpLabs GitHub client.

Soap types generated by wsdl2phpgenerator library.