🤖REST API v1 (deprecated)
This page lists all available endpoints of the deprecated Boltz API v1.
API v1 is maintained for existing integrations only and does not include the latest features or swap pairs. For any new integrations, we strongly recommend using API v2.
Basics
Response and request encoding
All the responses to all calls are encoded as JSON
objects. If endpoints require the client to provide any kind of arguments these also have to be encoded as JSON
and sent in the body of a POST
request. Make sure to set the Content-Type
header of your POST
requests to application/json
.
Error handling
If a call fails for some reason, the returned HTTP status code will indicate that. Additionally, an object will be returned that includes the reason why the call failed:
Backend Version
Returns the version of Boltz Backend serving the API. A good call to get started and see if Boltz API requests and responses are working.
GET /version
JSON
object
Status Codes:
200 OK
Response object:
version
: The deployed version of Boltz Backend.
Examples:
GET /version
Supported Pairs
In order to create a swap, one first has to know which pairs are supported and what kind of rates, limits and fees are applied when creating a new swap. The following call returns this information.
GET /getpairs
JSON
object
Status Codes:
200 OK
Response object:
info
: Contains information about special configuration parameters of the Boltz Backend deployment. Currently there is only one:prepay.minerfee
: If the array contains this value, Boltz requires a small invoice for the miner fee to be paid before the actual hold invoice of a Reverse Swap is revealed.
warnings
: An array of strings that indicate that some feature of Boltz might me disabled or restricted. An example is:reverse.swaps.disabled
: Means that all reverse swaps (from Lightning to the chain) are disabled.
pairs
: An object containing the supported pairs. The keys of the values are the IDs of the pairs (BTC/BTC
is a special case with mainchain bitcoin as base asset and Lightning bitcoin as quote asset) and the values itself contain information about the pair:hash
: SHA256 hash of theJSON
encoded data in the pair object.rate
: The exchange rate of the pair.limits
: AJSON
Object containing the minimal and maximal amount of the pair's swap. The numbers are denominated 10 ** -8 of the quote asset.maximalZeroConf
: The maximal amounts that will be accepted without chain confirmations by Boltz. 0 indicates that Boltz will not accept 0-conf. See 0-conf for more info.
fees
: AJSON
object that contains different kinds of fees:percentage
: The percentage of the "send amount" that is charged by Boltz as "Boltz Fee" for swaps from quote to base asset (e.g. Lightning -> Bitcoin).percentageSwapIn
: The percentage of the "send amount" that is charged by Boltz as "Boltz Fee" for swaps from base to quote asset (e.g. Bitcoin -> Lightning).minerFees
: The network fees charged for locking up and claiming funds onchain. These values are absolute, denominated in 10 ** -8 of the quote asset.
Examples:
GET /getpairs
Response:
Creating Normal Submarine Swaps
This section walks you through creating Normal Submarine Swaps (Chain -> Lightning). They differ slightly depending on the kind of bitcoin that are swapped, more information can be found below. Please note that Boltz works with 10 ** -8 decimals internally and all amounts in the API endpoints follow this denomination. All requests to create Normal Submarine Swaps have the following common values in the API request:
type
: The type of swap to create. For Normal Submarine Swaps this issubmarine
.pairId
: The pair of which the swap should be created, query available pairs via/getpairs
.orderSide
: Possible values arebuy
&sell
. Currently, we recommend usingsell
across all pairs of swap typesubmarine
. The valuebuy
for Normal Submarine Swaps of e.g. theL-BTC/BTC
pair signifies a swap from Bitcoin mainchain to Liquid Lightning. Currently, this is not supported and the backend will return"error": "L-BTC has no lightning support"
.
If you already know the amount to be swapped, you should also set invoice
.
invoice
: The Lightning invoice of the user that should be paid.
If the amount is not known yet, a preimage hash has be specified. The invoice that is provided later during the lifecycle of the Submarine Swap has to have the same preimage hash as the one specified here.
preimageHash
: Hash of a preimage that will be used for the invoice that is set later on.
We recommend verifying that pair data fetched previously (like minerFees
) is still valid by additionally passing the pairHash
argument in this call.
pairHash
:hash
string of the pair object of/getpairs
.
Members of our partner program may set this optional referral parameter to get a percentage of the fees earned from referred swaps as kickback.
referralId
: Partner referral ID.
POST /createswap
JSON
object
Status Codes:
201 Created
400 Bad Request
: The swap could not be created. Check theerror
string in theJSON
object of the body of the response for more information.
Response objects:
id
: Id of the newly created swap.timeoutBlockHeight
: Base asset block height at which the swap will expire.address
: Address in which the bitcoin will be locked up. For the Bitcoin mainchain, this is a SegWitP2SHP2WSH
address (P2WSH
nested in aP2SH
) for the sake of compatibility, for Liquid aP2WSH
address and for EVM chains the address of the corresponding swap contract.
If a Lightning invoice is set in this call, one will also find the following values in the response:
acceptZeroConf
: Whether Boltz will accept 0-conf for this swap.expectedAmount
: The amount that Boltz expects to be locked on the chain.
Normal Swaps: UTXO Chains
For UTXO chains, /createswap
requests have to contain one additional parameter:
refundPublicKey
: public key of a keypair that will allow the user to refund the locked up bitcoin once the time lock is expired. This keypair has to be generated and stored by the client integrating Boltz API.
Responses also contain one additional value:
redeemScript
: redeem script from which theaddress
is derived. The redeem script should be used, to verify that Boltz did provide the correct address.
In case the address is for the Liquid Network, it will be blinded by a key that is also in the response:
blindingKey
: hex encoded private key with which the address was blinded
If the invoice has been set, you will also get this value:
bip21
: a BIP21 payment request for theexpectedAmount
and theaddress
Examples:
POST /createswap
Request body:
Response:
Normal Swaps: EVM Chains
Swaps from account-based EVM chains like RSK do not require a new address for every swap. /createswap
takes the details of the swap (like lightning invoice and pair) and Boltz waits until the user locked e.g. RBTC in the contract. The addresses of those contracts can be queried with /getcontracts
and the address of the contract that needs to be used for the swap is also returned in the response of this request.
For EVM chains, the request does not require any additional values, but the response returns one additional value:
claimAddress
: The EVM chain destination address of Boltz. It is specified in thelock
function of the swap contract.
Examples:
POST /createswap
Request body:
Response:
Swap Rates
In case the amount to be swapped is not known when creating a Normal Submarine Swap, the invoice can be set afterwards; even if the chain bitcoin were sent already. In this case, you want to first use this endpoint to figure out what the exact amount of the invoice should be based on the already sent bitcoin. Send a POST
request with a JSON
encoded body with this value:
id
: Id of the Submarine Swap.
POST /swaprates
JSON
object
Status Codes:
200 OK
400 Bad Request
: The invoice amount could not be calculated. Check theerror
string in theJSON
object of the body of the response for more information. A common case is where the user did not lock up chain bitcoin yet, which is a requirement in order to calculate an invoice amount:"error": "no coins were locked up yet"
.
Response object:
invoiceAmount
: Amount of the invoice that should be set with/setinvoice
.
Examples:
Request body:
Response:
Setting an Invoice
In case the amount to be swapped is not known when creating a Normal Submarine Swap, the invoice can be set afterwards; even if the chain bitcoin were sent already. Please keep in mind that the invoice has to have the same preimage hash that was specified when creating the swap. Although the invoice can be changed after setting it initially, this endpoint will only work if Boltz did not try to pay the initial invoice yet. Requests to this endpoint have to be POST
and should have the following values in its JSON
encoded body:
id
: Id of the swap for which the invoice should be set.invoice
: Invoice of the user that should be paid.
POST /setinvoice
JSON
object
Status Codes:
200 OK
400 Bad Request
: The invoice could not be set. Check theerror
string in theJSON
object of the body of the response for more information.
Response objects:
What is returned when the invoice is set depends on the status of the Normal Submarine Swap. If no funds were sent (status swap.created
) the endpoint will return a JSON
object with these values:
acceptZeroConf
: Whether Boltz will accept 0-conf for this swap.expectedAmount
: The amount that Boltz expects you to lock in the chain HTLC.bip21
: A BIP21 payment request for theexpectedAmount
of bitcoin and theaddress
(only set when swapping from UTXO chains).
If chain bitcoin were sent already (status transaction.mempool
or transaction.confirmed
) the endpoint will return an empty JSON
object, signifying success.
In case this endpoint is called again after an invoice was set and Boltz already tried to pay the invoice, the following response objects are returned:
error
: Error message explaining that Boltz tried to pay the invoice already and that it cannot be changed anymore.invoice
: The invoice that was set and that will be used for the swap.
Examples:
If no bitcoin were sent yet:
POST /setinvoice
Request body:
Response:
If bitcoin were sent already:
POST /setinvoice
Request body:
Response:
If the invoice was previously successfully set and Boltz tried to pay it already:
POST /setinvoice
Request body:
Response:
Creating Reverse Submarine Swaps
This section walks you creating Reverse Submarine Swaps (Lightning -> Chain). Similar to Normal Submarine Swaps, requests and responses change slightly depending on the kind of bitcoin involved in the swap. Keep in mind, Boltz uses 10 ** -8 as denomination for responses on the API.
All requests to create Reverse Submarine Swaps have the following common values in the API request:
type
: Type of the swap to create. For Reverse Submarine Swaps this isreversesubmarine
.pairId
: The pair of which the swap should be created, query available pairs via/getpairs
.orderSide
: Possible values arebuy
&sell
. Currently, we recommend usingbuy
across all pairs of swap typereversesubmarine
. The valuesell
for reverse swaps of e.g. theL-BTC/BTC
pair signifies a swap from Bitcoin mainchain to Liquid Lightning. Currently, this is not supported and the backend will return"error": "L-BTC has no lightning support"
preimageHash
: The SHA256 hash of a preimage that was generated by the client. The size of that preimage has to be 32 bytes, otherwise claiming will fail.
There are two options how to set the amount of a reverse swap. The first option is to specify the amount of the invoice that Boltz will generate:
invoiceAmount
: amount of the invoice that will be generated by Boltz
The second option is to specify the amount that will be locked in the chain HTLC. That amount is not what the user will finally receive because of transaction fees required to claim the HTLC. But those can be approximated easily in advance with third party tools like mempool.space.
onchainAmount
: amount Boltz will lock in the chain HTLC
We recommend verifying that pair data fetched previously (like minerFees
) is still valid by additionally passing the pairHash
argument in this call.
pairHash
:hash
string in the pair object of/getpairs
.
Members of our partner program may set this optional referral parameter to get a percentage of the fees earned from referred swaps as kickback.
referralId
: Partner referral ID.
POST /createswap
JSON
object
Status Codes:
201 Created
400 Bad Request
: The swap could not be created. Check theerror
string in theJSON
object of the body of the response for more information.
Response objects:
id
: Id of the newly created swap.lockupAddress
: Address derived from theredeemScript
or contract in which Boltz will lock up bitcoin.invoice
: Hold invoice that needs to be paid before Boltz locks up bitcoin.timeoutBlockHeight
: Base asset block height at which the swap will expire.
In case the invoice amount was specified, the amount that will be locked in the chain HTLC is also returned:
onchainAmount
: Amount of chain bitcoin that will be locked by Boltz.
Boltz Backend finally features the so-called Prepay Miner Fee protocol that requires an invoice for network fees to be paid before the actual hold invoice
of a Reverse Submarine Swap. If this protocol is enabled, the response object will also contain a minerFeeInvoice
. Once the minerFeeInvoice
is paid, Boltz will send the event minerfee.paid
and when the actual hold invoice
is paid, the chain bitcoin will be sent.
This protocol is a countermeasure against a specific attack vector and is currently _not_ enabled on Boltz Mainnet.
Reverse Swaps: UTXO Chains
For UTXO chains, /createswap
requests have to contain one additional parameter:
claimPublicKey
: Public key of a keypair that will allow the user to claim the locked up bitcoin with the preimage. This keypair has to be generated and stored by the Boltz API client.
Responses also contain one additional value:
redeemScript
: Redeem script from which the lockup address is derived. The redeem script should be used, to verify that Boltz didn't try to cheat by creating an address without a HTLC.
In case the lockup address is on the Liquid Network, it will be blinded by a key that is returned in the response too:
blindingKey
: Hex encoded private key with which the address was blinded.
Examples:
POST /createswap
Request body:
Response:
In case the Prepay Miner Fee protocol is enabled:
Request body:
Response body:
Reverse Swaps: EVM Chains
For EVM chains, /createswap
requests have to contain one additional parameter:
claimAddress
: address from which the bitcoin will be claimed
The response also has one more property:
refundAddress
: the address of Boltz which is specified as refund address when it is locking up funds
Boltz features an optional "gasless" protocol that allows a user to pay an additional lightning invoice to pay for gas on EVM chains like RSK to claim a reverse swap. This is useful for users who do not not have e.g. RBTC on RSK yet. In the gasless protocol, using the example of RSK, Boltz sends just enough RBTC to the claimAddress
in the swap process for the user to successfully claim the swap. To use this protocol, set the following property in the request body to true
.
gasless
: If the gasless protocol should be used for the reverse swap.
When the gasless protocol is used, the response will contain two more values. One is the amount of RBTC that will be sent to the claimAddress
. The other one is an invoice to pay for the sent gasAssetAmount
.
gasAssetAmount
: Amount of e.g. RBTC that will be sent to theclaimAddress
to be used as gas to claim the swap.gaslessInvoice
: Invoice that pays forgasAssetAmount
.
Only when both invoices (gaslessInvoice
and invoice)
are paid, Boltz will lock the chain bitcoin to proceed with the swap.
Examples:
POST /createswap
Request body:
Response body:
Swap Status
Before handling status events of this method, we recommended to read: [Swap Types & States](lifecycle.md)
To query the status of a swap one can use this endpoint which returns a JSON
object containing the status of the swap. Possible states and status events are documented in the section Swap Types & States.
Requests querying the status of a swap have to be POST
and contain a single value in its JSON
encoded body:
id
: Id of the swap of which the status is queried.
POST /swapstatus
JSON
object
Status Codes:
200 OK
404 Not Found
: The swap with the provided id couldn't be found.400 Bad Request
: Theid
argument wasn't provided.
Response object:
status
: Status of the swap, e.g.transaction.mempool
&transaction.claimed
for successful Normal Submarine Swaps andtransaction.mempool
andtransaction.confirmed
for successful Reverse Submarine Swaps.transaction
: For Reverse Submarine Swaps, this field contains lockup transaction details in the statestransaction.mempool
andtransaction.confirmed:
id
: Id of the lockup transaction.hex
: Hex encoded lockup transaction (only set for transactions on UTXO chains).eta
: If the status istransaction.mempool
, this value is the estimated time of arrival (ETA) in blocks of when the transaction will be confirmed. Only set for transactions on UTXO chains.
zeroConfRejected
: Set totrue
for Swaps with the statustransaction.mempool
and a lockup transaction that is not eligible for 0-conf.failureReason
: Set when it's necessary to further clarify the failure reason.
Examples:
POST /swapstatus
Request body:
Response:
POST /swapstatus
Request body:
Response:
POST /swapstatus
Request body:
Response:
Swap Status Stream
To avoid querying the /swapstatus
endpoint regularly to get the latest swap status, this endpoint streams swap status updates via Server-Side Events.
Requests to this endpoint have to provide the required swap id
parameter via an URL parameter because all requests have to be of the method GET
.
Every event in the Server-Side stream has data that is encoded exactly like the JSON
object of the /swapstatus
endpoint. Please refer to the examples below for a reference implementation in JavaScript in how to handle the stream.
GET /streamswapstatus
Server-Side event stream
Examples:
Server-Side event streams have to be handled differently from regular HTTP responses. Below is a sample implementation in JavaScript and also what a raw response of a Server-Side event stream looks like.
Sample implementation in JavaScript:
Raw response:
Swap Timeouts
Boltz Swaps have different timeouts for each pair. This endpoint allows querying those timeouts denominated in blocks of the base and quote chain.
GET /timeouts
JSON
object
Status Codes:
200 OK
Response object:
timeouts
: AJSON
object with the pairs as keys and aJSON
object with the timeouts as values.
Examples:
GET /timeouts
Response:
Swap Contracts
To query the addresses of contracts used by Boltz for swaps on EVM chains like RSK, the following endpoint can be queried:
GET /getcontracts
JSON
object
Status Codes:
200 OK
Response object:
chain
:JSON
object that contains all relevant contract addresses of this EVM chain.network
:JSON
object that contains information about the network.chainId
: Id of the EVM chain.
swapContracts
:JSON
object containing swap contract addresses as values.tokens
:JSON
object with the ticker symbol of the supported token as key and its address as value.
Examples:
GET /getcontracts
Response:
Fee Estimations
Boltz provides an API endpoint that returns fee estimations for all supported chains. These fee estimations are not enforced by Boltz and merely represent a recommendation.
For UTXO chains like Bitcoin it is important to mention that if 0-conf is accepted by Boltz for a particular pair and to be used with Normal Submarine Swaps, the lockup transaction has to have at least 80% of the recommended sat/vbyte
value. For more information refer to the 0-conf section.
GET /getfeeestimation
JSON
object
Status Codes:
200 OK
Response object:
This endpoint returns a JSON
object of which each key is the symbol of a chain and each value the estimated fee for that chain denominated in sat/vbyte
for UTXO chains like Bitcoin or GWEI
for EVM chains like RSK.
Examples:
GET /getfeeestimation
Response:
Raw Transactions
Boltz API also allows for querying raw transactions of all supported UTXO chains, irrespective of whether the transactions are still in the mempool or already included in a block. Note, that Boltz does not provide any kind of cryptographic proof that the transaction was included in a block. Also this call is primarily kept for backward compatibility with older integrations, it is not needed to construct transactions as the response of /swapstatus
provides all necessary info.
Requests querying for transactions have to be POST
and contain two arguments in its JSON
encoded body:
currency
: The chain to be queried for the transaction.transactionId
: The id of the transaction that should be queried.
POST /gettransaction
JSON
object
Status Codes:
200 OK
400 Bad Request
: An argument wasn't provided or the transaction couldn't be found.
Response object:
transactionHex
: The requested transaction encoded in hex.
Examples:
POST /gettransaction
Request body:
Response:
Lockup Transactions
The following endpoint can be used to query the user's lockup transaction of a Normal Submarine Swap on UTXO chains. The request has to be POST
and contain the following argument in the JSON
encoded body:
id
: Id of the Submarine Swap.
POST /getswaptransaction
JSON
object
Status Codes:
200 OK
400 Bad Request
: An argument wasn't provided, or the swap couldn't be found.
Response object:
transactionHex
: The lockup transaction of the Normal Submarine Swap encoded in hex.timeoutBlockHeight
: The block height at which the HTLC in the lockup transaction will time out.
If the HTLC has not timed out yet, there will be an additional value in the response:
timeoutEta
: UNIX timestamp at which the HTLC is expected to time out.
Examples:
POST /getswaptransaction
Request body:
Response:
This call works for Normal Submarine Swaps only. If used for Reverse Submarine Swaps, the response will be:
Broadcasting Transactions
This endpoint is used to broadcast transactions on UTXO chains. It is similar to /gettransaction
but instead of getting the hex representation of existing transactions, this call broadcasts new transactions to the network. It is mainly intended to be used as an easy way to broadcast claim & refund transactions by Boltz API clients that don't have access to a full node. We encourage checking out alternatives like mempool.space's public API for Bitcoin or Liquid to reduce reliance on Boltz. The call returns the id of the broadcast transaction,which can be used to verify that the refund transaction was broadcast successfully using a third party service.
Requests broadcasting transactions have to be POST
and contain two arguments in the JSON
encoded body:
currency
: Which network the transaction should be broadcast on.transactionHex
: The HEX encoded transaction.
POST /broadcasttransaction
JSON
object
Status Codes:
200 OK
400 Bad Request
: An argument wasn't provided or the node that was used to broadcast the transaction returned an error.
Response object:
transactionId
: The id of the transaction that was broadcast.
Example:
POST /broadcasttransaction
Request body:
Response:
There is one special case: when trying to broadcast a refund transaction for a swap that has not timed out yet, the backend will return some additional information in addition to the error
in the JSON
encoded response:
error
: The reason why broadcasting failed. In this special case always:non-mandatory-script-verify-flag (Locktime requirement not satisfied) (code 64)
.timeoutEta
: UNIX timestamp at which the HTLC is expected to time out.timeoutBlockHeight
: Block height at which the HTLC in the lockup transaction will time out.
Example:
POST /broadcasttransaction
Request body:
Response:
Authentication
Boltz API does not require any sort of authentication to perform swaps. However, some API endpoints like querying referral fees for members of our partner program, do.
To authenticate your API request, three request headers have to be set:
TS
: current UNIX timestamp (can only deviate from server time by 1 minute at most)API-KEY
: your API keyAPI-HMAC
: SHA256 HMAC encoded as HEX (lower case letters!) of the following values:value of the
TS
headermethod of the HTTP request (e.g.
GET
orPOST
)request path, including the leading slash (e.g.
/referrals/query
)if the request method is
POST
, the body of the request
TypeScript Node.js example:
Querying Referral Fees
Members of the Boltz partner program can request a referral key (hi@bol.tz) to get a percentage of the fees earned from referred swaps as kickback. To query for their referrals, they can send an authenticated request to this endpoint.
GET /referrals/query
JSON
object
Status Codes:
200 OK
401 Unauthorized
: Missing or invalid request authentication.
Response object:
The response of a valid request is grouped by year, month and referral key.
Examples:
GET /referrals/query
Response:
Lightning Node Info
This endpoint allows you to query info like public keys and URIs of the lightning nodes operated by Boltz.
GET /getnodes
JSON
object
Status Codes:
200 OK
Response object:
nodes
:JSON
with the symbol of the chain on which the Lightning node is running as key and the following objects:nodeKey
: Public key of the Lightning node.uris
: Array of the URIs on which the Lightning node is reachable.
Examples:
GET /getnodes
Response:
Lightning Node Statistics
For display purposes on our website, basic statistics about our lightning nodes are exposed via the following endpoint:
GET /nodestats
JSON
object
Status Codes:
200 OK
Response object:
nodes
:JSON
with the symbol of the chain on which the Lightning node is running as key, and the following objects:peers
: Number of peers.channels
: Number of public channels.oldestChannel
: UNIX timestamp of the block in which the opening transaction of the oldest channel was included.capacity
: Sum of the capacity of all public channels.
Examples:
GET /nodestats
Response:
Last updated