Documentation
Kanari DocsDeveloper documentation
Kanari Documentation
API Reference
Documentation for interacting with Kanari Network via API.
Last updated
API Reference
The Kanari Network provides a suite of APIs for developers to interact with the blockchain, manage metadata, deploy smart contracts, and query transaction data. It is divided into two main systems: the REST API for general data and wallet management, and the JSON-RPC API for deep Node interactions and Move Modules.
Authentication
All REST API requests require an API key passed in the header:
Authorization: Bearer YOUR_API_KEY
Part 1: REST API
The REST API provides a set of endpoints for managing accounts, token balances, and transactions.
Wallet & Token API
Endpoints for managing accounts and token operations.
1. Get Balance
GET /accounts/{address}/balance
Returns the token balance for a specific address.
Response:
{
"address": "0x1234...",
"balance": 1500.50,
"currency": "KANARI",
"token" : {
"name": "Kanari Token",
"symbol": "KANARI",
"decimals": 18
}
}
2. Initiate Transfer
POST /transfer
Send tokens from one account to another.
Request Body:
{
"to": "0xrecipient...address",
"amount": 50.0,
"memo": "Payment for services"
}
Part 2: JSON-RPC API
The JSON-RPC server is used for low-level node interactions, particularly for publishing and querying Move modules.
Request Wrapper
All requests use the JSON-RPC 2.0 wrapper via POST with Content-Type: application/json:
{
"jsonrpc": "2.0",
"method": "kanari_<methodName>",
"params": { /* method-specific fields */ },
"id": 1
}
Module Methods
kanari_publishModule
Publish a new Move module to the network.
Request params:
{
"sender": "0x...",
"module_bytes": [1,2,3],
"module_name": "MyModule",
"gas_limit": 1000000,
"gas_price": 1,
"sequence_number": 0,
"signature": null,
"execute_immediate": false
}
Response (Success):
{
"jsonrpc": "2.0",
"result": { "hash": "<tx-hash-hex>", "status": "pending", "action": "publish" },
"id": 1
}
kanari_upgradeModule
Upgrade an existing module. The request params are identical to kanari_publishModule.
Response (Success):
{
"jsonrpc": "2.0",
"result": { "hash": "<tx-hash>", "status": "pending", "action": "upgrade" },
"id": 1
}
kanari_getModule
Fetch module info and bytecode.
Request params:
{ "address": "0x...", "name": "MyModule" }
Response result:
{
"address": "0x...",
"name": "MyModule",
"bytecode_hash": "<blake3-hex>",
"size": 1234,
"dependencies": []
}
kanari_listModules
List all modules available in the runtime. Send an empty object {} as params.
kanari_verifyModule
Verify module bytecode locally without publishing.
Request params:
{ "module_bytes": [1,2,3] }
cURL Examples
Publish a Module (Submit Pending TX):
curl -X POST http://127.0.0.1:19001/rpc \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"kanari_publishModule","params":{"sender":"0x1","module_bytes":[1,2,3],"module_name":"M","gas_limit":1000000,"gas_price":1,"sequence_number":0},"id":1}'
Get a Module:
curl -X POST http://127.0.0.1:19001/rpc \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"kanari_getModule","params":{"address":"0x1","name":"M"},"id":1}'
Error Codes
The API uses standard HTTP status codes:
| Code | Description |
|---|---|
200 | Success - Request completed successfully. |
400 | Bad Request - Invalid parameters. |
401 | Unauthorized - Invalid or missing API key. |
404 | Not Found - The requested resource does not exist. |
500 | Internal Server Error - Something went wrong on our end. |