LibreMoney

2. Основная часть

2.8. API (RestAPI)

Операции для работы с серверной частью

Get Constants

Запрос на получение списка всех констант, используемых сервером, и их текущих значений.

Request

http://localhost:1400/api/getConstants

Запрос

{
     "maxBlockPayloadLength":40800,
     "genesisAccountId":"GENESISACC",
     "genesisBlockId":"GENESISBLK",
     "transactionTypes":
     [
          {
               "description":"Payment","value":0,"subtypes":
               [
                    {"description":"Ordinary payment","value":0}
               ]
          },
          {
               "description":"Messaging","value":1,"subtypes":
               [
                    {"description":"Arbitrary message","value":0},
                    {"description":"Alias assignment","value":1},
                    {"description":"Poll creation","value":2},
                    {"description":"Vote casting","value":3},
                    {"description":"Hub terminal announcement","value":4},
                    {"description":"Account info","value":5}
               ]
          },
          {
               "description":"Colored coins","value":2,"subtypes":
               [
                    {"description":"Asset issuance","value":0},
                    {"description":"Asset transfer","value":1},
                    {"description":"Ask order placement","value":2},
                    {"description":"Bid order placement","value":3},
                    {"description":"Ask order cancellation","value":4},
                    {"description":"Bid order cancellation","value":5}
               ]
          },
          {
               "description":"Digital goods","value":3,"subtypes":
               [
                    {"description":"Listing","value":0},
                    {"description":"Delisting","value":1},
                    {"description":"Price change","value":2},
                    {"description":"Quantity change","value":3},
                    {"description":"Purchase","value":4},
                    {"description":"Delivery","value":5},
                    {"description":"Feedback","value":6},
                    {"description":"Refund","value":7}
               ]
          },
          {
               "description":"Account Control","value":4,"subtypes":
               [
                    {"description":"Effective balance leasing","value":0}
               ]
          }
     ],
     "peerStates":
          [
               {"description":"Non-connected","value":0},
               {"description":"Connected","value":1},
               {"description":"Disconnected","value":2}
          ]
}

Где:

Пример

Запрос:

http://localhost:1400/api/getConstants

Ответ:

{
     "maxBlockPayloadLength":40800,
     "genesisAccountId":"1739068987193023818",
     "genesisBlockId":"2680262203532249785",
     "transactionTypes":
     [
          {
               "description":"Payment","value":0,"subtypes":
               [
                    {"description":"Ordinary payment","value":0}
               ]
          },
          {
               "description":"Messaging","value":1,"subtypes":
               [
                    {"description":"Arbitrary message","value":0},
                    {"description":"Alias assignment","value":1},
                    {"description":"Poll creation","value":2},
                    {"description":"Vote casting","value":3},
                    {"description":"Hub terminal announcement","value":4},
                    {"description":"Account info","value":5}
               ]
          },
          {
               "description":"Colored coins","value":2,"subtypes":
               [
                    {"description":"Asset issuance","value":0},
                    {"description":"Asset transfer","value":1},
                    {"description":"Ask order placement","value":2},
                    {"description":"Bid order placement","value":3},
                    {"description":"Ask order cancellation","value":4},
                    {"description":"Bid order cancellation","value":5}
               ]
          },
          {
               "description":"Digital goods","value":3,"subtypes":
               [
                    {"description":"Listing","value":0},
                    {"description":"Delisting","value":1},
                    {"description":"Price change","value":2},
                    {"description":"Quantity change","value":3},
                    {"description":"Purchase","value":4},
                    {"description":"Delivery","value":5},
                    {"description":"Feedback","value":6},
                    {"description":"Refund","value":7}
               ]
          },
          {
               "description":"Account Control","value":4,"subtypes":
               [
                    {"description":"Effective balance leasing","value":0}
               ]
          }
     ],
     "peerStates":
     [
          {"description":"Non-connected","value":0},
          {"description":"Connected","value":1},
          {"description":"Disconnected","value":2}
     ],
     "maxArbitraryMessageLength":1000
}

Get My Info

возвращает данные сервера - хост и адрес.

Запрос

http://localhost:1400/api/getMyInfo

Ответ

{
     "host":       "HOSTNAME",
     "address":       "ADDRESS"
}

Где:

Пример

Запрос:

http://localhost:1400/api/getMyInfo

Ответ:

{
     "host":       "127.0.0.1",
     "address":    "127.0.0.1"
}

Get Peer

получает данные о заданном узле (peer)

Запрос

http://localhost:1400/api/getPeer?
     peer=PEERNAME

Где:

Ответ:

Информация возвращается в том виде и объеме, который хранится на сервере узла в файле web.xml file !

