XTE and XTCASH documentation

XTE and XTCASH documentation

  • Getting Started
  • About
  • FAQ
  • Guides
  • For Developers

›API Documentation

For Developers

  • Developer Resources
  • Local Testnet
  • API Documentation

    • Daemon JSON RPC API
    • Daemon HTTP RPC API
    • Wallet RPC API
    • XTEservice Wallet RPC API
    • RPC Errors
Edit

Daemon HTTP RPC API

The daemon HTTP RPC is a HTTP server which provides additional information regarding network and daemon connections.

Currently we support the following official client bindings:

  • NodeJS
  • PHP
  • Python
  • Go

Installation

NodeJS
PHP
Python
Go
npm i turtlecoin-rpc
composer require turtlecoin/turtlecoin-rpc-php
pip3 install turtlecoin
go get github.com/turtlecoin/turtlecoin-rpc-go

Interacting with the API

API endpoint example

http://localhost:11898

Configuration and Instantiation

To start the Daemon JSON RPC API server at http://localhost:11898, run:

TurtleCoind --rpc-bind-port=11898

To make the server accessible from another computer, use the --rpc-bind-ip 0.0.0.0 switch.

TurtleCoind --rpc-bind-ip=0.0.0.0 --rpc-bind-port=11898

To enable block explorer API access (like for getblocks, gettransactionpool, etc.), use the --enable-blockexplorer switch.

TurtleCoind --enable-blockexplorer

The above given switches can be combined to achieve remote access with block explorer methods as shown below.

TurtleCoind --enable-blockexplorer --rpc-bind-ip=0.0.0.0 --rpc-bind-port=11898

This would make the RPC server accessible at

http://<your ip address>:11898

and, locally at

http://localhost:11898

To make a HTTP RPC request to your Daemon RPC you should use a GET request that looks like this:

http://<service address>:<service port>

ParameterDescription
<service address>IP of Daemon RPC, if it is located on local machine it is either 127.0.0.1 or localhost
<service port>Daemon RPC port, by default it is bound to 11898 port, but it can be manually bound to any port you want
NodeJS
PHP
Python
Go
const TurtleCoind = require('turtlecoin-rpc').TurtleCoind

const daemon = new TurtleCoind({
host: '0.0.0.0', // ip address or hostname of the TurtleCoind host
port: 11898, // what port is the RPC server running on
timeout: 2000, // request timeout
ssl: false // whether we need to connect using SSL/TLS
})
<?php
use TurtleCoin\TurtleCoind;

$config = [
'rpcHost' => 'http://localhost',
'rpcPort' => 11898,
];

$turtlecoind = new TurtleCoind($config);
from turtlecoin import TurtleCoind

rpc_host = 'localhost'
rpc_port = 11898
turtlecoind = TurtleCoind(rpc_host, rpc_port)
import (
"fmt"
trpc "github.com/turtlecoin/turtlecoin-rpc-go"
)

rpcHost := "localhost"
rpcPort := 11898

daemon := trpc.TurtleCoind{
URL: rpcHost,
Port: rpcPort}

getheight

getheight() returns the height of the daemon and the network

No Input.

Output

ArgumentDescriptionFormat
heightCurrent daemon heightint
network_heightCurrent Network heightint
statusStatus of requeststring
Shell
NodeJS
PHP
Python
Go
curl http://localhost:11898/getheight
daemon.getHeight().then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $turtlecoind->getHeight();
echo $response;
response = turtlecoind.get_height()
print(response)
response := daemon.Height()
fmt.Println(response)

Expected Output

{
    "height":614214,
    "network_height":614218,
    "status":"OK"
}

getinfo

getinfo() returns information related to the network and daemon connection

No Input.

Output

ArgumentDescriptionFormat
alt_blocks_countthe number of blocks on alternative (split) chains since the start of the daemonint
difficultydifficulty of the top blockint
grey_peerlist_sizelist of peers that were alive but not any more (offline)int
hashrateestimated network hashrate for given block (top block if general chain info) = difficulty / 30s (block time target)int
heightdaemon height. index of the last locally stored block. different from network_height when syncing the network, or when just found a block.int
incoming_connections_countNumber of peers connected to and pulling from this daemon node.int
last_known_block_index?int
major_versionblockchain major version. such as hash algorithm changeint
minor_versionblockchain minor version. for example, difficulty algo adjustment. rarely used.int
network_heightblockchain length reported by peers. the longest value given by any connected peer.int
outgoing_connections_countnumber of outgoing connections from the daemonint
start_timethe time when this daemon was started. epoch time in secondsint
statusStatus of requeststring
supported_heightthe height of the blockchain for supported fork. if forked after this block height, this version does not support itint
syncedsync status. does the height of this node match the height of the network?bool
testnetwhether the daemon is on testnet or notbool
tx_countTotal number of non-coinbase transaction in the chain.int
tx_pool_sizeNumber of transactions that have been broadcast but not included in a block.int
upgrade_heightspre-determined fork heights. blockchain heights where it forked.array
versionversion of the daemon softwarestring
white_peerlist_sizelist of online peersint
Shell
NodeJS
PHP
Python
Go
curl http://localhost:11898/getinfo
daemon.getInfo().then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $turtlecoind->getInfo();
echo $response;
response = turtlecoind.get_info()
print(response)
response := daemon.Info()
fmt.Println(response)

