cardano-community / koios-java-client

koios-java-client
https://www.koios.rest/
Apache License 2.0
18 stars 3 forks source link
api-client blockchain cardano java transaction

Preview Preprod Mainnet CodeQL Coverage Maven License

Koios

What is Koios?

Koios Java Client Library is based on Koios Elastic Query Layer for Cardano Node by Cardano Community Guild Operators.
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc.
Resource and maintenance requirements for Cardano blockchain components (e.g. cardano-node, cardano-db-sync) are ever-growing. Along with that, every builder needs to identify how to query complex information from the chain.

Overview

Koios Java Client is a Java REST Client library which allows interacting with Koios Server Instances using Java Objects.

Features

Version Compatability Chart | Koios Instance | Koios Java Client | |:--------------:|:-----------------:| | 1.2.0 | 1.19.3 | | 1.1.2 | 1.18.2 | | 1.0.10 | 1.17.3 | | 1.0.9 | 1.16.3 | | 1.0.8 | 1.15.2 | | 1.0.7 | 1.14.1 | | 1.0.6 | 1.13 |

Use as a library in a Java Project

Add dependency

Get Koios Backend Service (No API Token)

Get Koios Backend Service (with API Token)

Get Your API Token from Koios Website: https://www.koios.rest/

Get Koios Backend Services

NetworkService networkService = backendService.getNetworkService();
EpochService epochService = backendService.getEpochService();
BlockService blockService = backendService.getBlockService();
TransactionsService transactionsService = backendService.getTransactionsService();
AddressService addressService = backendService.getAddressService();
AccountService accountService = backendService.getAccountService();
AssetService assetService = backendService.getAssetService();
PoolService poolService = backendService.getPoolService();
ScriptService scriptService = backendService.getScriptService();

Advanced Query Example (Preview)

Querying a Descending Order of All Address Transactions since Block No. #42248 to Block No. #69447 (inclusive), Limited to Maximum of 10 Results.

String address = "addr_test1qrvaadv0h7atv366u6966u4rft2svjlf5uajy8lkpsgdrc24rnskuetxz2u3m5ac22s3njvftxcl2fc8k8kjr088ge0qz98xmv";

Options options = Options.builder()
        .option(Limit.of(10))
        .option(Offset.of(0))
        .option(Order.by("block_height", SortType.DESC))
        .option(Filter.of("block_height", FilterType.GTE, "42248"))
        .option(Filter.of("block_height", FilterType.LTE, "69447")).build();

Result<List<TxHash>> transactionsResult = addressService.getAddressTransactions(List.of(address), options);

Supported Environment Variables

Variable Type Description Default
KOIOS_JAVA_LIB_LOGGING boolean Toggle Logging false
KOIOS_JAVA_LIB_RETRIES_COUNT integer Sets the max retry count upon request timeout 5
KOIOS_JAVA_LIB_READ_TIMEOUT_SEC integer Sets the default read timeout for new connections (seconds) 300
KOIOS_JAVA_LIB_CONNECT_TIMEOUT_SEC integer Sets the default connect timeout for new connections (seconds) 300
KOIOS_JAVA_LIB_RETRY_ON_TIMEOUT boolean Sets whether to retry upon request timeout true
KOIOS_JAVA_LIB_GZIP_COMPRESSION boolean Sets whether to use GZIP Compression true

Clone & Build with Maven

git clone https://github.com/cardano-community/koios-java-client.git
cd koios-java-client
mvn clean install

Used by

:triangular_ruler: Contributing | :gift_heart: Sponsors | DiscordDiscord (#koios-java-client)