The ZHTP API provides a comprehensive interface for interacting with the ZHTP node orchestrator. The API is built on the ZHTP protocol and provides endpoints for identity management, blockchain operations, network coordination, storage, and more.
- Protocol: ZHTP/1.0
- Default Port: 9333
- Content-Type: application/json
- Authentication: API key and user ID based
Retrieve a list of connected network peers.
GET /api/v1/blockchain/network/peersResponse:
{
"status": "success",
"peer_count": 5,
"peers": [
{
"peer_id": "peer_1",
"peer_type": "local",
"status": "connected",
"connection_time": 1697834400
}
]
}Peer Types:
local- Local mesh peersregional- Regional mesh peersglobal- Global mesh peersrelay- Relay peers
Retrieve comprehensive network statistics and health metrics.
GET /api/v1/blockchain/network/statsResponse:
{
"status": "success",
"mesh_status": {
"internet_connected": true,
"mesh_connected": true,
"connectivity_percentage": 85.5,
"coverage": 72.3,
"stability": 94.2
},
"traffic_stats": {
"bytes_sent": 1024000,
"bytes_received": 2048000,
"packets_sent": 500,
"packets_received": 750,
"connection_count": 12
},
"peer_distribution": {
"active_peers": 15,
"local_peers": 8,
"regional_peers": 5,
"global_peers": 2,
"relay_peers": 0
}
}Add a new peer to the network.
POST /api/v1/blockchain/network/peer/addRequest Body:
{
"peer_address": "192.168.1.100:33444",
"peer_type": "local"
}Response:
{
"status": "success",
"peer_id": "peer_12345",
"message": "Successfully initiated connection to peer 192.168.1.100:33444",
"connected": true
}Remove a peer from the network.
DELETE /api/v1/blockchain/network/peer/{peer_id}Response:
{
"status": "success",
"peer_id": "peer_12345",
"message": "Successfully initiated disconnection from peer peer_12345",
"removed": true
}Create a new zero-knowledge DID identity.
POST /api/v1/identity/createRequest Body:
{
"name": "Alice",
"identity_type": "human",
"recovery_options": ["email", "phone"]
}Response:
{
"status": "success",
"identity_id": "did:zhtp:abc123...",
"public_key": "04a1b2c3...",
"created_at": 1697834400
}Verify an existing identity.
POST /api/v1/identity/verifyRequest Body:
{
"identity_id": "did:zhtp:abc123...",
"proof": "proof_data_here"
}Response:
{
"status": "success",
"verified": true,
"verification_level": "full",
"expires_at": 1697920800
}Get a list of all identities.
GET /api/v1/identity/listResponse:
{
"status": "success",
"identities": [
{
"identity_id": "did:zhtp:abc123...",
"name": "Alice",
"type": "human",
"status": "active",
"created_at": 1697834400
}
]
}Get the current blockchain status and statistics.
GET /api/v1/blockchain/statusResponse:
{
"status": "active",
"height": 12345,
"pending_transactions": 8,
"total_identities": 150,
"blockchain_ready": true,
"last_block_time": 1697834400,
"network_hash_rate": "1.5 TH/s"
}Retrieve information about a specific transaction.
GET /api/v1/blockchain/transaction/{tx_hash}Response:
{
"status": "success",
"transaction": {
"hash": "0xabc123...",
"block_height": 12340,
"from": "did:zhtp:sender...",
"to": "did:zhtp:receiver...",
"amount": 100,
"fee": 1,
"timestamp": 1697834000,
"confirmations": 5,
"status": "confirmed"
}
}Submit a new transaction to the blockchain.
POST /api/v1/blockchain/transaction/submitRequest Body:
{
"from": "did:zhtp:sender...",
"to": "did:zhtp:receiver...",
"amount": 100,
"fee": 1,
"signature": "signature_data_here"
}Response:
{
"status": "success",
"transaction_hash": "0xabc123...",
"message": "Transaction submitted successfully"
}Create a new wallet.
POST /api/v1/wallet/createRequest Body:
{
"name": "MyWallet",
"wallet_type": "citizen"
}Response:
{
"status": "success",
"wallet_address": "zhtp1abc123...",
"public_key": "04a1b2c3...",
"wallet_type": "citizen"
}Get the balance for a specific wallet.
GET /api/v1/wallet/balance/{address}Response:
{
"status": "success",
"address": "zhtp1abc123...",
"balance": 1500,
"pending_balance": 50,
"currency": "ZHTP"
}Transfer funds between wallets.
POST /api/v1/wallet/transferRequest Body:
{
"from": "zhtp1sender...",
"to": "zhtp1receiver...",
"amount": 100,
"memo": "Payment for services"
}Response:
{
"status": "success",
"transaction_hash": "0xabc123...",
"fee": 1,
"total_amount": 101
}Store content in the distributed storage system.
POST /api/v1/storage/storeRequest Body:
{
"content": "base64_encoded_content",
"content_type": "text/plain",
"encryption": true,
"redundancy": 3
}Response:
{
"status": "success",
"content_hash": "Qm...",
"storage_nodes": 5,
"cost": 10
}Retrieve content from distributed storage.
GET /api/v1/storage/retrieve/{content_hash}Response:
{
"status": "success",
"content": "base64_encoded_content",
"content_type": "text/plain",
"retrieved_from": ["node1", "node2"],
"cost": 2
}Get information about the DAO governance system.
GET /api/v1/dao/infoResponse:
{
"status": "success",
"dao": {
"total_members": 500,
"active_proposals": 3,
"treasury_balance": 100000,
"voting_power_distributed": 45000,
"current_period": "voting"
}
}Create a new DAO proposal.
POST /api/v1/dao/proposeRequest Body:
{
"title": "Increase UBI Rate",
"description": "Proposal to increase the UBI rate from 10 to 15 ZHTP per day",
"proposal_type": "economic",
"voting_duration": 604800
}Response:
{
"status": "success",
"proposal_id": "prop_123",
"voting_starts": 1697834400,
"voting_ends": 1698439200
}Cast a vote on a DAO proposal.
POST /api/v1/dao/voteRequest Body:
{
"proposal_id": "prop_123",
"choice": "yes",
"voting_power": 100
}Response:
{
"status": "success",
"vote_recorded": true,
"voting_power_used": 100,
"current_tally": {
"yes": 15000,
"no": 8000,
"abstain": 2000
}
}Claim Universal Basic Income.
POST /api/v1/dao/claim-ubiResponse:
{
"status": "success",
"amount_claimed": 10,
"next_claim_available": 1697920800,
"total_claimed": 300
}Get overall system health status.
GET /api/v1/healthResponse:
{
"status": "healthy",
"version": "1.0.0",
"protocol": "ZHTP/1.0",
"timestamp": 1697834400,
"handlers": ["identity", "blockchain", "storage", "protocol"]
}Get comprehensive system statistics.
GET /api/v1/statsResponse:
{
"status": "active",
"handlers_registered": 4,
"middleware_layers": 4,
"requests_processed": 15847,
"uptime": 86400,
"identity_stats": {
"total_identities": 150
},
"blockchain_stats": {
"block_count": 12345,
"transaction_count": 98765
},
"storage_stats": {
"total_storage_used": 1073741824,
"total_content_count": 5000
},
"economic_stats": {
"total_supply": 1000000,
"circulating_supply": 750000
}
}Content-Type: application/json
X-API-Key: your-api-key
X-User-ID: your-user-idContent-Type: application/json
X-Handler: HandlerName
X-Protocol: ZHTP/1.0
X-Response-Time: 45ms{
"status": "error",
"error_code": "INVALID_REQUEST",
"message": "Detailed error description",
"timestamp": 1697834400
}INVALID_REQUEST- Malformed requestUNAUTHORIZED- Authentication requiredFORBIDDEN- Insufficient permissionsNOT_FOUND- Resource not foundRATE_LIMITED- Too many requestsINTERNAL_ERROR- Server error
Include your API key in the request headers:
X-API-Key: your-api-key-hereInclude your user ID for user-specific operations:
X-User-ID: did:zhtp:your-identity-here- Default: 100 requests per minute per API key
- Burst: Up to 20 requests in 10 seconds
- Headers included in response:
X-RateLimit-Limit: Rate limitX-RateLimit-Remaining: Remaining requestsX-RateLimit-Reset: Reset time
Some operations require ZHTP token payments:
- Storage operations: Based on size and redundancy
- High-priority transactions: Network fee
- Premium API access: Subscription model
Real-time updates available via WebSocket connections:
ws://localhost:9333/api/v1/wsnetwork.peers- Peer connection updatesblockchain.transactions- New transactionsblockchain.blocks- New blocksdao.proposals- Proposal updatessystem.health- Health status changes
{
"type": "update",
"topic": "network.peers",
"data": {
"peer_id": "peer_123",
"event": "connected",
"timestamp": 1697834400
}
}Official SDKs available for:
- Rust (native)
- JavaScript/TypeScript
- Python
- Go
Example usage (JavaScript):
import { ZhtpClient } from '@zhtp/sdk';
const client = new ZhtpClient({
endpoint: 'http://localhost:9333',
apiKey: 'your-api-key'
});
const peers = await client.network.getPeers();
console.log(`Connected peers: ${peers.peer_count}`);This API reference provides comprehensive access to all ZHTP node orchestrator functionality, enabling developers to build applications on the ZHTP network with zero-knowledge privacy, economic incentives, and decentralized governance.