Minimal, idiomatic Java client for OpenExchangeAPI
- All endpoints supported
- API key is optional
- Strong types and precise decimal support
Add to your Maven/Gradle project, or copy OpenExchangeApiClient.java
into your codebase.
import com.openexchangeapi.OpenExchangeApiClient;
OpenExchangeApiClient client = new OpenExchangeApiClient("YOUR_API_KEY"); // API key optional
// Get latest rates
var latest = client.getLatest();
// Convert currency
var result = client.convert("USD", "EUR", 100);
// List currencies
var currencies = client.listCurrencies();
// Get currency details
var eur = client.getCurrency("EUR");
getLatest(base)
getLatestPrecise(base)
getHistorical(date, base)
getHistoricalPrecise(date, base)
convert(from, to, amount)
convertPrecise(from, to, amount)
listCurrencies(type)
getCurrency(code)
All methods throw OpenExchangeApiException
on error.
try {
var data = client.getLatest();
} catch (OpenExchangeApiException e) {
// Handle error
}
MIT