HOPRd Rest API v2 (2.0.0)
Download OpenAPI specification:Download
This Rest API enables developers to interact with a hoprd node programatically.
accountWithdraw
Withdraw funds from this node to your ethereum wallet address. You can choose whitch currency you want to withdraw, NATIVE or HOPR.
Authorizations:
Request Body schema: application/json
currency required | string (Currency) Enum: "NATIVE" "HOPR" Supported currencies, NATIVE used for the interacting with blockchain or HOPR used to fund channels. |
amount required | string <amount> Amount to withdraw in the currency's smallest unit. |
recipient required | string <address> (NativeAddress) Blockchain-native account address. Can be funded from external wallets (starts with 0x...). It can't be used internally to send / receive messages, open / close payment channels. |
Responses
Request samples
- Payload
{- "currency": "NATIVE",
- "amount": "1337",
- "recipient": "0xEA9eDAE5CfC794B75C45c8fa89b605508A03742a"
}
Response samples
- 200
- 400
- 422
{- "receipt": "0x37954ca4a630aa28f045df2e8e604cae22071046042e557355acf00f4ef20d2e"
}
accountGetBalances
Get node's HOPR and native balances. HOPR tokens from this balance is used to fund payment channels between this node and other nodes on the network. NATIVE balance is used to pay for the gas fees for the blockchain network.
Authorizations:
Responses
Response samples
- 200
- 422
{- "native": "1000000000000000000",
- "hopr": "10000000000000000000"
}
accountGetAddresses
Get node's HOPR and native addresses. HOPR address is also called PeerId and can be used by other node owner to interact with this node.
Authorizations:
Responses
Response samples
- 200
- 422
{- "nativeAddress": "string",
- "hoprAddress": "string",
- "native": "0xEA9eDAE5CfC794B75C45c8fa89b605508A03742a",
- "hopr": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar"
}
accountGetAddress Deprecated
Get node's HOPR and native addresses. HOPR address is also called PeerId and can be used by other node owner to interact with this node.
Authorizations:
Responses
Response samples
- 200
- 422
{- "nativeAddress": "string",
- "hoprAddress": "string",
- "native": "0xEA9eDAE5CfC794B75C45c8fa89b605508A03742a",
- "hopr": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar"
}
aliasesGetAliases
Get all aliases you set previously and thier corresponding peer IDs.
Authorizations:
Responses
Response samples
- 200
- 422
{- "alice": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "bob": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar"
}
aliasesSetAlias
Instead of using HOPR address, we can assign HOPR address to a specific name called alias. Give an address a more memorable alias and use it instead of Hopr address. Aliases are kept locally and are not saved or shared on the network.
Authorizations:
Request Body schema: application/json
peerId required | string <peerId> PeerId that we want to set alias to. |
alias required | string Alias that we want to attach to peerId. |
Responses
Request samples
- Payload
{- "peerId": "16Uiu2HAmUsJwbECMroQUC29LQZZWsYpYZx1oaM1H9DBoZHLkYn12",
- "alias": "Alice"
}
Response samples
- 400
- 422
{- "status": "INVALID_PEERID"
}
aliasesGetAlias
Get the PeerId (Hopr address) that have this alias assigned to it.
Authorizations:
path Parameters
alias required | string Example: Alice Alias that we previously assigned to some PeerId. |
Responses
Response samples
- 200
- 404
- 422
{- "peerId": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar"
}
aliasesRemoveAlias
Unassign an alias from a PeerId. You can always assign back alias to that PeerId using /aliases endpoint.
Authorizations:
path Parameters
alias required | string Example: Alice Alias that we want to remove. |
Responses
Response samples
- 422
{- "status": "UNKNOWN_FAILURE",
- "error": "Full error message."
}
channelsOpenChannel
Opens a payment channel between this node and the counter party provided. This channel can be used to send messages between two nodes using other nodes on the network to relay the messages. Each message will deduce its cost from the funded amount to pay other nodes for relaying your messages. Opening a channel can take a little bit of time, because it requires some block confirmations on the blockchain.
Authorizations:
Request Body schema: application/json
peerId required | string <peerId> PeerId that we want to transact with using this channel. |
amount required | string <amount> Amount of HOPR tokens to fund the channel. It will be used to pay for sending messages through channel |
Responses
Request samples
- Payload
{- "peerId": "16Uiu2HAmUsJwbECMroQUC29LQZZWsYpYZx1oaM1H9DBoZHLkYn12",
- "amount": "1000000"
}
Response samples
- 201
- 400
- 403
- 409
- 422
{- "channelId": "0x04e50b7ddce9770f58cebe51f33b472c92d1c40384759f5a0b1025220bf15ec5",
- "receipt": "0x37954ca4a630aa28f045df2e8e604cae22071046042e557355acf00f4ef20d2e"
}
channelsGetChannels
Lists all active channels between this node and other nodes on the Hopr network. By default response will contain all incomming and outgoing channels that are either open, waiting to be opened, or waiting to be closed. If you also want to receive past channels that were closed, you can pass includingClosed
in the request url query.
Authorizations:
query Parameters
includingClosed | string Example: includingClosed=false When includingClosed is passed the response will include closed channels which are ommited by default. |
Responses
Response samples
- 200
- 422
{- "incoming": [
- {
- "type": "incoming",
- "channelId": "0x04e50b7ddce9770f58cebe51f33b472c92d1c40384759f5a0b1025220bf15ec5",
- "peerId": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "status": "Open",
- "balance": "10000000000000000000"
}
], - "outgoing": [
- {
- "type": "incoming",
- "channelId": "0x04e50b7ddce9770f58cebe51f33b472c92d1c40384759f5a0b1025220bf15ec5",
- "peerId": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "status": "Open",
- "balance": "10000000000000000000"
}
]
}
channelsRedeemTickets
Redeems your tickets for this channel. Redeeming will change your tickets into Hopr tokens if they are winning ones. You can check how much tickets given channel has by calling /channels/{peerid}/tickets endpoint. Do this before channel is closed as neglected tickets are no longer valid for redeeming.
Authorizations:
path Parameters
peerid required | string <peerId> Example: 16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit PeerId attached to the channel. |
Responses
Response samples
- 400
- 404
- 422
{- "status": "INVALID_PEERID"
}
channelsGetTickets
Get tickets earned by relaying data packets by your node for the particular channel.
Authorizations:
path Parameters
peerid required | string <peerId> Example: 16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit PeerId attached to the channel. |
Responses
Response samples
- 200
- 400
- 404
- 422
[- {
- "counterparty": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "challenge": "string",
- "epoch": "string",
- "index": "string",
- "amount": "string",
- "winProb": "string",
- "channelEpoch": "string",
- "signature": "0x304402201065a95fd22fc3e48266c3b270ace032489b0177e07d33c59e0d13dccc89108402205f41fb911bcfe485a8e58162ebce90382dc96ccafff378e5c8960e07efcf9e92"
}
]
channelsCloseChannel
Close a opened channel between this node and other node. Once you've initiated channel closure, you have to wait for a specified closure time, it will show you a closure initiation message with cool-off time you need to wait. Then you will need to send the same command again to finalize closure. This is a cool down period to give the other party in the channel sufficient time to redeem their tickets.
Authorizations:
path Parameters
peerid required | string <peerId> Example: 16Uiu2HAmUsJwbECMroQUC29LQZZWsYpYZx1oaM1H9DBoZHLkYn12 PeerId attached to the channel that we want to close. |
direction required | string Enum: "incoming" "outgoing" Specify which channel should be fetched, incoming or outgoing. |
Responses
Response samples
- 200
- 400
- 422
{- "receipt": "0x37954ca4a630aa28f045df2e8e604cae22071046042e557355acf00f4ef20d2e",
- "channelStatus": "Closed"
}
channelsGetChannel
Returns information about the channel between this node and provided peerId.
Authorizations:
path Parameters
peerid required | string <peerId> (HoprAddress) Example: 16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar Counterparty peerId assigned to the channel you want to fetch. |
direction required | string Enum: "incoming" "outgoing" Specify which channel should be fetched, incoming or outgoing. |
Responses
Response samples
- 200
- 400
- 404
- 422
[- {
- "type": "incoming",
- "channelId": "0x04e50b7ddce9770f58cebe51f33b472c92d1c40384759f5a0b1025220bf15ec5",
- "peerId": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "status": "Open",
- "balance": "10000000000000000000"
}
]
messagesWebsocket
This is a websocket endpoint which streams incoming messages from other nodes. Data is streamed in a stringified Uint8Array instance. Authentication (if enabled) is done via either passing an apiToken
parameter in the url or cookie X-Auth-Token
. Connect to the endpoint by using a WS client. No preview available. Example: ws://127.0.0.1:3001/api/v2/messages/websocket/?apiToken=myApiToken
Authorizations:
Responses
Response samples
- 206
104,101,108,108,111,32,119,111,114,108,100
messagesSign
Signs a message given using the node’s private key. Prefixes messsage with “HOPR Signed Message: ” before signing.
Authorizations:
Request Body schema: application/json
message required | string The message to be signed. |
Responses
Request samples
- Payload
{- "message": "string"
}
Response samples
- 200
- 422
{- "signature": "0x304402201065a95fd22fc3e48266c3b270ace032489b0177e07d33c59e0d13dccc89108402205f41fb911bcfe485a8e58162ebce90382dc96ccafff378e5c8960e07efcf9e92"
}
messagesSendMessage
Send a message to another peer using a given path (list of node addresses that should relay our message through network). If no path is given, HOPR will attempt to find a path.
Authorizations:
Request Body schema: application/json
body required | string The message body which should be sent. |
recipient required | string <peerId> The recipient HOPR peer id, to which the message is sent. |
path | Array of strings <peerId> [ items <peerId > [ 1 .. 3 ] items ] The path is ordered list of peer ids through which the message should be sent. If no path is provided, a path which covers the nodes minimum required hops will be determined automatically. |
Responses
Request samples
- Payload
{- "body": "Hello",
- "recipient": "16Uiu2HAm2SF8EdwwUaaSoYTiZSddnG4hLVF7dizh32QFTNWMic2b",
- "path": [
- "16Uiu2HAm1uV82HyD1iJ5DmwJr4LftmJUeMfj8zFypBRACmrJc16n"
]
}
Response samples
- 202
- 422
"e61bbdda74873540c7244fe69c39f54e5270bd46709c1dcb74c8e3afce7b9e616d"
messageSign Deprecated
Signs a message given using the node’s private key. Prefixes messsage with “HOPR Signed Message: ” before signing.
Authorizations:
Request Body schema: application/json
message required | string The message to be signed. |
Responses
Request samples
- Payload
{- "message": "string"
}
Response samples
- 200
- 422
{- "signature": "0x304402201065a95fd22fc3e48266c3b270ace032489b0177e07d33c59e0d13dccc89108402205f41fb911bcfe485a8e58162ebce90382dc96ccafff378e5c8960e07efcf9e92"
}
nodeStreamWebsocket Deprecated
This is a websocket endpoint which streams legacy hopr-admin data. Authentication (if enabled) is done via either passing an apiToken
parameter in the url or cookie X-Auth-Token
. Connect to the endpoint by using a WS client. No preview available. Example: ws://127.0.0.1:3001/api/v2/node/stream/websocket/?apiToken=myApiToken
Authorizations:
Responses
Response samples
- 206
{- "type": "log",
- "timestamp": 1644587213977,
- "content": "Opening channel..."
}
nodePing
Pings another node to check its availability.
Authorizations:
Request Body schema: application/json
peerId required | string <peerId> PeerId associated to the other node that we want to ping. |
Responses
Request samples
- Payload
{- "peerId": "16Uiu2HAmUsJwbECMroQUC29LQZZWsYpYZx1oaM1H9DBoZHLkYn12"
}
Response samples
- 200
- 400
- 422
{- "latency": 10
}
nodeGetPeers
Lists information for connected peers
and announced peers
.
Connected peers are nodes which are connected to the node while announced peers are nodes which have announced to the network.
Optionally, you can pass quality
parameter which would filter out peers with lower quality to the one specified.
Authorizations:
query Parameters
quality | number Example: quality=0.5 When quality is passed, the response will only include peers with higher or equal quality to the one specified. |
Responses
Response samples
- 200
- 400
- 422
{- "connected": [
- {
- "peerId": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "multiAddr": [
- "/ip4/128.0.215.32/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/p2p/16Uiu2HAmLpqczAGfgmJchVgVk233rmB2T3DSn2gPG6JMa5brEHZ1/p2p-circuit/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/127.0.0.1/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/192.168.178.56/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit"
], - "heartbeats": {
- "sent": 10,
- "success": 8
}, - "lastSeen": 1646410980793,
- "quality": 0.8,
- "backoff": 0,
- "isNew": true
}
], - "announced": [
- {
- "peerId": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "multiAddr": [
- "/ip4/128.0.215.32/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/p2p/16Uiu2HAmLpqczAGfgmJchVgVk233rmB2T3DSn2gPG6JMa5brEHZ1/p2p-circuit/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/127.0.0.1/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/192.168.178.56/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit"
], - "heartbeats": {
- "sent": 10,
- "success": 8
}, - "lastSeen": 1646410980793,
- "quality": 0.8,
- "backoff": 0,
- "isNew": true
}
]
}
nodeGetInfo
Information about the HOPR Node, including any options it started with. See the schema of the response to get more information on each field.
Authorizations:
Responses
Response samples
- 200
- 422
{- "environment": "hardhat-localhost",
- "announcedAddress": [
- "/ip4/128.0.215.32/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/p2p/16Uiu2HAmLpqczAGfgmJchVgVk233rmB2T3DSn2gPG6JMa5brEHZ1/p2p-circuit/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/127.0.0.1/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/192.168.178.56/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit"
], - "listeningAddress": [
- "/ip4/0.0.0.0/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit"
], - "network": "hardhat",
- "hoprToken": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
- "hoprChannels": "0x2a54194c8fe0e3CdeAa39c49B95495aA3b44Db63",
- "hoprNetworkRegistryAddress": "0xBEE1F5d64b562715E749771408d06D57EE0892A7",
- "connectivityStatus": "GREEN",
- "isEligible": true,
- "channelClosurePeriod": 1
}
nodeGetEntryNodes
List all known entry nodes and their multiaddrs and their eligibility state
Authorizations:
Responses
Response samples
- 200
- 422
{- "property1": {
- "multiaddrs": [
- "string"
], - "isEligible": true
}, - "property2": {
- "multiaddrs": [
- "string"
], - "isEligible": true
}
}
peerInfoGetPeerInfo
Get information about this peer.
Authorizations:
path Parameters
peerid required | string <peerId> (HoprAddress) Example: 16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar HOPR account address, also called a PeerId. Used to send / receive messages, open / close payment channels. |
Responses
Response samples
- 200
- 422
{- "announced": [
- [
- "/ip4/128.0.215.32/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/p2p/16Uiu2HAmLpqczAGfgmJchVgVk233rmB2T3DSn2gPG6JMa5brEHZ1/p2p-circuit/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/127.0.0.1/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/192.168.178.56/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit"
]
], - "observed": [
- [
- "/ip4/128.0.215.32/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/p2p/16Uiu2HAmLpqczAGfgmJchVgVk233rmB2T3DSn2gPG6JMa5brEHZ1/p2p-circuit/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/127.0.0.1/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit",
- "/ip4/192.168.178.56/tcp/9080/p2p/16Uiu2HAm91QFjPepnwjuZWzK5pb5ZS8z8qxQRfKZJNXjkgGNUAit"
]
]
}
settingsSetSetting
Change this node's setting value. Check Settings schema to learn more about each setting and the type of value it expects.
Authorizations:
path Parameters
setting required | string <settingKey> Example: includeRecipient Name of the setting we want to change. |
Request Body schema: application/json
settingValue required | any |
Responses
Request samples
- Payload
{- "settingValue": true
}
Response samples
- 400
- 422
{- "status": "INVALID_SETTING | INVALID_SETTING_VALUE"
}
ticketsGetStatistics
Get statistics regarding all your tickets. Node gets a ticket everytime it relays data packet in channel.
Authorizations:
Responses
Response samples
- 200
- 422
{- "pending": 0,
- "unredeemed": 0,
- "unredeemedValue": "string",
- "redeemed": 0,
- "redeemedValue": "string",
- "losingTickets": 0,
- "winProportion": 0,
- "neglected": 0,
- "rejected": 0,
- "rejectedValue": "string"
}
ticketsRedeemTickets
Redeems all tickets from all the channels and exchanges them for Hopr tokens. Every ticket have a chance to be winning one, rewarding you with Hopr tokens.
Authorizations:
Responses
Response samples
- 422
{- "status": "UNKNOWN_FAILURE",
- "error": "Full error message."
}
ticketsGetTickets
Get all tickets earned by relaying data packets by your node from every channel.
Authorizations:
Responses
Response samples
- 200
- 422
[- {
- "counterparty": "16Uiu2HAmVfV4GKQhdECMqYmUMGLy84RjTJQxTWDcmUX5847roBar",
- "challenge": "string",
- "epoch": "string",
- "index": "string",
- "amount": "string",
- "winProb": "string",
- "channelEpoch": "string",
- "signature": "0x304402201065a95fd22fc3e48266c3b270ace032489b0177e07d33c59e0d13dccc89108402205f41fb911bcfe485a8e58162ebce90382dc96ccafff378e5c8960e07efcf9e92"
}
]