Skip to main content

Client Libraries

Official Java Client

The Java client library is included in the Shamwari QKP distribution.

Maven Dependency

<dependency>
<groupId>network.shamwari</groupId>
<artifactId>shamwariQKP</artifactId>
<version>1.0.0</version>
</dependency>

Gradle Dependency

implementation 'network.shamwari:shamwariQKP:1.0.0'

Usage Example

import nxt.http.APICall;
import nxt.http.callers.*;
import nxt.http.responses.*;

public class ShamwariClient {
public static void main(String[] args) throws Exception {
// Get account
AccountResponse account = GetAccountCall.create("NXT-address")
.includeLessors(true)
.includeTotems(true)
.call();

System.out.println("Balance: " + account.getBalanceFQT());

// Send transaction
SendMoneyCall send = SendMoneyCall.create(
"your_secret_phrase",
"NXT-recipient",
100000000L // 1 QKP in NQT
);

TransactionResponse tx = send.call();
System.out.println("Transaction ID: " + tx.getTransactionId());
}
}

TypeScript/JavaScript Client

Available as npm package:

npm install @shamwari/crypto-ts
import { ShamwariClient } from '@shamwari/crypto-ts';

const client = new ShamwariClient({
host: 'localhost',
port: 6876
});

// Get blockchain status
const status = await client.getBlockchainStatus();

// Get account
const account = await client.getAccount({
account: 'NXT-address',
includeLessors: true
});

// Send transaction
const tx = await client.sendMoney({
secretPhrase: 'your_secret_phrase',
recipient: 'NXT-recipient',
amountNQT: 100000000
});

Python Client

from shamwari import ShamwariClient

client = ShamwariClient('http://localhost:6876')

# Get status
status = client.get_blockchain_status()

# Get account
account = client.get_account('NXT-address')

# Send transaction
tx = client.send_money(
secret_phrase='your_secret_phrase',
recipient='NXT-recipient',
amount_nqt=100000000
)

Go Client

import "github.com/shamwari-crypto/go-shamwari"

client := shamwari.NewClient("http://localhost:6876")

status, _ := client.GetBlockchainStatus()
account, _ := client.GetAccount("NXT-address")
tx, _ := client.SendMoney(&shamwari.SendMoneyParams{
SecretPhrase: "your_secret_phrase",
Recipient: "NXT-recipient",
AmountNQT: 100000000,
})

API Conventions

All clients follow these conventions:

  1. Request Types: Map directly to Shamwari API endpoints
  2. Parameters: Named explicitly (no positional args for complex calls)
  3. Responses: Typed response objects with helper methods
  4. Errors: Throw on validation/server errors
  5. Async: Promise/async-await for network operations

Community Libraries

LanguageRepositoryStatus
TypeScriptshamwari-crypto-tsStable
Pythonshamwari-pyBeta
Gogo-shamwariAlpha
Rustshamwari-rsExperimental

Contributing a Client

Community client libraries are welcome. Please:

  1. Open an issue in the main repository
  2. Follow the API specification exactly
  3. Include comprehensive tests
  4. Submit PR with documentation