Examples

Initialization

1from client import ArkClient
2 
3client = ArkClient('https://node.ip.address:port/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

1blocks = client.blocks.all()
2 
3# With parameters
4blocks = client.blocks.all(page=5, limit=10, {"orderBy": "height"})
5 
6# Available extra_parameters :
7# orderBy, ...
8 
9print(blocks)
10 
11>>> {'meta': {'count': 10, ... }}

Retrieve a Block

1block = client.blocks.get('validBlockId')
2 
3print(block)
4 
5>>> {'data': {'id': 'validBlockId' ... }}

List All Transactions of a Block

1block_transactions = client.blocks.transactions('validBlockId')
2 
3# With parameters
4block_transactions = client.blocks.transactions('validBlockId', page=5, limit=10)
5 
6print(block_transactions)
7 
8>>> {'meta': {'count': 10, ... }}

Search All Blocks

1searched_blocks = client.blocks.search({"generatorPublicKey": "validPublicKey"})
2 
3# With parameters
4searched_blocks = client.blocks.search({"generatorPublicKey": "validPublicKey"}, page=5, limit=10)
5 
6# Available keys :
7# generatorPublicKey, ...
8 
9print(searched_blocks)
10 
11>>> {'meta': {'count': 100, ... }}

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

1delegates = client.delegates.all()
2 
3# With parameters
4delegates = client.delegates.all(page=5, limit=20, {"orderBy": "production")
5 
6# Available extra_parameters :
7# orderBy, ...
8 
9print(delegates)
10 
11>>> {'meta': {'count': 20, ... }}

Retrieve a Delegate

1delegate = client.delegates.get("delegateName")
2 
3print(delegate)
4 
5>>> {'data': {'username': 'delegateName', ... }}

Search Delegates

1searched_delegates = client.delegates.search("delegateName")
2 
3# With parameters
4searched_delegates = client.delegates.search("delegateName", page=1, limit=5)
5 
6print(searched_delegates)
7 
8>>> {'meta': {'count': 1, ... }}

List All Blocks of a Delegate

1delegate_blocks = client.delegates.blocks("delegateName")
2 
3# With parameters
4delegate_blocks = client.delegates.blocks("delegateName", page=1, limit=20)
5 
6print(delegate_blocks)
7 
8>>> {'meta': {'count': 20, ... }}

List All Voters of a Delegate

1delegate_voters = client.delegates.voters("delegateName")
2 
3# With parameters
4delegate_voters = client.delegates.voters("delegateName", page=1, limit=10)
5 
6print(delegate_voters)
7 
8>>> {'meta': {'count': 10, ... }}

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

1configuration = client.node.configuration()
2 
3print(configuration)
4 
5>>> {'data': {'nethash': '6e84d08bd299ed97c212c886c98a57e36545c8f5d645ca7eeae63a8bd62d8988', ... }}

Retrieve the Status

1status = client.node.status()
2 
3print(status)
4 
5>>> {'data': {'synced': True, 'now': 6897158, 'blocksCount': -1}}

Retrieve the Syncing Status

1syncing_status = client.node.syncing()
2 
3print(syncing_status)
4 
5>>> {'data': {'syncing': False, 'blocks': -1, 'height': 6897160, 'id': '12905037940821862953'}}

Retrieve the Node Fees

1fees = client.node.fees()
2 
3print(fees)
4 
5>>> {"meta":{"days":7, ...}}

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

1peers = client.peers.all()
2 
3# With parameters
4peers = client.peers.all(os="", status="", port=4002, version="", orderBy="latency", page=1, limit=10)
5 
6print(peers)
7 
8>>> {'meta': {'count': 10, ... }}

Retrieve a Peer

1peer = client.peers.get("peerIpAddress")
2 
3print(peer)
4 
5>>> {'data': {'count': 20, ... }} # Need to changes

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

1transaction = client.transactions.create([signed_transaction])
2 
3print(transaction)
4 
5>>> <class 'dict'> # Need to update

Retrieve a Transaction

1transaction = client.transactions.get("validTransactionId")
2 
3print(transaction)
4 
5>>> <class 'dict'> # Need to update

List All Transactions

1transactions = client.transactions.all()
2 
3# With parameters
4transactions = client.transactions.all(page=1, limit=10, {"orderBy": "amount"})
5 
6# Available extra_parameters :
7# orderBy, ...
8 
9>>> {'meta': {'count': 10, ... }}

List All Unconfirmed Transactions

1unconfirmed_transactions = client.transactions.all_unconfirmed()
2 
3# With parameters
4unconfirmed_transactions = client.transactions.all_unconfirmed(page=1, limit=10, {"orderBy": "amount"})
5 
6# Available extra_parameters :
7# orderBy, ...
8 
9print(unconfirmed_transactions)
10 
11>>> {'meta': {'count': 10, ... }}

Get Unconfirmed Transaction

1unconfirmed_transaction = client.transactions.get_unconfirmed("validTransactionId")
2 
3print(unconfirmed_transaction)
4 
5>>> <class 'dict'> # Need to update

Search Transactions

1transactions = client.transactions.search({"senderId": "validPublicKey"})
2transactions = client.transactions.search({"senderId": "validPublicKey"}, page=1, limit=10)
3 
4# Available keys :
5# senderId, ...
6 
7print(transactions)
8 
9>>> {'meta': {'count': 10, ... }}

List Transaction Types

1types = client.transactions.types()
2 
3print(types)
4 
5>>> {"data":{...}}

List Transaction Fees (Non-Dynamic)

1fees = client.transactions.fees()
2 
3>>> {"data":{...}}

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

1votes = client.votes.all()
2 
3# With parameters
4votes = client.votes.all(page=1, limit=10)
5 
6print(votes)
7 
8>>> {'meta': {'count': 10, ... }}

Retrieve a Vote

1vote = client.votes.get('validVoteId')
2 
3print(vote)
4 
5>>> {'data': {...}}

Wallets

The wallet resource provides access to:

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

Retrieve All Wallets

1wallets = client.wallets.all()
2 
3# With parameters
4wallets = client.wallets.all(page=1, limit=10)
5 
6print(wallets)
7 
8>>> {'meta': {'count': 10, ... }}

Retrieve a Wallet

1wallet = client.wallets.get('validWalletId')
2 
3print(wallet)
4 
5>>> {'data': {'id': 'validWalletId' ... }}

List All Transactions of a Wallet

1wallet_transactions = client.wallets.transactions('validWalletId')
2wallet_transactions = client.wallets.transactions('validWalletId', page=1, limit=10, {"orderBy": "amount"})
3 
4# Available extra_parameters :
5# orderBy, ...
6 
7print(wallet_transactions)
8 
9>>> {'meta': {'count': 10, ... }}

List All Received Transactions of a Wallet

1received_transactions = client.wallets.transactions_received('validWalletId')
2 
3# With parameters
4received_transactions = client.wallets.transactions_received('validWalletId', page=1, limit=10, {"orderBy": "amount"})
5 
6# Available extra_parameters :
7# orderBy, ...
8 
9print(received_transactions)
10 
11>>> {'meta': {'count': 10, ... }}

List All Sent Transactions of a Wallet

1sent_transactions = client.wallets.transactions_sent('validWalletId')
2 
3# With parameters
4sent_transactions = client.wallets.transactions_sent('validWalletId', page=1, limit=10, {"orderBy": "amount"})
5 
6# Available extra_parameters :
7# orderBy, ...
8 
9print(sent_transactions)
10 
11>>> {'meta': {'count': 10, ... }}

List All Votes of a Wallet

1wallet_votes = client.wallets.votes('validWalletId')
2 
3# With parameters
4wallet_votes = client.wallets.votes('validWalletId', page=1, limit=10)
5 
6print(wallet_votes)
7 
8>>> {'meta': {'count': 10, ... }}

List All Top Wallets

1top_wallets = client.wallets.top()
2 
3# With parameters
4top_wallets = client.wallets.top(page=1, limit=10)
5 
6print(top_wallets)
7 
8>>> {'meta': {'count': 10, ... }}

Search All Wallets

1wallets = client.wallets.search({"publicKey": "validPublicKey})
2 
3# With parameters
4wallets = client.wallets.search({"publicKey": "validPublicKey}, page=1, limit=10)
5 
6# Available keys :
7# publicKey, ...
8 
9print(wallets)
10 
11>>> {'meta': {'count': 10, ... }}
Last updated 10 months ago
Edit Page
Share:
2022 © ARK.io | All Rights Reserved
An ARK.io Product