ecb-client

Build

European Central Bank (ECB) Client

Java client based on new HttpClient (java 11+)

Usage

Simple client creation

EcbApi client = EcbClient.api();

Complex client configuration

var client = ecbClient()
    .useClient(HttpClient.newBuilder()
        .followRedirects(HttpClient.Redirect.ALWAYS)
        .priority(10)
        .connectTimeout(Duration.ofMillis(500))
        .executor(Executors.newSingleThreadExecutor())
        .build())
    .with(CircuitBreaker.ofDefaults())
    .with(RateLimiter.smoothBuilder(Duration.ofMillis(100))
        .build())
    .with(RetryPolicy.ofDefaults())
    .with(Timeout.of(Duration.ofMillis(400)))
    .rootPath("https://www.ecb.europa.eu/stats/eurofxref") -- just to use stub in tests
    .build();

Get latest rates

var client = EcbClient.api();
int rates = client.rates();

Get supported currencies

var client = EcbClient.api();
var currencies = client.supportedCurrencies();

Dependencies

Author

Anton Batiaev anton@batiaev.com