Expected Output

{
    "alt_blocks_count":1,
    "difficulty":250340644,
    "grey_peerlist_size":493,
    "hashrate":8344688,
    "height":614321,
    "incoming_connections_count":28,
    "last_known_block_index":614319,
    "major_version":4,
    "minor_version":0,
    "network_height":614321,
    "outgoing_connections_count":8,
    "start_time":1531403048,
    "status":"OK",
    "supported_height":620000,
    "synced":true,
    "testnet":false,
    "tx_count":720189,
    "tx_pool_size":0,
    "upgrade_heights":[
        187000,
        350000,
        440000,
        620000,
        .....
    ],
    "version":"0.6.3",
    "white_peerlist_size":43
}

gettransactions

gettransactions() method returns list of missed transactions. "Missed transactions" are invalid transactions in the sense that they do not exist in the blockchain. Input should include the transaction hashes to check. Try figuring that out. This method is likely to go away in near future.

No Input

Output

ArgumentDescriptionFormat
missed_txarray of missed transactionsarray
statusStatus of requeststring
txs_as_hexarray of hex values of missed transactionsarray
Shell
NodeJS
PHP
Python
Go
curl http://localhost:11898/gettransactions
daemon.getTransactions({
hashes: [
'549828e75151982b0e51b27e8f53b26ebc174f0ef78063984c8952b13e2a3564',
'549828e75151982b0e51b27e8f53b26ebc174f0ef78063984c8952b13e2a3563'
]
}).then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $turtlecoind->getTransactions();
echo $response;
response = turtlecoind.get_transactions()
print(response)
Not Implemented

Expected Output

{
    "missed_tx":[],
    "status":"OK",
    "txs_as_hex":[]
}

getpeers

getpeers() method returns the list of peers connected to the daemon

No Input.

Output

ArgumentDescriptionFormat
peersarray of peers (peer_ip:peer_port)array
statusStatus of requeststring
Shell
NodeJS
PHP
Python
Go
curl http://localhost:11898/getpeers
daemon.getPeers().then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $turtlecoind->getPeers();
echo $response;
response = turtlecoind.get_peers()
print(response)
response := daemon.Peers()
fmt.Println(response)

Expected Output

{
    "peers":[
        "192.222.157.172:11897",
        "94.23.49.75:11897",
        "112.78.10.43:11897",
        .....
    ],
    "status":"OK"
}

feeinfo

feeinfo() method returns information about the fee set for the remote node.

No Input.

Output

ArgumentDescriptionFormat
addressaddress to which the fee is paidstring
amountfee amountint
statusStatus of fees for the nodestring
Shell
NodeJS
PHP
Python
Go
curl http://localhost:11898/feeinfo
daemon.feeInfo().then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $turtlecoind->getFeeInfo();
echo $response;
response = turtlecoind.get_fee_info()
print(response)
response := daemon.Fee()
fmt.Println(response)

Expected Output

{
    "address":"",
    "amount":0,
    "status":"Node's fee address is not set"
}

License

Creative Commons License

The content in this document was originally written by the Bytecoin (BCN) Developers. It is licensed under the CC BY SA 3.0 license. The source material can be found at the Bytecoin Wiki.

TRRXITTE Int., incorporate and TurtleCoin developers have altered and adapted the content to suit our implementation of the API. This was done independently of the Bytecoin development team. They neither endorse or acknowledge our changes. Feel free to adopt or change our content as per the CC BY SA 3.0 license requirements.

Last updated on 4.7.2024
← Daemon JSON RPC APIWallet RPC API →
  • Installation
  • Interacting with the API
    • API endpoint example
    • Configuration and Instantiation
  • getheight
  • getinfo
  • gettransactions
  • getpeers
  • feeinfo
  • License
XTE and XTCASH documentation
Docs
Getting StartedAboutGuidesDeveloper Resources
Community
Generalx.com
More
GitHubStar
Copyright © 2024 TRRXITTE Int., incorporate
Docs released under the MIT License
cryptocurrencies released under the GNU General Public V3 License