Unofficial Java wrapper for Monobank API: get exchange rates (public), get client info and statements and set a webhook to receive transaction events (personal).
It uses Jackson to encode and decode JSON. There are other packages for Gson, Jackson Jr., and JSON-java.
It implements:
- currency rates
The package is not published to Maven Central yet. Use project's GitLab repository instead, please:
<repositories>
<repository>
<id>monobank4j-maven</id>
<url>https://gitlab.example.com/api/v4/projects/28690779/packages/maven</url>
</repository>
</repositories>
Please add dependency to your project:
<dependency>
<groupId>uk.bot-by.monobank4j</groupId>
<artifactId>monobank4j-jackson</artifactId>
<version>1.1.0</version>
</dependency>
Create an instance of currency Monobank Currency API using Currency.getInstance()
or with Feign manually, e.g. if you want to use custom client.
currency = Feign.builder()
.client(new Http2Client())
.decoder(new JacksonDecoder())
.target(Currency.class, "https://api.monobank.ua/");
Then just get exchange rates, it's easy:
List<CurrencyInfo> currencyExchangeRates = currency.getRates();
To run the example GetExchangeRates:
-
Build the whole project:
mvn
-
Go to the monobank4j-jackson and get all dependencies:
mvn dependency:copy-dependencies
-
Then go to target/dependency and run the following to get rates of pound and zloty:
- java -cp jackson-annotations-2.12.4.jar:jackson-core-2.12.4.jar:jackson-databind-2.12.4.jar:feign-core-11.6.jar:feign-jackson-11.6.jar:feign-java11-11.6.jar:../classes:../test-classes GetExchangeRates 826
- java -cp jackson-annotations-2.12.4.jar:jackson-core-2.12.4.jar:jackson-databind-2.12.4.jar:feign-core-11.6.jar:feign-jackson-11.6.jar:feign-java11-11.6.jar:../classes:../test-classes GetExchangeRates 985