API Overview
The Shamwari Network exposes a comprehensive REST API for interacting with the blockchain. All endpoints return JSON responses and accept parameters via HTTP GET or POST.
Base URL
http://localhost:6876/nxt
With HTTPS (if enabled):
https://localhost:6877/nxt
Authentication
Most endpoints are public. Sensitive operations require:
| Parameter | Description |
|---|---|
adminPassword | Admin password for configuration changes |
secretPhrase | Account passphrase for signing transactions |
sharedPiece | Part of split secret for multi-party transaction signing |
Request Format
GET Requests
curl "http://localhost:6876/nxt?requestType=getAccount&account=NXT-xxxx"
POST Requests
curl -X POST http://localhost:6876/nxt \
-d "requestType=sendMoney" \
-d "secretPhrase=your_passphrase" \
-d "recipient=NXT-recipient" \
-d "amountNQT=100000000"
Response Format
All responses are JSON objects:
{
"requestType": "getAccount",
"account": "NXT-1234567890123456789",
"balanceFQT": "1000000000",
"errorCode": 0,
"errorDescription": ""
}
Response Fields
errorCode: 0 for success, non-zero for errorserrorDescription: Error message if applicablerequestProcessingTime: Request processing time in milliseconds
Error Codes
| Code | Description |
|---|---|
| 1 | Incorrect request |
| 2 | Unknown request type |
| 3 | Unknown account |
| 4 | Unknown block |
| 5 | Insufficient balance |
| 6 | Not enough funds |
| 7 | Invalid parameter |
| 8 | Already have |
| 9 | Deadline already passed |
| 10 | Phasing only |
| 40 | Forbidden host |
| 50 | Bad request |
Common Parameters
| Parameter | Type | Description |
|---|---|---|
requestType | string | API endpoint name (required) |
chain | int | Chain ID (for multi-chain) |
requireBlock | long | Block ID required for response |
requireLastBlock | long | Last block ID required |
secretPhrase | string | Account passphrase |
publicKey | string | Account public key (hex) |
account | string | Account ID (NXT-format or numeric) |
adminPassword | string | Admin password |
firstIndex | int | Pagination start index (default: 0) |
lastIndex | int | Pagination end index (default: MAX) |
includeLessors | boolean | Include lessor info (default: false) |
includeCurrencies | boolean | Include currency holdings (default: false) |
includeTotems | boolean | Include totem holdings (default: false) |
includeEffectiveBalance | boolean | Include effective balance (default: false) |
JSON Response Models
Shamwari uses standardized JSON response models defined in JSONData.java:
Account Response (JSONData.putAccount)
{
"account": "1234567890123456789",
"accountRS": "NXT-abcd-efgh-ijkl"
}
Totem Response (JSONData.totem)
{
"issuer": "1234567890",
"name": "Totem Name",
"description": "Totem Description",
"decimals": 8,
"quantityQNT": "100000000",
"totem": "123456789",
"hasPhasingTotemControl": true
}
Currency Response (JSONData.currency)
{
"currency": "123456789",
"issuer": "1234567890",
"name": "Currency Name",
"code": "CNY",
"description": "Currency Description",
"type": 3,
"sovereign": false,
"decimals": 8,
"initialSupplyQNT": "100000000000",
"currentSupplyQNT": "95000000000",
"maxSupplyQNT": "100000000000"
}
Transaction Response (JSONData.transaction)
{
"type": 2,
"subtype": 0,
"chain": 1,
"phased": false,
"timestamp": 123456789,
"deadline": 1440,
"senderPublicKey": "hex...",
"sender": "1234567890",
"recipient": "0987654321",
"amountMTA": "100000000",
"feeMTA": "1000000",
"signature": "hex...",
"fullHash": "hex...",
"transaction": "1234567890123456789",
"confirmations": 123,
"attachment": {}
}
API Tags
Endpoints are organized by tags for easier discovery:
| Tag | Category | Description |
|---|---|---|
| ACCOUNTS | Account queries | Account balances, properties, permissions |
| BLOCKS | Block queries | Block information and chain status |
| TRANSACTIONS | Transaction ops | Create, sign, broadcast, retrieve transactions |
| AE | Asset Exchange | Totem creation, transfer, trading |
| MS | Monetary System | Currency creation, exchange, lending |
| CONTRACTS | Smart contracts | WASM contract file management |
| PHASING | Phasing | Time-locked transactions, voting |
| SHUFFLING | Privacy shuffles | Confidential asset mixing |
| NETWORK | Networking | Peer discovery and management |
| PAYMENTS | Payments | Currency payment operations |
| LOANS | Lending | Currency lending and borrowing |
| SUBSCRIPTIONS | Subscriptions | Subscription service management |
| CERTIFICATE | Certificates | Digital certificate issuance |
| AGENT_ATTESTATION | Agent Attestation | Agent identity and attestation |
| MESSAGES | Messages | Encrypted and plain messaging |
| TOKENS | Totems | Totem token operations |
| DEBUG | Debug | Administrative functions |
| UTILS | Utilities | Encryption, encoding, hashing |
Rate Limiting
| Endpoint Type | Limit |
|---|---|
| Public read APIs | No limit |
| Write APIs | 10 req/s per IP |
| Admin APIs | Authenticated only |
API Console
The built-in API console provides interactive documentation:
http://localhost:6876/test.html
http://localhost:6876/index.html
Next Steps
Browse the API Reference for detailed endpoint documentation.