Skip to main content

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:

ParameterDescription
adminPasswordAdmin password for configuration changes
secretPhraseAccount passphrase for signing transactions
sharedPiecePart 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 errors
  • errorDescription: Error message if applicable
  • requestProcessingTime: Request processing time in milliseconds

Error Codes

CodeDescription
1Incorrect request
2Unknown request type
3Unknown account
4Unknown block
5Insufficient balance
6Not enough funds
7Invalid parameter
8Already have
9Deadline already passed
10Phasing only
40Forbidden host
50Bad request

Common Parameters

ParameterTypeDescription
requestTypestringAPI endpoint name (required)
chainintChain ID (for multi-chain)
requireBlocklongBlock ID required for response
requireLastBlocklongLast block ID required
secretPhrasestringAccount passphrase
publicKeystringAccount public key (hex)
accountstringAccount ID (NXT-format or numeric)
adminPasswordstringAdmin password
firstIndexintPagination start index (default: 0)
lastIndexintPagination end index (default: MAX)
includeLessorsbooleanInclude lessor info (default: false)
includeCurrenciesbooleanInclude currency holdings (default: false)
includeTotemsbooleanInclude totem holdings (default: false)
includeEffectiveBalancebooleanInclude 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:

TagCategoryDescription
ACCOUNTSAccount queriesAccount balances, properties, permissions
BLOCKSBlock queriesBlock information and chain status
TRANSACTIONSTransaction opsCreate, sign, broadcast, retrieve transactions
AEAsset ExchangeTotem creation, transfer, trading
MSMonetary SystemCurrency creation, exchange, lending
CONTRACTSSmart contractsWASM contract file management
PHASINGPhasingTime-locked transactions, voting
SHUFFLINGPrivacy shufflesConfidential asset mixing
NETWORKNetworkingPeer discovery and management
PAYMENTSPaymentsCurrency payment operations
LOANSLendingCurrency lending and borrowing
SUBSCRIPTIONSSubscriptionsSubscription service management
CERTIFICATECertificatesDigital certificate issuance
AGENT_ATTESTATIONAgent AttestationAgent identity and attestation
MESSAGESMessagesEncrypted and plain messaging
TOKENSTotemsTotem token operations
DEBUGDebugAdministrative functions
UTILSUtilitiesEncryption, encoding, hashing

Rate Limiting

Endpoint TypeLimit
Public read APIsNo limit
Write APIs10 req/s per IP
Admin APIsAuthenticated 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.