jacekkow / enable-banking-api
PSR-18 client for the Enable Banking API (Account Information Service)
v1.0.0
2026-11-16 22:40 UTC
Requires
- php: >=8.1
- ext-json: *
- ext-openssl: *
- firebase/php-jwt: ^6.10 || ^7.0
- guzzlehttp/guzzle: ^7.8
- guzzlehttp/psr7: ^2.6
- psr/clock: ^1.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.1 || ^2.0
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-16 22:49:37 UTC
README
PHP client for the Account Information Service (AIS) part of the Enable Banking API.
- Works with any PSR-18 HTTP client and PSR-17 factories. Guzzle is used by default.
- JWTs are signed with firebase/php-jwt and reused until shortly before they expire.
- Responses are mapped to typed, read-only models. Each model also keeps the raw payload in
$raw.
Installation
composer require jacekkow/enable-banking-api
Requires PHP 8.1+ with the openssl and json extensions.
Usage
use EnableBanking\Auth\JwtTokenProvider; use EnableBanking\EnableBankingClient; use EnableBanking\Enum\PsuType; use EnableBanking\Model\Aspsp; use EnableBanking\Request\Access; use EnableBanking\Request\PsuHeaders; use EnableBanking\Request\StartAuthorizationRequest; $client = new EnableBankingClient( JwtTokenProvider::fromFile('your-application-id', '/path/to/private.pem'), ); // or: EnableBankingClient::create($applicationId, $pemString); // 1. Pick a bank $aspsps = $client->getAspsps(country: 'FI', psuType: PsuType::Personal); // 2. Start authorization and redirect the user $auth = $client->startAuthorization(new StartAuthorizationRequest( access: new Access(validUntil: new DateTimeImmutable('+90 days')), aspsp: new Aspsp('Nordea', 'FI'), state: $csrfState, redirectUrl: 'https://example.com/enable-banking/callback', psuType: PsuType::Personal, )); header('Location: ' . $auth->url); // 3. On the callback, check $_GET['state'] and exchange the code for a session $session = $client->authorizeSession($_GET['code']); // 4. Read account data foreach ($session->accounts as $account) { $balances = $client->getAccountBalances($account->uid); // Follows continuation keys automatically foreach ($client->getAllAccountTransactions($account->uid, dateFrom: new DateTimeImmutable('-30 days')) as $tx) { echo $tx->bookingDate?->format('Y-m-d'), ' ', $tx->transactionAmount->amount, PHP_EOL; } } // Later: session status and closing $client->getSession($session->sessionId)->isAuthorized(); $client->deleteSession($session->sessionId);
Available methods
| Method | Endpoint |
|---|---|
getApplication() |
GET /application |
getAspsps(?country, ?psuType, ?service = AIS) |
GET /aspsps |
startAuthorization(StartAuthorizationRequest) |
POST /auth |
authorizeSession(code) |
POST /sessions |
getSession(sessionId) |
GET /sessions/{id} |
deleteSession(sessionId, ?PsuHeaders) |
DELETE /sessions/{id} |
getAccountDetails(accountId, ?PsuHeaders) |
GET /accounts/{id}/details |
getAccountBalances(accountId, ?PsuHeaders) |
GET /accounts/{id}/balances |
getAccountTransactions(accountId, ...) |
GET /accounts/{id}/transactions (one page) |
getAllAccountTransactions(accountId, ...) |
same, as a generator that follows all pages |
getTransaction(accountId, transactionId, ?PsuHeaders) |
GET /accounts/{id}/transactions/{tx} |
request(method, path, query, body, ?PsuHeaders) |
any other endpoint, returns the decoded array |
PSU headers
Some banks require PSU context headers (see AspspData::$requiredPsuHeaders) when the user is present:
$client->getAccountBalances($accountId, PsuHeaders::fromGlobals());
Custom HTTP client
$client = new EnableBankingClient( $tokenProvider, $anyPsr18Client, // Psr\Http\Client\ClientInterface $requestFactory, // Psr\Http\Message\RequestFactoryInterface $streamFactory, // Psr\Http\Message\StreamFactoryInterface );
Errors
Every exception implements EnableBanking\Exception\EnableBankingException:
ApiException: the API returned a non-2xx status. It has$statusCode,$error(e.g.EXPIRED_SESSION),$detailand$response.NetworkException: the request could not be sent.UnexpectedResponseException: the response body could not be parsed.InvalidArgumentException: the configuration is invalid, for example an unreadable key or a TTL over 24 hours.
Example
examples/ais.php runs the full interactive flow, like the
official PHP sample:
cp examples/config.json.dist examples/config.json # fill in application ID and key path
php examples/ais.php
Development
composer test
composer analyse