PHPackages                             elecena/php-allegro-api - 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. elecena/php-allegro-api

ActiveLibrary[API Development](/categories/api)

elecena/php-allegro-api
=======================

PHP SDK for Allegro.pl REST API

v2.3.0(6mo ago)01[1 PRs](https://github.com/elecena/php-allegro-api/pulls)MITPHPPHP &gt;=7.4CI passing

Since Dec 7Pushed 5mo agoCompare

[ Source](https://github.com/elecena/php-allegro-api)[ Packagist](https://packagist.org/packages/elecena/php-allegro-api)[ RSS](/packages/elecena-php-allegro-api/feed)WikiDiscussions master Synced today

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

Allegro.pl REST API PHP SDK
===========================

[](#allegropl-rest-api-php-sdk)

Upgrading v1.x.x -&gt; v2.x.x -&gt; v3.x.x
------------------------------------------

[](#upgrading-v1xx---v2xx---v3xx)

V2 introduced PHP &gt;=7.4 support (8.0 is also supported). All you need to do is change version in `composer.json`file. All resources and methods are the same as in V1, so you don't need to update your code.

V1 will not be maintained anymore, so please upgrade as fast as you can.

Installation
------------

[](#installation)

Just use composer:

```
composer require imper86/php-allegro-api
```

### HTTPlug note

[](#httplug-note)

This lib uses [HTTPlug](https://github.com/php-http/httplug)so it doesn't depend on any http client. In order to use this lib you must have some [PSR-18 http client](https://www.php-fig.org/psr/psr-18)and [PSR-17 http factories](https://www.php-fig.org/psr/psr-17). If you don't know which one you shoud install you can require these:

```
composer require php-http/guzzle6-adapter http-interop/http-factory-guzzle
```

Authentication &amp; usage
--------------------------

[](#authentication--usage)

Library has a bunch of mechanisms that allows you to forget about tokens, expirations etc. But in order to start using it you must authorize user using Oauth flow.

```
use Imper86\PhpAllegroApi\AllegroApi;
use Imper86\PhpAllegroApi\Model\Credentials;
use Imper86\PhpAllegroApi\Oauth\FileTokenRepository;
use Imper86\PhpAllegroApi\Plugin\AuthenticationPlugin;

// first, create Credentials object
$credentials = new Credentials(
    'your-client-id',
    'your-client-secret',
    'your-redirect-uri',
    true //is sandbox
);

// create api client
$api = new AllegroApi($credentials);

// get the authorization URL, and redirect your user:
$state = 'your-random-secret-state';
header(sprintf('Location: %s', $api->oauth()->getAuthorizationUri(true, $state)));

/*
 * after successfull authorization, user will be refirected to your
 * redirect_uri with state and code as query parameters
 */

// verify the state and fetch token
if ($state !== $_GET['state'] ?? null) {
    throw new Exception('CSRF?!');
}

$token = $api->oauth()->fetchTokenWithCode($_GET['code']);

// create TokenRepository object
$tokenRepository = new FileTokenRepository(
    $token->getUserId(),
    __DIR__ . '/tokens'
);
$tokenRepository->save($token);

/*
 * You can invent your own TokenRepository, just implement
 * Imper86\PhpAllegroApi\Oauth\TokenRepositoryInterface
 * You can use your DB, Redis, or anything you want.
 */

// now you can add AuthenticationPlugin, which will take care
// of maintaining your tokens

$api->addPlugin(new AuthenticationPlugin($tokenRepository, $api->oauth()));

// * note: of course you can use your own plugin, or AuthenticationPlugin from HTTPlug library

// from now you can use these methods on AllegroApi object:
$api->account()->(...);
$api->afterSalesServiceConditions()->(...);
$api->bidding()->(...);
$api->billing()->(...);
$api->me()->(...);
$api->offers()->(...);
$api->order()->(...);
$api->payments()->(...);
$api->pointsOfService()->(...);
$api->pricing()->(...);
$api->sale()->(...);
$api->users()->(...);

// fast example:
var_dump($api->sale()->offers()->tags()->get('123456'));
```

If you use IDE with typehinting such as PHPStorm, you'll easily figure it out. If not, please [take a look in Resource directory](src/Resource)

Device Flow
-----------

[](#device-flow)

```
use Imper86\PhpAllegroApi\AllegroApi;
use Imper86\PhpAllegroApi\Model\Credentials;
use Imper86\PhpAllegroApi\Oauth\FileTokenRepository;
use Imper86\PhpAllegroApi\Plugin\AuthenticationPlugin;

// first, create Credentials object
$credentials = new Credentials(
    'your-client-id',
    'your-client-secret',
    'your-redirect-uri',
    true //is sandbox
);

// create api client
$api = new AllegroApi($credentials);

// Create authorization session
$session = $api->oauth()->getDeviceCode();

// Provide device code and/or url to user
echo 'Please visit: ' . $session->getVerificationUriComplete();

// Poll for authorization result
$interval = $session->getInterval();
$token = false;
do {
    sleep($interval);
    $device_code = $session->getDeviceCode();
    try{
        $token = $api->oauth()->fetchTokenWithDeviceCode($device_code);
    } catch (AuthorizationPendingException) {
        continue;
    } catch (SlowDownException) {
        $interval++;
        continue;
    }
} while ($token == false);

// create TokenRepository object
$tokenRepository = new FileTokenRepository(
    $token->getUserId(),
    __DIR__ . '/tokens'
);
$tokenRepository->save($token);
```

Contributing
------------

[](#contributing)

Any help will be very appreciated :)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance68

Regular maintenance activity

Popularity1

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

208d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1929317?v=4)[Maciej Brencz](/maintainers/macbre)[@macbre](https://github.com/macbre)

---

Top Contributors

[![imper86](https://avatars.githubusercontent.com/u/16724155?v=4)](https://github.com/imper86 "imper86 (49 commits)")[![devEcommercePL](https://avatars.githubusercontent.com/u/155567765?v=4)](https://github.com/devEcommercePL "devEcommercePL (3 commits)")[![mgalejSM](https://avatars.githubusercontent.com/u/74053882?v=4)](https://github.com/mgalejSM "mgalejSM (3 commits)")[![kduma](https://avatars.githubusercontent.com/u/1062582?v=4)](https://github.com/kduma "kduma (2 commits)")[![macbre](https://avatars.githubusercontent.com/u/1929317?v=4)](https://github.com/macbre "macbre (2 commits)")[![fzdunek](https://avatars.githubusercontent.com/u/9900496?v=4)](https://github.com/fzdunek "fzdunek (2 commits)")[![Hornir91](https://avatars.githubusercontent.com/u/53277040?v=4)](https://github.com/Hornir91 "Hornir91 (1 commits)")[![dHerc](https://avatars.githubusercontent.com/u/43823377?v=4)](https://github.com/dHerc "dHerc (1 commits)")[![squishfunk](https://avatars.githubusercontent.com/u/23218977?v=4)](https://github.com/squishfunk "squishfunk (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/elecena-php-allegro-api/health.svg)

```
[![Health](https://phpackages.com/badges/elecena-php-allegro-api/health.svg)](https://phpackages.com/packages/elecena-php-allegro-api)
```

###  Alternatives

[imper86/php-allegro-api

PHP SDK for Allegro.pl REST API

1818.7k](/packages/imper86-php-allegro-api)[vonage/client-core

PHP Client for using Vonage's API.

9329.9M24](/packages/vonage-client-core)[fschmtt/keycloak-rest-api-client-php

PHP client to interact with Keycloak's Admin REST API.

49108.6k2](/packages/fschmtt-keycloak-rest-api-client-php)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[oxid-esales/graphql-base

OXID eSales GraphQL base module

24107.6k16](/packages/oxid-esales-graphql-base)[shopware/administration

Administration frontend for the Shopware Core

414.3M116](/packages/shopware-administration)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
