Examples
Initialization
import java.util.HashMap;
import java.io.IOException;
import org.arkecosystem.client.Connection;
import org.arkecosystem.client.api;
public class Main {
public static void main(String[] args) throws IOException {
HashMap map = new HashMap<>();
map.put("host", "http://my.node.ip:port/api/");
map.put("API-Version", 2);
Connection connection = new Connection(map);
}
}
Blockchain
Used to get the latest block and supply of the blockchain.
Get blockchain data
LinkedTreeMap blockchain = connection2.api().blockchain.all();
>>> LinkedTreeMap
Blocks
This service API grants access to the blocks resource. A block is a signed set of transactions created by a delegate and permanently committed to the ARK blockchain.
It is not possible to
POST
a block through the public API. Relay Nodes accept only blocks posted by a delegate at the correct time through the internal API.
List All Blocks
LinkedTreeMap blocks = connection.api().blocks.all();
>>> LinkedTreeMap
Retrieve a Block
LinkedTreeMap block = connection.api().blocks.show("validBlockId");
>>> LinkedTreeMap
Retrieve first block
LinkedTreeMap block = connection2.api().blocks.first();
>>> LinkedTreeMap
Retrieve last block
LinkedTreeMap block = connection2.api().blocks.last();
>>> LinkedTreeMap
List All Transactions of a Block
LinkedTreeMap blockTransactions = connection.api().blocks.transactions("validBlockId");
>>> LinkedTreeMap
Search All Blocks
LinkedTreeMap searchedBlocks = connection.api().blocks.search(new HashMap<>());
>>> LinkedTreeMap
Bridgechains
This service API grants access to the bridgechain resource. This can be used to access all registered bridgechains on the network.
List all bridgechains
LinkedTreeMap bridgechains = connection2.api().bridgechains.all();
>>> LinkedTreeMap
Retrieve a bridgechain
LinkedTreeMap bridgechain = connection2.api().bridgechains.show("bridgechains genesis hash");
>>> LinkedTreeMap
Search bridgechains
LinkedTreeMap bridgechains = connection2.api().bridgechains.search(new HashMap<>());
>>> LinkedTreeMap
Businesses
This service API grants access to the business resource. This can be used to access all registered businesses on the network.
List all businesses
LinkedTreeMap businesses = connection2.api().businesses.all();
>>> LinkedTreeMap
Retrieve a businesses
LinkedTreeMap businesses = connection2.api().businesses.show("wallet address");
>>> LinkedTreeMap
Retrieve all bridgechains of a business
LinkedTreeMap bridgechains = connection2.api().businesses.showBridgechains("D991ZqskaGWMDu9kpfpJr5LRssV7ek981k");
>>> LinkedTreeMap
Search businesses
LinkedTreeMap businesses = connection2.api().businesses.search(new HashMap<>());
>>> LinkedTreeMap
Delegates
The client SDK can be used to query the delegate resource.
A delegate is a regular wallet that has broadcasted a registration transaction, acquired a sufficient number of votes, and has a Relay Node configured to forge new blocks through a forger
module. At any time only 51 delegates are active. They are cost-efficient miners running the ARK network.
Voters are wallets which have broadcasted a vote transaction on a delegate. A vote remains active until an un-vote transaction is sent (it does not have to be recast unless a wallet wishes to change from delegate). Voting for a delegate does not give the delegate access to the wallet nor does it lock the coins in it.
List All Delegates
LinkedTreeMap delegates = connection.api().delegates.all();
>>> LinkedTreeMap
Retrieve a Delegate
LinkedTreeMap delegate = connection.api().delegates.show("validDelegateId");
>>> LinkedTreeMap
List All Blocks of a Delegate
LinkedTreeMap delegateBlocks = connection.api().delegates.blocks("validDelegateId");
>>> LinkedTreeMap
List All Voters of a Delegate
LinkedTreeMap delegateVoters = connection.api().delegates.voters("validDelegateId");
>>> LinkedTreeMap
Search delegates
LinkedTreeMap delegates = connection2.api().delegates.search(new HashMap<>());
>>> LinkedTreeMap
Locks
This service API grants access to the lock resource. This can be used to access all locks initiated for wallets.
List all locks
LinkedTreeMap locks = connection2.api().locks.all();
>>> LinkedTreeMap
Retrieve a lock
LinkedTreeMap lock = connection2.api().locks.show("lock id");
>>> LinkedTreeMap
Search unlocked locks
LinkedTreeMap unlockedLocks = connection2.api().locks.searchUnlocked(new HashMap<>());
>>> LinkedTreeMap
Search locks
LinkedTreeMap locks = connection2.api().locks.search(new HashMap<>());
>>> LinkedTreeMap
Node
The ARK network consists of different anonymous nodes (servers), maintaining the public ledger, validating transactions and blocks and providing APIs. The node resource allows for querying the health and configurations of the node used by the instantiated client.
Retrieve the Configuration
LinkedTreeMap nodeConfiguration = connection.api().node.configuration();
>>> LinkedTreeMap
Retrieve the Status
LinkedTreeMap nodeStatus = connection.api().node.status();
>>> LinkedTreeMap
Retrieve the Syncing Status
LinkedTreeMap nodeSyncingStatus = connection.api().node.syncing();
>>> LinkedTreeMap
Retrieve the Fees
LinkedTreeMap fees = connection2.api().node.fees(days);
>>> LinkedTreeMap
Debug
LinkedTreeMap debug = connection2.api().node.debug();
>>> LinkedTreeMap
Peers
Each node is connected to a set of peers, which are Relay or Delegate Nodes as well. The peers resource provides access to all peers connected to our node.
Peers have made their Public API available for use; however for mission-critical queries and transaction posting you should use a node which is under your control. We provide a guide to setting up a Relay Node here.
List All Peers
LinkedTreeMap peers = connection.api().peers.all();
>>> LinkedTreeMap
Retrieve a Peer
LinkedTreeMap peer = connection.api().peers.show("validIpAddress");
>>> LinkedTreeMap
Rounds
This service API grants access to the round resource. This can be used to access all round information for the network.
List Delegates for a Round
LinkedTreeMap delegates = connection2.api().rounds.delegates(numberOfARound);
>>> LinkedTreeMap
Transactions
The heart of any blockchain is formed by its transactions; state-altering payloads signed by a wallet. Most likely you will be querying for transactions most often, using the transaction resource.
A transaction is the only object which may be posted by a non-delegate. It requires a signature from a wallet containing a sufficient amount of ARK.
Create a Transaction
LinkedTreeMap transaction = connection.api().transactions.create(new ArrayList<>());
>>> LinkedTreeMap
Retrieve a Transaction
LinkedTreeMap transaction = connection.api().transactions.show("validTxId");
>>> LinkedTreeMap
List All Transactions
LinkedTreeMap transactions = connection.api().transactions.all();
>>> LinkedTreeMap
List All Unconfirmed Transactions
LinkedTreeMap unconfirmedTransactions = connection.api().transactions.allUnconfirmed();
echo gettype($unconfirmedTransactions);
>>> LinkedTreeMap
Get Unconfirmed Transaction
LinkedTreeMap unconfirmedTransaction = connection.api().transactions.showUnconfirmed("validTxId");
echo gettype($unconfirmedTransaction);
>>> LinkedTreeMap
Search Transactions
LinkedTreeMap searchedTransactions = connection.api().transactions.search(new HashMap<>());
>>> LinkedTreeMap
List Transaction Types
LinkedTreeMap transactionTypes = connection.api().transactions.types();
>>> LinkedTreeMap
List transaction schemas
LinkedTreeMap schemas = connection2.api().transactions.schemas();
>>> LinkedTreeMap
List transaction fees
LinkedTreeMap fees = connection2.api().transactions.fees();
>>> LinkedTreeMap
Votes
A vote is a transaction sub-type, where the asset
field contains a votes
object and the transaction.type
is 3
.
List All Votes
LinkedTreeMap votes = connection.api().votes.all();
>>> LinkedTreeMap
Retrieve a Vote
LinkedTreeMap actual = connection.api().votes.show("validVoteId");
>>> LinkedTreeMap
Wallets
The wallet resource provides access to:
- Wallets.
- Incoming and outgoing transactions per wallet.
- Each wallet’s votes.
Retrieve All Wallets
LinkedTreeMap wallets = connection.api().wallets.all();
>>> LinkedTreeMap
Retrieve a Wallet
LinkedTreeMap wallet = connection.api().wallets.show("validWalletId");
>>> LinkedTreeMap
List All Transactions of a Wallet
LinkedTreeMap walletTransactions = connection.api().wallets.transactions("validWalletId");
>>> LinkedTreeMap
List All Received Transactions of a Wallet
LinkedTreeMap receivedTransactions = connection.api().wallets.receivedTransactions("validWalletId");
>>> LinkedTreeMap
List All Sent Transactions of a Wallet
LinkedTreeMap senTransactions = connection.api().wallets.sentTransactions("validWalletId");
>>> LinkedTreeMap
List All Votes of a Wallet
LinkedTreeMap walletVotes = connection.api().wallets.votes("validWalletId");
>>> LinkedTreeMap
List All Top Wallets
LinkedTreeMap topWallets = connection.api().wallets.top();
>>> LinkedTreeMap
List locks of a Wallet
LinkedTreeMap fees = connection2.api().wallets.locks(walletAddress);
>>> LinkedTreeMap
Search All Wallets
LinkedTreeMap searchedWallets = connection.api().wallets.search(new HashMap<>());
>>> LinkedTreeMap