PHPackages                             sashalenz/olx-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. sashalenz/olx-api

ActiveLibrary[API Development](/categories/api)

sashalenz/olx-api
=================

OLX.ua Partner API v2 SDK for Laravel — typed client for adverts, threads/messages, categories, locations, packets and OAuth (marketplace publisher + chat intake).

1.0.0(today)00MITPHPPHP ^8.2

Since Jun 22Pushed todayCompare

[ Source](https://github.com/sashalenz/olx-api)[ Packagist](https://packagist.org/packages/sashalenz/olx-api)[ Docs](https://github.com/sashalenz/olx-api)[ RSS](/packages/sashalenz-olx-api/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (12)Versions (2)Used By (0)

olx-api
=======

[](#olx-api)

OLX.ua **Partner API v2** SDK for Laravel — a thin, typed client for the marketplace publisher + chat intake use cases. Mirrors the structure of `sashalenz/chatwoot-api` (static entry class, fluent resources, `spatie/laravel-data`DTOs, `Http`-facade transport).

> Scope: the **Partner API v2** served at `https://www.olx.ua/api/open/…` — adverts, chat threads/messages, categories, locations, packets, paid features, users and OAuth. Push (webhooks) and `read:leads` (call leads) live on the separate OLX Group PartnerHub program and are **not** part of this API.

Install
-------

[](#install)

```
composer require sashalenz/olx-api
```

```
php artisan vendor:publish --tag=olx-api-config
```

```
OLX_API_BASE_URL=https://www.olx.ua
OLX_API_CLIENT_ID=...
OLX_API_CLIENT_SECRET=...
OLX_API_REDIRECT_URI=https://your-app/olx/callback
# single-account convenience default (multi-account passes ->token() per call):
OLX_API_TOKEN=
```

OAuth (per-account onboarding)
------------------------------

[](#oauth-per-account-onboarding)

The SDK is **stateless** about token storage — minting/refresh is here, but persisting the access + refresh tokens (and refreshing before the ~1-month refresh-token lapses) is the consumer's job.

```
use Sashalenz\OlxApi\OlxApi;

// 1. redirect the manager to consent
$url = OlxApi::oauth()->authorizeUrl(state: 'account-b');

// 2. on the callback, exchange the code → persist the token
$token = OlxApi::oauth()->exchangeCode($request->query('code'));
// $token->accessToken, $token->refreshToken, $token->expiresIn

// 3. later, refresh (OLX rotates the refresh token — persist the new one)
$token = OlxApi::oauth()->refresh($storedRefreshToken);
```

Per-account calls
-----------------

[](#per-account-calls)

Five manager accounts (one per FOP) each carry their own access token; pass it at call time:

```
$threads = OlxApi::threads()->token($accessB)->all(['limit' => 50]);

foreach ($threads->data as $thread) {
    if ($thread->unreadCount > 0) {
        $messages = OlxApi::messages()->token($accessB)->all($thread->id);
        OlxApi::threads()->token($accessB)->markAsRead($thread->id);
    }
}

// reply (attachments are pre-hosted URLs; no upload endpoint)
OlxApi::messages()->token($accessB)->post($threadId, 'Доброго дня! Так, є в наявності.');
```

Publishing adverts
------------------

[](#publishing-adverts)

```
$advert = OlxApi::adverts()->token($accessB)->create([
    'title' => 'Фара права Jeep Grand Cherokee WK2',
    'description' => '...80–9000 chars, no phone numbers...',
    'category_id' => 1234,                 // leaf category
    'advertiser_type' => 'business',
    'contact' => ['name' => 'А20', 'phone' => '+380...'],
    'location' => ['city_id' => 5],
    'price' => ['value' => 3500, 'currency' => 'UAH', 'negotiable' => true],
    'images' => [['url' => 'https://cdn.a20/part-1.jpg']],
    'attributes' => [['code' => 'make', 'value' => 'jeep']],
]);

OlxApi::adverts()->token($accessB)->finish($advert->id);   // sold
```

Resources
---------

[](#resources)

`oauth()` · `adverts()` · `threads()` · `messages()` · `categories()` · `cities()` · `regions()` · `districts()` · `locations()` · `currencies()` · `languages()` · `packets()` · `paidFeatures()` · `users()` · `usersBusiness()`

Errors
------

[](#errors)

All failures throw an `OlxApiException` subclass carrying the parsed `error`envelope (`status`, `title`, `detail`, `validation`):

`ValidationException` (400/422) · `UnauthorizedException` (401) · `ForbiddenException` (403) · `NotFoundException` (404) · `RateLimitException` (429) · `ServerException` (5xx).

Testing
-------

[](#testing)

```
composer test
composer analyse
composer format
```

License
-------

[](#license)

MIT.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13202688?v=4)[Oleksandr Petrovskyi](/maintainers/sashalenz)[@sashalenz](https://github.com/sashalenz)

---

Top Contributors

[![sashalenz](https://avatars.githubusercontent.com/u/13202688?v=4)](https://github.com/sashalenz "sashalenz (1 commits)")

---

Tags

laravelmarketplacesashalenzolxclassifiedsolx-api

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sashalenz-olx-api/health.svg)

```
[![Health](https://phpackages.com/badges/sashalenz-olx-api/health.svg)](https://phpackages.com/packages/sashalenz-olx-api)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4923.6k5](/packages/ralphjsmit-laravel-glide)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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