Connections

The connections endpoints allow you to automatically connect to a token network as well as leave a token network by closing and settling all open channels.

Connections Resource Overview

HTTP Method

Resource

Description

GET

/api/<version>/connections

Details of all joined token networks

PUT

/api/<version>/connections/<token_address>

Join a token network

DELETE

/api/<version>/connections/<token_address>

Leave a token network

Currently all API calls are blocking. In case of long running API calls like joining or leaving a token network, if any concurrent API calls are made they will be queued.

Connections Resource Details

get
Details of All Joined Token Networks

http://localhost:5001/api/v1/connections
Each key in the JSON response object is a token address for which you have open channels.
Request
Response
Path Parameters
version
required
string
Version of the API
200: OK
Successful query The value for the token address key is an object containing: - "funds", an integer of the token amount from your last connect request - "sum_deposits", an integer of the sum of deposits in all currently open channels - "channels", an integer of all channels currently open for the specific token
{
"0x2a65Aca4D5fC5B5C859090a6c34d164135398226": {
"funds": 100,
"sum_deposits": 67,
"channels": 3
},
"0x0f114A1E9Db192502E7856309cc899952b3db1ED": {
"funds": 49,
"sum_deposits": 31,
"channels": 1
}
}
500: Internal Server Error
Internal Raiden node error

put
Join a Token Network

http://localhost:5001/api/v1/connections/0x2a65...8226
Calling this endpoint lets you join the token network for the specified token and automatically open channels. If you have already joined the token network for the specified token a call to this endpoint can be made to change the funds allocated in the token network. The request might take some time and will only return once all blockchain calls for opening and/or depositing to a channel have been completed.
Request
Response
Path Parameters
version
required
string
Version of the API
token_address
required
string
Address of a token
Body Parameters
funds
required
integer
Amount of tokens to be put into the network
initial_channel_target
optional
integer
Number of channels to open proactively, defaults to 3 if nothing is provided
joinable_funds_target
optional
number
Floating point number as a fraction of the funds that will be reserved for joining channels opened by others, defaults to 0.4 if nothing is provided. This means that of 100 tokens 40 will get reserved.
204: No Content
A successful connection has been created
402: Payment Required
Insufficient balance of ETH to pay for the on-chain transactions
404: Not Found
The token address is not a valid EIP55-encoded Ethereum address
408: Request Time-out
A timeout happened during any of the transactions
409: Conflict
Some invalid input has been provided
500: Internal Server Error
Internal Raiden node error

Example request:

{
"funds": 1337
}

If the number of channels provided as a value for initial_channel_target is greater than the current number of peers in the token network the funds will still get split according to the value you provided.

This means that if you have funds of 100 tokens and want to open 4 channels but there are only 3 peers in the network then 15 tokens will get distributed for the 3 channels while the remaining 15 will be used for opening a 4th channel as soon as one more peer becomes available.

delete
Leave a Token Network

http://localhost:5001/api/v1/connections/0x2a65...8226
The request might take some time and will only return once all blockchain calls for closing and settling a channel have been completed. The response is a list with addresses of all closed channels.
Request
Response
Path Parameters
version
required
string
Version of the API
token_address
required
string
Address of a token
200: OK
Successfully leaving a token network
[
"0x41BCBC2fD72a731bcc136Cf6F7442e9C19e9f313",
"0x5A5f458F6c1a034930E45dC9a64B99d7def06D7E",
"0x8942c06FaA74cEBFf7d55B79F9989AdfC85C6b85"
]
404: Not Found
The token address is not a valid EIP55-encoded Ethereum address
500: Internal Server Error
Internal Raiden node error