ecosplay/e-brocante

Official PHP client for the public e-brocante.enum.fr API

Maintainers

Package info

code.e-cosplay.fr/shoko/e-brocante-php

Homepage

Issues

Documentation

pkg:composer/ecosplay/e-brocante

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

v1.0.2 2026-05-10 20:01 UTC

This package is auto-updated.

Last update: 2026-05-10 20:05:25 UTC


README

Official PHP client for the public API of e-brocante.enum.fr โ€” the French platform connecting flea-market organizers and stallholders (brocanteurs).

License PHP API

Code quality

Quality Gate Status Coverage Duplicated Lines (%) Lines of Code Security Hotspots Reliability Issues Maintainability Issues Security Issues Maintainability Rating Reliability Rating Security Rating Technical Debt

โœจ 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:

HeaderMeaning
X-KEYYour API key (eb_prod_โ€ฆ for live, eb_test_โ€ฆ for sandbox)
X-BROCThe email of the e-brocante account the call is made for

Step 1 โ€” Create an account on e-brocante.enum.fr

Step 2 โ€” Generate an API key from your dashboard

Account typeAPI 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:

  1. Click "Create a key"
  2. Name it (e.g. "Website integration", "Mobile app")
  3. Pick the mode:
    • ๐ŸŸข Production โ†’ eb_prod_โ€ฆ โ†’ live data, real production
    • ๐ŸŸก Test (sandbox) โ†’ eb_test_โ€ฆ โ†’ fake data (1 fake organizer + 3-7 fake events)
  4. 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:

ModeURL prefixKey prefixDataStripe
๐ŸŸข prod (live)/api/prod/*eb_prod_โ€ฆReal organizers and eventsStripe 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 to mode: '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 methodAPI endpointDescription
$client->events->list($filters)GET /api/{mode}/eventsPaginated 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}/orgaPaginated 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

TopicLink
๐Ÿ“– API docs (Swagger)https://e-brocante.enum.fr/api/doc
๐Ÿ“ฅ OpenAPI 3.1 (JSON)https://e-brocante.enum.fr/api/doc.json
Runnable examplessamples/
ChangelogCHANGELOG.md
AI agents policyAGENTS.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