Operator API
pNode RPC (pRPC) Reference
11 min
complete reference for all json rpc 2 0 methods available in xandeum pnode overview the xandeum pnode prpc api uses json rpc 2 0 protocol over http post requests all requests should be sent to the /prpc endpoint !!! info "base url" http //\<pnode ip> 6000/rpc default `http //127 0 0 1 6000/rpc` (private) network architecture the pnode uses several network ports for different services port 6000 prpc api server (configurable ip binding) port 80 statistics dashboard (localhost only) port 9001 gossip protocol for peer discovery and communication port 5000 atlas server connection for data streaming (fixed endpoint) available methods \=== "get version" returns the current version of the pnode software \### request ```json { "jsonrpc" "2 0", "method" "get version", "id" 1 } ``` \### response ```json { "jsonrpc" "2 0", "result" { "version" "1 0 0" }, "id" 1 } ``` \### curl example ```bash curl x post http //127 0 0 1 6000/rpc \\ h "content type application/json" \\ d '{ "jsonrpc" "2 0", "method" "get version", "id" 1 }' ``` \=== "get stats" returns comprehensive statistics about the pnode including system metrics, storage info, and network activity \### request ```json { "jsonrpc" "2 0", "method" "get stats", "id" 1 } ``` \### response ```json { "jsonrpc" "2 0", "result" { "metadata" { "total bytes" 1048576000, "total pages" 1000, "last updated" 1672531200 }, "stats" { "cpu percent" 15 5, "ram used" 536870912, "ram total" 8589934592, "uptime" 86400, "packets received" 1250, "packets sent" 980, "active streams" 5 }, "file size" 1048576000 }, "id" 1 } ``` \### response fields \| field | type | description | \| | | | \| `metadata total bytes` | number | total bytes processed | \| `metadata total pages` | number | total pages in storage | \| `metadata last updated` | number | unix timestamp of last update | \| `stats cpu percent` | number | current cpu usage percentage | \| `stats ram used` | number | ram used in bytes | \| `stats ram total` | number | total ram available in bytes | \| `stats uptime` | number | uptime in seconds | \| `stats packets received` | number | packets received per second | \| `stats packets sent` | number | packets sent per second | \| `stats active streams` | number | number of active network streams | \| `file size` | number | storage file size in bytes | \=== "get pods" returns a list of all known peer pnodes in the network with their status information \### request ```json { "jsonrpc" "2 0", "method" "get pods", "id" 1 } ``` \### response ```json { "jsonrpc" "2 0", "result" { "pods" \[ { "address" "192 168 1 100 9001", "version" "1 0 0", "last seen" "2023 12 01 14 30 00 utc", "last seen timestamp" 1672574200 }, { "address" "10 0 0 5 9001", "version" "1 0 1", "last seen" "2023 12 01 14 25 00 utc", "last seen timestamp" 1672573900 } ], "total count" 2 }, "id" 1 } ``` \### pod fields \| field | type | description | \| | | | \| `address` | string | ip address and port of the peer pnode | \| `version` | string | software version of the peer pnode | \| `last seen` | string | human readable timestamp of last contact | \| `last seen timestamp` | number | unix timestamp of last contact | \| `total count` | number | total number of known pnodes | error handling all errors follow the json rpc 2 0 specification and include standard error codes method not found { "jsonrpc" "2 0", "error" { "code" 32601, "message" "method not found" }, "id" 1 } internal error { "jsonrpc" "2 0", "error" { "code" 32603, "message" "internal error" }, "id" 1 } standard error codes code message description 32601 method not found the requested method does not exist 32603 internal error server encountered an internal error integration examples python example import requests import json def call prpc(method, params=none) payload = { "jsonrpc" "2 0", "method" method, "id" 1 } if params payload\["params"] = params response = requests post( "http //127 0 0 1 6000/rpc", json=payload, headers={"content type" "application/json"} ) return response json() \# get version version = call prpc("get version") print(f"pnode version {version\['result']\['version']}") \# get stats stats = call prpc("get stats") print(f"cpu usage {stats\['result']\['stats']\['cpu percent']}%") javascript/node js example const fetch = require('node fetch'); async function callprpc(method, params = null) { const payload = { jsonrpc "2 0", method method, id 1 }; if (params) payload params = params; const response = await fetch('http //127 0 0 1 6000/rpc', { method 'post', headers { 'content type' 'application/json' }, body json stringify(payload) }); return await response json(); } // usage (async () => { const version = await callprpc('get version'); console log(`pnode version ${version result version}`); const stats = await callprpc('get stats'); console log(`uptime ${stats result stats uptime} seconds`); })(); bash/curl example \#!/bin/bash prpc url="http //127 0 0 1 6000/rpc" \# function to call prpc call prpc() { local method=$1 curl s x post "$prpc url" \\ h "content type application/json" \\ d "{\\"jsonrpc\\" \\"2 0\\",\\"method\\" \\"$method\\",\\"id\\" 1}" } \# get version echo "getting version " call prpc "get version" | jq ' result version' \# get stats echo "getting stats " call prpc "get stats" | jq ' result stats cpu percent' !!! tip "installation" install the pod via apt sudo apt install pod !!! tip "rate limiting" there are currently no rate limits on the prpc api, but be mindful of resource usage when making frequent requests !!! warning "security" when using rpc ip 0 0 0 0 , your prpc api will be accessible from any network interface ensure proper firewall rules are in place
