e100/public-api-sdk

A typed PHP SDK for the E100 Public API.

Maintainers

Package info

github.com/ivashchukk/e100-php-sdk

pkg:composer/e100/public-api-sdk

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-07-24 19:15 UTC

This package is auto-updated.

Last update: 2026-07-24 19:16:11 UTC


README

A typed, dependency-injectable PHP 8.3+ client for the E100 Public API.

Installation

composer require e100/public-api-sdk

Authentication

<?php

use E100\Sdk\DTO\Authentication\AuthenticationRequest;
use E100\Sdk\E100Client;

$client = E100Client::create();

$authentication = $client->authentication()->authenticate(
    new AuthenticationRequest(
        username: $_ENV['E100_USERNAME'],
        password: $_ENV['E100_PASSWORD'],
    ),
);

$client = $client->withAccessToken($authentication);

Authentication is explicit and immutable. The API documentation returns a refresh token but does not document a refresh endpoint, so this SDK does not guess at refresh behaviour.

Usage

<?php

use DateTimeImmutable;
use E100\Sdk\DTO\Stations\StationPricesRequest;
use E100\Sdk\DTO\Transactions\TransactionSearchRequest;
use E100\Sdk\Enum\Language;

$balance = $client->agents()->balance('19-42');
$card = $client->cards()->info('7005230000719422465', Language::English);

$prices = $client->stations()->prices(new StationPricesRequest(
    stations: ['PL764', 'DE963'],
    from: new DateTimeImmutable('2026-07-01T00:00:00+03:00'),
));

$transactions = $client->transactions()->search(new TransactionSearchRequest(
    pageSize: 250,
    from: new DateTimeImmutable('2026-07-01'),
    to: new DateTimeImmutable('2026-07-23'),
    regions: ['pl', 'de'],
));

See docs/api-reference.md for all endpoint methods and DTOs.

Configuration and HTTP clients

The default base URI is https://publicapi.e100.eu. Override it for a proxy or another E100 environment:

use E100\Sdk\Config\ClientConfig;
use E100\Sdk\E100Client;
use E100\Sdk\Enum\Language;

$config = new ClientConfig(
    baseUri: 'https://publicapi.e100.eu',
    accessToken: $_ENV['E100_ACCESS_TOKEN'],
    language: Language::English,
    timeoutSeconds: 30,
);

$client = E100Client::create($config);

Guzzle is included as the default transport. Any PSR-18 client can be injected, together with optional PSR-17 request and stream factories:

$client = E100Client::create(
    config: $config,
    httpClient: $psr18Client,
    requestFactory: $psr17RequestFactory,
    streamFactory: $psr17StreamFactory,
);

Timeouts for an injected PSR-18 client must be configured on that client.

Errors

All SDK exceptions extend E100\Sdk\Exception\E100Exception. HTTP errors are represented by BadRequestException, AuthenticationException, NotFoundException, RateLimitException, ServerException, or the generic ApiException. Transport failures and invalid payloads use TransportException and UnexpectedResponseException respectively.

Automatic retries are intentionally disabled because some POST endpoints perform mutations. RateLimitException::retryAfterSeconds() exposes a numeric Retry-After value when E100 supplies one.

Development

composer test
composer analyse
composer format:check
composer validate --strict

License

MIT