Developers
  • SWT PROTOCOL
    • Introduction
    • Accounts
    • Transactions
    • Fees
    • Smart Contracts
  • GETTING STARTED
    • Network Node
      • Introduction
      • STEP 1:RENTING A LINUX VPS
      • STEP 2:INSTALLATION OF PUTTY
      • STEP 3:INSTALLATION OF FILEZILLA
      • STEP 4:VPS CONNECTION AND LINUX CONFIGURATION WITH PUTTY (SSH)
      • STEP 5:HOW TO SECURE YOUR VPS
      • STEP 6:USING TMUX THROUGH PUTTY
      • STEP 7:UPLOAD OF THE SWT SOFTWARE WITH FILEZILLA
      • STEP 8:EXTRACT THE SWT SOFTWARE FOLDER
      • STEP 9:RUNNING THE SWT NODE THROUGH TMUX
      • STEP 10:RUNNING THE MONITORING TOOLS
  • API REFERENCE
    • Apache Thrift API
      • Transactions
      • Blocks
      • Smart contract
      • Tokens
      • Wallets
      • Sync info
      • Data structures
    • REST API
      • GetBlocks()
      • GetNodeInfo()
      • GetBalance()
      • GetWalletInfo()
      • GetTokenBalance()
      • GetTransactionsByWallet()
      • GetTransactionInfo()
      • GetEstimatedFee()
      • GetContractByAddress()
      • GetContractFromTransaction()
      • GetContractMethods()
      • ContractValidation()
      • ContractCall()
      • TransactionPack()
      • TransactionExec()
  • SMART CONTRACTS
    • Creating "Hello-world" Smart Contract
    • Smart Contract Methods
    • Smart Contract Standarts
      • Token Smart Contract
      • Escrow Smart Contract
      • Stable coin Token
  • HOW TO REST API
    • Introduction
    • Retrieve a balance from the blockchain
    • Request a specific transaction from the blockchain
    • Sending Transactions to the SWT Blockchain
    • Validating and deploying a Smart Contract with REST API
Powered by GitBook
On this page
  • Summary
  • Description
  • Request
  • Response
  • Example Code
  1. API REFERENCE
  2. REST API

GetNodeInfo()

Summary

Route
Type
Example

/monitor/getnodeinfo

POST

http://176.113.80.7:62000/api/Monitor/GetNodeInfo

Description

Get statistical information about the specified network node. Note that any node owner can block the node from providing this information upon request

Request

IP address and port of the node, information about which is requested

Request Structure

The following set of parameters is used for request:

{

// Parameters common for all requests

// IP address of the node

"networkIp": "ip v4 address",

// Port on a remote node, if it differs from the default value

"networkPort": "u16_value"

}

Request Parameters

The pair networkIp and networkPort define the node, information about which is requested by the client. if networkAlias is set instead of these 2 parameters or simultaneously with them, networkAlias will be used, and the information will be received from the current default node in the network.

Response

JSON output depends on request type and its success.

If there’s an error accessing the node, request returns basic Result:

  • Success: False

  • Message:

If successful, requested information is returned

Response Structure

{

// Node identifier (public key of the node account)

"Id": "base58_value",

// Platform OS: 0 - Linux, 1 - Mac OS, 2 - Windows, 3 - Android, ост. - Unknown

"Platform": "u8_value",

// Software version build

"Version": "text",

// Number of top block in blockchain

"TopBlock": "u64_value",

// Network round when the node was launched

"StartRound": "u64_value",

// Current network round

"CurrentRound": "u64_value",

// Average round time in milliseconds calculated for the period between start round and current round

 "AveRoundMs": "u64_value",

// Node uptime from the time of its launch in milliseconds

"UptimeMs": "u64_value",

// List of the nodes in the gray list

"GrayList":

[

// Node identifier in the Graylist (list)

"base58_value",

...

 ],

// List of the nodes in the blacklist (list)

"BlackList":

[

// Node identifier in the blacklist

"base58_value",

...

]

}

Example Code

Python

import requests
import json
def GetNodeInfo():
    url =  'http://176.113.80.7:62000/api/Monitor/GetNodeInfo'
    headers = {
        'Content-type': 'application/json'
        , 'Accept': 'application/json'
        , 'Content-Encoding': 'utf-8'
        }
    data = {
        "authKey": "1a577a1f-d683-4a20-ab95-2cd31bf9844d"
        , "NetworkAlias":"Mainnet"
        }
    answer = requests.post(url, data=json.dumps(data), headers=headers)
    response = answer.json()
    print(response)
GetNodeInfo()

C++

#include <iostream>

#include <cpprest/http_client.h>
#include <cpprest/filestream.h>

using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::http;                  // Common HTTP functionality
using namespace web::http::client;          // HTTP client features
using namespace concurrency::streams;       // Asynchronous streams
using namespace web::json;

int main(int argc, char* argv[])
{
    web::json::value json_v;
    web::json::value json_return;
    json_v[L"authKey"] = web::json::value::string(L"");
    json_v[L"NetworkAlias"] = web::json::value::string(L"Mainnet");
    http_client client(U("http://176.113.80.7:62000"));

    client.request(web::http::methods::POST, U("/api/Monitor/GetNodeInfo"), json_v)
        .then([](const web::http::http_response& response) {
        return response.extract_json();
    })
        .then([&json_return](const pplx::task<web::json::value>& task) {
        try {
            json_return = task.get();
        }
        catch (const web::http::http_exception& e) {
            std::cout << "error " << e.what() << std::endl;
        }
    })
        .wait();

    std::wcout << json_return.serialize() << std::endl;

    return 0;
}

C#

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Program.Getinfo
{
    public class Getinfo
    {
        static readonly HttpClient client = new HttpClient();
        public class body
        {
            public string authKey { get; set; }
            public string networkAlias { get; set; }
        }
            public static async Task Main()
        {
            try
            {
                var body = new body
                {
                    authKey = "1a577a1f-d683-4a20-ab95-2cd31bf9844d",
                    networkAlias = "Mainnet",
                };
                var httpContent = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
                var response = await client.PostAsync("http://176.113.80.7:62000/api/Monitor/GetNodeInfo", httpContent);
                Console.WriteLine("RESPONSE=" + await response.Content.ReadAsStringAsync());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    }
}

PreviousGetBlocks()NextGetBalance()

Last updated 1 year ago