Examples

Initialization

1const { Connection } = require("@arkecosystem/client");
2 
3const client = new Connection(`${server}/api`);

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

1const response = client.api("blocks").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Block

1const response = client.api("blocks").get("validBlockId");
2 
3>>> Promise<IResponse<T>>

List All Transactions of a Block

1const response = client.api("blocks").transactions("validBlockId");
2 
3>>> Promise<IResponse<T>>

Search All Blocks

1const response = client.api("blocks").search({"id": "validBlockId"});
2 
3>>> Promise<IResponse<T>>

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

1const response = client.api("bridgechains").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Bridgechain

1const response = client.api("bridgechains").get("validId");
2 
3>>> Promise<IResponse<T>>

Search All Bridgechains

1const response = client.api("bridgechains").search({"bridgechainId": "validId"});
2 
3>>> Promise<IResponse<T>>

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

1const response = client.api("businesses").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Business

1const response = client.api("businesses").get("validId");
2 
3>>> Promise<IResponse<T>>

Retrieve all Business Bridgechains

1const response = client.api("businesses").bridgechains("validId");
2 
3>>> Promise<IResponse<T>>

Search All Businesses

1const response = client.api("businesses").search({"businessId": "validId"});
2 
3>>> Promise<IResponse<T>>

Delegates

The client SDK can be used to query the delegate resource.

A delegate is a regular wallet that has broadcast 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 broadcast 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

1const response = client.api("delegates").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Delegate

1const response = client.api("delegates").get("validId");
2 
3>>> Promise<IResponse<T>>

List All Blocks of a Delegate

1const response = client.api("delegates").blocks("validId");
2 
3>>> Promise<IResponse<T>>

List All Voters of a Delegate

1const response = client.api("delegates").voters("validId");
2 
3>>> Promise<IResponse<T>>

Locks

This service API grants access to the lock resource. This can be used to access all locks initiated for wallets.

List All Locks

1const response = client.api("locks").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Lock

1const response = client.api("locks").get("validId");
2 
3>>> Promise<IResponse<T>>

Search Locks

1const response = client.api("locks").search({"lockId": "validId"});
2 
3>>> Promise<IResponse<T>>

Get Unlocked Locks

1const response = client.api("locks").unlocked({ids: [ "validId" ]});
2 
3>>> Promise<IResponse<T>>

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

1const response = client.api("node").configuration();
2 
3>>> Promise<IResponse<T>>

Retrieve the Status

1const response = client.api("node").status();
2 
3>>> Promise<IResponse<T>>

Retrieve the Syncing Status

1const response = client.api("node").syncing();
2 
3>>> Promise<IResponse<T>>

Retrieve the Fees

1const response = client.api("node").fees();
2 
3>>> Promise<IResponse<T>>

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.

List All Peers

1const response = client.api("peers").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Peer

1const response = client.api("peers").get("validIpAddress");
2 
3>>> Promise<IResponse<T>>

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

1const response = client.api("rounds").delegates(roundNumber);
2 
3>>> Promise<IResponse<T>>

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

1const response = client.api("transactions").create([...]);
2 
3>>> Promise<IResponse<T>>

Retrieve a Transaction

1const response = client.api("transactions").get("validId");
2 
3>>> Promise<IResponse<T>>

List All Transactions

1const response = client.api("transactions").all();
2 
3>>> Promise<IResponse<T>>

List All Unconfirmed Transactions

1const response = client.api("transactions").allUnconfirmed();
2 
3>>> Promise<IResponse<T>>

Get Unconfirmed Transaction

1const response = client.api("transactions").getUnconfirmed("validId");
2 
3>>> Promise<IResponse<T>>

Search Transactions

1const response = client.api("transactions").search({"id": "validId"});
2 
3>>> Promise<IResponse<T>>

List Transaction Types

1const response = client.api("transactions").types();
2 
3>>> Promise<IResponse<T>>

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

1const response = client.api("votes").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Vote

1const response = client.api("votes").get("validId");
2 
3>>> Promise<IResponse<T>>

Wallets

The wallet resource provides access to:

  • Wallets.
  • Incoming and outgoing transactions per wallet.
  • Each wallet’s votes.

Retrieve All Wallets

1const response = client.api("wallets").all();
2 
3>>> Promise<IResponse<T>>

Retrieve a Wallet

1const response = client.api("wallets").get("validId");
2 
3>>> Promise<IResponse<T>>

List All Transactions of a Wallet

1const response = client.api("wallets").transactions("validId");
2 
3>>> Promise<IResponse<T>>

List All Received Transactions of a Wallet

1const response = client.api("wallets").transactionsReceived("validId");
2 
3>>> Promise<IResponse<T>>

List All Sent Transactions of a Wallet

1const response = client.api("wallets").transactionsSent("validId");
2 
3>>> Promise<IResponse<T>>

List All Votes of a Wallet

1const response = client.api("wallets").votes("validId");
2 
3>>> Promise<IResponse<T>>

List All Locks of a Wallet

1const response = client.api("wallets").locks("validId");
2 
3>>> Promise<IResponse<T>>

List All Top Wallets

1const response = client.api("wallets").top();
2 
3>>> Promise<IResponse<T>>

Search All Wallets

1const response = client.api("wallets").search({"address": "validId"});
2 
3>>> Promise<IResponse<T>>
Last updated 3 years ago
Edit Page
Share: