ecosplay / e-brocante
Official PHP client for the public e-brocante.enum.fr API
Requires
- php: >=8.3
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.9
- psr/log: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- predis/predis: ^2.3
Suggests
- ext-redis: Alternative to predis/predis for the Redis backend
- predis/predis: Required to use the Redis cache backend
README
Official PHP client for the public API of e-brocante.enum.fr โ the French platform connecting flea-market organizers and stallholders (brocanteurs).
Code quality
โจ Overview
Idiomatic PHP client for the four public read-only endpoints of the e-brocante API:
- ๐ช Events โ list & detail (flea markets, vide-greniers, antique markets, collector fairs)
- ๐ฅ Organizers โ list & profile
The API is free, REST + JSON, and strictly read-only (GET only). All transactional operations (booth reservations, payments, attendance register) live in the e-brocante.enum.fr web app, not in this SDK.
๐ Site: https://e-brocante.enum.fr ๐ API docs: https://e-brocante.enum.fr/api/doc ๐ Issues: https://code.e-cosplay.fr/shoko/e-brocante-php/issues
๐ฆ Installation
composer require ecosplay/e-brocante
Or pull from the Gitea Composer registry (private/internal channel โ useful when Packagist is unreachable):
{
"repositories": [
{ "type": "composer", "url": "https://code.e-cosplay.fr/api/packages/shoko/composer" }
],
"require": { "ecosplay/e-brocante": "^1.0" }
}
Or, before the package lands on Packagist, point Composer at the Gitea repository:
{
"repositories": [
{ "type": "vcs", "url": "https://code.e-cosplay.fr/shoko/e-brocante-php" }
],
"require": { "ecosplay/e-brocante": "^1.0" }
}
Requirements: PHP โฅ 8.3, ext-json, ext-curl, guzzlehttp/guzzle ^7.
๐ Getting an API key
The API authenticates with two headers:
| Header | Meaning |
|---|---|
X-KEY | Your API key (eb_prod_โฆ for live, eb_test_โฆ for sandbox) |
X-BROC | The email of the e-brocante account the call is made for |
Step 1 โ Create an account on e-brocante.enum.fr
- Stallholder โ https://e-brocante.enum.fr/register/broc
- Organizer โ https://e-brocante.enum.fr/register/orga
Step 2 โ Generate an API key from your dashboard
| Account type | API key page |
|---|---|
Stallholder (ROLE_BROC) | https://e-brocante.enum.fr/espace-broc/api |
Organizer (ROLE_ORGA) | https://e-brocante.enum.fr/espace-orga/api |
On that page:
- Click "Create a key"
- Name it (e.g. "Website integration", "Mobile app")
- Pick the mode:
- ๐ข Production โ
eb_prod_โฆโ live data, real production - ๐ก Test (sandbox) โ
eb_test_โฆโ fake data (1 fake organizer + 3-7 fake events)
- ๐ข Production โ
- Copy the key โ it is shown only once
โ ๏ธ Store the key in environment variables / a secret manager. Never commit it in plain text.
๐ Quick start
<?php
require 'vendor/autoload.php';
use ECosplay\EBrocante\Client;
$client = new Client(
apiKey: $_ENV['EBROCANTE_API_KEY'], // eb_prod_...
brocEmail: 'orga@example.com',
mode: 'prod',
);
$events = $client->events->list([
'city' => 'paris',
'from' => '2026-06-01',
'to' => '2026-06-30',
]);
foreach ($events as $event) {
printf("%s โ %s on %s\n",
$event->name,
$event->city,
$event->startAt->format('d/m/Y'),
);
}
More runnable examples in samples/.
๐ข Live vs ๐ก Sandbox
The API offers two strictly separated modes:
| Mode | URL prefix | Key prefix | Data | Stripe |
|---|---|---|---|---|
๐ข prod (live) | /api/prod/* | eb_prod_โฆ | Real organizers and events | Stripe live |
๐ก test (sandbox) | /api/test/* | eb_test_โฆ | Fake (generated on the fly) | Stripe test |
Sandbox guarantees
- โ
Always exactly 1 organizer in
orga.list()(slug:test-orga) - โ
Always between 3 and 7 events in
events.list()(deterministic per day) - โ
All events belong to the single
test-orga - โ Same filters / pagination / response shape as live
- โ Same HTTP codes and error structure
$client = new Client(apiKey: 'eb_test_xxx', brocEmail: 'tester@example.com', mode: 'test');
$orgas = $client->orga->list();
assert($orgas->count() === 1);
assert($orgas->data[0]->slug === 'test-orga');
$events = $client->events->list();
assert($events->count() >= 3 && $events->count() <= 7);
๐ก Develop and test in
mode: 'test'(CI, demos), then flip tomode: 'prod'. Data never crosses between modes.
โก Response cache
Responses are cached in-process by default (TTL 5 min). Override at construction time:
use ECosplay\EBrocante\Client;
use ECosplay\EBrocante\Cache\RedisConfig;
// 1๏ธโฃ Local (default โ 5 min)
$client = new Client(apiKey: '...', brocEmail: '...');
// 2๏ธโฃ Local with custom TTL
$client = new Client(apiKey: '...', brocEmail: '...', cacheTtl: 3600);
// 3๏ธโฃ Redis (multi-instance)
$client = new Client(
apiKey: '...',
brocEmail: '...',
cacheType: 'redis',
cacheRedis: new RedisConfig(host: 'redis.internal', db: 3),
cacheTtl: 600,
);
// 4๏ธโฃ Disabled โ always fresh
$client = new Client(apiKey: '...', brocEmail: '...', cache: false);
// 5๏ธโฃ One-shot bypass
$events = $client->events->list(['city' => 'paris'], skipCache: true);
// 6๏ธโฃ Manual invalidation
$client->cache->purge();
$client->cache->purgeKey('events.list', ['city' => 'paris']);
๐ชต Logging
The SDK emits PSR-3 records around every request, retry, and error. Three ways to wire a sink:
// A) Write JSON-lines log files (one per day) to a directory
$client = new Client(apiKey: '...', brocEmail: '...', logPath: '/var/log/ebrocante');
// B) Plug your own PSR-3 logger (Monolog, Symfony, Laravel, etc.)
$client = new Client(apiKey: '...', brocEmail: '...', logger: $monolog);
// C) Verbose plain-text trace to ./DEBUG.TXT (one line per action)
$client = new Client(apiKey: '...', brocEmail: '...', debug: true);
// or with a custom path
$client = new Client(apiKey: '...', brocEmail: '...', debug: true, debugFile: '/tmp/ebrocante.debug.log');
API keys are automatically redacted from log output.
๐ก Available endpoints
The API is read-only โ four methods:
| SDK method | API endpoint | Description |
|---|---|---|
$client->events->list($filters) | GET /api/{mode}/events | Paginated list of events (geo / date / category filters) |
$client->events->get($slug) | GET /api/{mode}/event/{slug} | Event detail |
$client->orga->list($filters) | GET /api/{mode}/orga | Paginated list of organizers |
$client->orga->get($slug) | GET /api/{mode}/orga/{slug} | Organizer profile + upcoming events |
Both events and orga resources expose an iter() generator that walks every page automatically.
๐งช Bundled mock API server
The package ships a small mock server in tools/mock-api/ that reproduces the four endpoints on http://127.0.0.1:3000. Use it for local development, integration tests, and CI without ever touching production.
composer mock-api # starts the server (Bun required)
# In another terminal:
php samples/01-list-events.php # hits the mock if EBROCANTE_BASE_URL is set
Point any Client at it via the baseUrl argument:
$client = new Client(
apiKey: 'eb_mock_dev',
brocEmail: 'dev@example.com',
mode: 'prod',
baseUrl: 'http://127.0.0.1:3000',
);
See tools/mock-api/README.md for fixtures and configuration.
๐ Documentation
| Topic | Link |
|---|---|
| ๐ API docs (Swagger) | https://e-brocante.enum.fr/api/doc |
| ๐ฅ OpenAPI 3.1 (JSON) | https://e-brocante.enum.fr/api/doc.json |
| Runnable examples | samples/ |
| Changelog | CHANGELOG.md |
| AI agents policy | AGENTS.md |
๐ค AI assistants
This SDK is compatible with AI coding assistants (Claude, ChatGPT, Copilot, Cursor, โฆ) for read-only integration help. Modifying or republishing the SDK requires written authorization from the publisher. See AGENTS.md.
๐ License
Proprietary โ ยฉ 2026 Association E-Cosplay (RNA W022006988, SIREN 943121517).
The SDK is free to use. Redistribution, modification, distributed forks, and derivative works are forbidden without prior written agreement โ contact@e-cosplay.fr.
See LICENSE for the full text.
๐ Useful links
- ๐ธ Platform: https://e-brocante.enum.fr
- ๐ API docs: https://e-brocante.enum.fr/api/doc
- ๐ API keys (stallholder): https://e-brocante.enum.fr/espace-broc/api
- ๐ API keys (organizer): https://e-brocante.enum.fr/espace-orga/api
- ๐ Issues: https://code.e-cosplay.fr/shoko/e-brocante-php/issues
- ๐ฌ Contact: contact@e-cosplay.fr
- ๐ข Publisher: Association E-Cosplay โ https://e-cosplay.fr