{
     "platform":          "PLATFORM",
     "blacklisted":       BLACKLIST,
     "shareAddress":      SHAREADD
     "application":       "LIBREMONEY",
     "weight":            WEIGHT,
     "hallmark":          "HALLMARK",
     "state":             1,
     "announcedAddress":  "ANNOUNCED",
     "downloadedVolume":  DLBYTES,
     "version":           "VERSION",
     "uploadedVolume":    ULBYTES
}

Где:

Пример

Запрос:

http://localhost:1400/api/getPeer?
     peer=23.88.104.217

Ответ:

{
     hallmark":           "ea53f569819ad8c40d62dd7e4c1f4895b2a3...",
     "downloadedVolume":  115001,
     "blacklisted":       false,
     "announcedAddress":  "mode.libremoney.org",
     "application":       "LIBREMONEY",
     "weight":            911527,
     "uploadedVolume":    4707,
     "state":             1,
     "version":           "0.9.9",
     "platform":          "lm.now.im",
     "shareAddress":      true
}

Get Peers

Возвращает все известные вашему клиенту узлы (peers), не зависимо от их состояния на данный момент.

Запрос

http://localhost:1400/api/getPeers

Результат:

Массив имен/адресов узлов:

{
     "peers":
          [
               "PEER",
               "PEER",
               "PEER"...
          ]
}

Пример

Запрос:

http://localhost:1400/api/getPeers

Ответ:

{
     "peers":
     [
          "188.226.176.151",
          "88.202.37.38",
          "87.211.164.253"...
     ]
}

Get State

Возвращает информацию о статусе/состоянии запрашиваемого сервера

Запрос

http://localhost:1400/api/getState

Ответ

{
     "numberOfPolls":             NUMPOLLS,
     "numberOfVotes":             NUMVOTES,
     "numberOfTrades":            NUMTRADES,
     "lastBlock":                 "LASTBLOCKID",
     "numberOfAliases":           NUMALIASES,
     "lastBlockchainFeeder":      "FEEDERPEER",
     "numberOfBlocks":            HEIGHT,
     "numberOfPeers":             NUMPEERS
     "totalMemory":               CURMEMORY,
     "freeMemory":                FREEMEMORY,
     "maxMemory":                 MAXMEMORY,
     "numberOfTransactions":      NUMTRANS,
     "numberOfUnlockedAccounts":  NUMUSERS,
     "version":                   "VERSION",
     "numberOfOrders":            NUMORDERS,
     "totalEffectiveBalance":  EFFECTIVEBALANCE
     "time":                      TIME,
     "availableProcessors":       NUMPROCESSORS,
     "numberOfAssets":            NUMASSETS,
     "cumulativeDifficulty":      "CUMEDIFF"
     "numberOfAccounts":          NUMACCOUNTS
}

Где:

Пример

Запрос:

http://localhost:1400/api/getState

Ответ:

{
     "numberOfPeers":868,
     "numberOfPolls":0,
     "numberOfVotes":0,
     "availableProcessors":4,
     "totalEffectiveBalance":991634266,
     "numberOfAccounts":33172,
     "numberOfUnlockedAccounts":0,
     "numberOfBlocks":126493,
     "numberOfOrders":0,
     "numberOfTransactions":182379,
     "version":"1.0.0",
     "maxMemory":477626368,
     "lastBlock":"4329081735143326181",
     "totalMemory":466092032,
     "numberOfAliases":85657,
     "cumulativeDifficulty":"3936422822105943",
     "numberOfTrades":0,
     "time":13671770,
     "numberOfAssets":0,
     "lastBlockchainFeeder":"cubie-solar.mjke.de",
     "freeMemory":135007384
}

Get Time

Получает текущее время в системе. Внимание ! В LibreMoney время исчисляется в секундах с момента генерации генезисного блока, т.е. с момента зарождения LibreMoney

Запрос

http://localhost:1400/api/getTime

Ответ

{
     "time":       TIME
}

Где:

Пример

Запрос:

http://localhost:1400/api/getTime

Ответ:

{
     "time":       417
}

Get Blockchain Status

Получить текущий статус blockchain

Запрос

http://localhost:1400/api/getBlockchainStatus

Ответ

{
    "lastBlock": "LASTBLK",
    "lastBlockchainFeederHeight": LASTHEIGHT,
    "time": TIME,
    "lastBlockchainFeeder": "FEEDERPEER",
    "numberOfBlocks": NUMBLKS,
    "isScanning": SCAN,
    "cumulativeDifficulty": "CUMDIF",
    "version": "VER"
}

Where:

Пример

Запрос:

http://localhost:1400/api/getBlockchainStatus

Ответ:

{
    "lastBlock": "3153685344875873318",
    "lastBlockchainFeederHeight": 95337,
    "time": 14604616,
    "lastBlockchainFeeder": "192.241.223.132",
    "numberOfBlocks": 95339,
    "isScanning": false,
    "cumulativeDifficulty": "2406110597084752",
    "version": "1.1.0"
}