Complete reference for KnexCoin's REST and RPC APIs.
KnexCoin provides two API layers:
| API | Port | Purpose |
|---|---|---|
| Flask API | 8080 | High-level operations (Python) |
| Node API | 7076 | Low-level RPC (Rust) |
Base URL: http://localhost:8080/api
Creates a new account on the network.
POST /api/register
Content-Type: application/jsonRequest:
{
"public_key": "3abc...xyz",
"mode": "custodial"
}Response:
{
"success": true,
"address": "knex_3abc...xyz",
"mode": "custodial"
}| Field | Type | Description |
|---|---|---|
public_key |
string | Ed25519 public key (hex) |
mode |
string | custodial or self-custody |
Returns account balance and pending amounts.
GET /api/balance/{address}Response:
{
"address": "knex_3abc...xyz",
"balance": "1000000000",
"pending": "50000000",
"block_count": 42
}| Field | Type | Description |
|---|---|---|
balance |
string | Current balance (raw units) |
pending |
string | Unclaimed incoming (raw units) |
block_count |
integer | Number of blocks in chain |
Creates a send transaction.
POST /api/send
Content-Type: application/jsonRequest:
{
"from": "knex_3abc...xyz",
"to": "knex_1def...uvw",
"amount": "100000000",
"signature": "abc123...",
"work": "0000000012345678"
}Response:
{
"success": true,
"hash": "block_hash_here",
"pending_for": "knex_1def...uvw"
}Claims pending balance.
POST /api/receive
Content-Type: application/jsonRequest:
{
"account": "knex_1def...uvw",
"source_hash": "send_block_hash",
"signature": "abc123...",
"work": "0000000012345678"
}Response:
{
"success": true,
"hash": "receive_block_hash",
"new_balance": "1100000000"
}Lists pending receivables for an account.
GET /api/pending/{address}Response:
{
"address": "knex_1def...uvw",
"pending": [
{
"hash": "send_block_hash_1",
"amount": "50000000",
"from": "knex_3abc...xyz"
},
{
"hash": "send_block_hash_2",
"amount": "25000000",
"from": "knex_9ghi...rst"
}
]
}POST /api/faucet
Content-Type: application/jsonRequest:
{
"address": "knex_3abc...xyz"
}Response:
{
"success": true,
"amount": "10000000000",
"hash": "faucet_send_hash"
}GET /api/block/{hash}Response:
{
"hash": "block_hash",
"type": "send",
"account": "knex_3abc...xyz",
"previous": "previous_hash",
"representative": "knex_rep...xyz",
"balance": "900000000",
"link": "knex_1def...uvw",
"signature": "abc123...",
"work": "0000000012345678",
"height": 42,
"timestamp": 1706745600
}GET /api/history/{address}?count=10&offset=0Response:
{
"address": "knex_3abc...xyz",
"history": [
{
"hash": "block_hash_1",
"type": "send",
"amount": "100000000",
"timestamp": 1706745600
},
{
"hash": "block_hash_2",
"type": "receive",
"amount": "50000000",
"timestamp": 1706742000
}
]
}Base URL: http://localhost:7076
POST /
Content-Type: application/jsonRequest:
{
"action": "account_info",
"account": "knex_3abc...xyz"
}Response:
{
"frontier": "latest_block_hash",
"balance": "1000000000",
"block_count": "42",
"representative": "knex_rep...xyz",
"modified_timestamp": "1706745600"
}POST /
Content-Type: application/jsonRequest:
{
"action": "block_info",
"hash": "block_hash"
}Response:
{
"block_account": "knex_3abc...xyz",
"amount": "100000000",
"balance": "900000000",
"height": "42",
"confirmed": "true",
"contents": {
"type": "send",
"previous": "prev_hash",
"link": "destination",
"representative": "rep_address",
"signature": "sig...",
"work": "0000000012345678"
}
}Submit a pre-constructed block.
POST /
Content-Type: application/jsonRequest:
{
"action": "process",
"block": {
"type": "send",
"account": "knex_3abc...xyz",
"previous": "frontier_hash",
"representative": "knex_rep...xyz",
"balance": "900000000",
"link": "knex_1def...uvw",
"signature": "abc123...",
"work": "0000000012345678"
}
}Response:
{
"hash": "new_block_hash"
}Generate proof-of-work for spam prevention.
POST /
Content-Type: application/jsonRequest:
{
"action": "work_generate",
"hash": "frontier_hash",
"difficulty": "fffffff800000000"
}Response:
{
"work": "0000000012345678",
"difficulty": "fffffffa12345678",
"multiplier": "1.5"
}POST /
Content-Type: application/jsonRequest:
{
"action": "validator_info",
"account": "knex_validator...xyz"
}Response:
{
"stake": "10000000000000",
"is_active": true,
"reputation": 95,
"uptime_seconds": 2592000,
"validations_count": 12345,
"failures_count": 2
}POST /
Content-Type: application/jsonRequest:
{
"action": "validators",
"count": 100
}Response:
{
"validators": [
{
"account": "knex_val1...xyz",
"stake": "1000000000000000",
"reputation": 98
},
{
"account": "knex_val2...xyz",
"stake": "500000000000000",
"reputation": 95
}
]
}POST /
Content-Type: application/jsonRequest:
{
"action": "peers"
}Response:
{
"peers": {
"[::ffff:192.168.1.1]:26656": "3",
"[::ffff:10.0.0.1]:26656": "2"
}
}POST /
Content-Type: application/jsonRequest:
{
"action": "version"
}Response:
{
"rpc_version": "1",
"node_vendor": "KnexCoin Node",
"protocol_version": "20",
"build_info": "release-1.0.0"
}{
"error": "error_code",
"message": "Human readable description"
}| Code | Description |
|---|---|
invalid_account |
Malformed address |
account_not_found |
Account doesn't exist |
insufficient_balance |
Not enough funds |
invalid_signature |
Signature verification failed |
invalid_work |
PoW below threshold |
gap_previous |
Previous block doesn't match frontier |
fork |
Conflicting block detected |
| Endpoint | Limit |
|---|---|
/api/* |
100 req/min |
/api/faucet |
1 req/hour |
| Node RPC | 1000 req/min |
const ws = new WebSocket('ws://localhost:7077');{
"action": "subscribe",
"topic": "account",
"accounts": ["knex_3abc...xyz"]
}{
"topic": "account",
"account": "knex_3abc...xyz",
"block": {
"hash": "new_block_hash",
"type": "receive",
"amount": "50000000"
}
}import { KnexClient } from '@knexcoin/sdk';
const client = new KnexClient('http://localhost:7076');
// Get balance
const info = await client.accountInfo('knex_3abc...xyz');
console.log(info.balance);
// Send transaction
const result = await client.send({
from: wallet,
to: 'knex_1def...uvw',
amount: '100000000'
});from knexcoin import KnexClient
client = KnexClient('http://localhost:7076')
# Get balance
info = client.account_info('knex_3abc...xyz')
print(info['balance'])
# Send transaction
result = client.send(
from_account=wallet,
to='knex_1def...uvw',
amount='100000000'
)