π¨βπ» Get Bitcoin transaction by hash
Code samples
GET /api/v1/btc/transactions/{hash}
curl 'https://settla.net/api/v1/btc/transactions/5fc111d07140a808ba08ac28f61fd436efbfe9d84f5437abe980b42c8d9f0a5e' \
-H 'X-API-Key: $SETTLA_API_KEY' \
-H 'Accept: application/json'
Returns transaction details using getrawtransaction with verbose output. Note txid versus hash: for a segwit transaction they differ, because hash covers the witness data and txid does not. Always identify a transaction by txid. A transaction that is not in a block yet has no blockhash, confirmations, time or blocktime. confirmations is the number to watch when waiting for a payment to settle. An unknown txid comes back as 500, not 404. The handler does have a 404 Transaction not found branch, but it is only reached if the node returns an empty result; in practice getrawtransaction raises an RPC error for a txid it does not know, which is caught and reported as Could not connect to BTC node.. Handle both, and do not read a 500 here as proof that the node is down.
π οΈ Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| hash | path | string | true | Bitcoin transaction hash (txid). |
Example responses
200 Response
{
"txid": "5fc111d07140a808ba08ac28f61fd436efbfe9d84f5437abe980b42c8d9f0a5e",
"hash": "504b28c85fde56f73379a73d500998f771fd4a411d63e3f18238c420cca11a70",
"version": 1,
"size": 333,
"vsize": 168,
"weight": 672,
"locktime": 0,
"vin": [
{
"txid": "d83bf8b280830c25847f2d242f6319899c14f37e1ed12fa2e02719e4bd99e8bb",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"",
"304402200147f0749d7918773fdf4b60b8e50d3b48d7ce2b83d126d457b86065fd57d64d02201d2f5d9034f78f18ad9638e12037fb94826f4c2a5a0981d73e6eec19b067f5ff01",
"3044022073fb78a4c016c2feb126d03402685c9a114eb7133d87e0be5341f2bb9c765150022022eb1cd2edec84cf6d9cf81e27c19acc49cbc42f754c408de3dd266aeb7a2d2c01",
"5221022d11a706b118c9b8c02a036644b5e4f971d91268db9273c136e048f19754566a2102269391f740e2766743fbe6650630517fde05434a44ad720eed1fa8858eca0b7c52ae"
],
"sequence": 4294967295
}
],
"vout": [
{
"value": 0.012,
"n": 0,
"scriptPubKey": {
"asm": "0 e93523416d7137dad7b63813ca2a72010bc94d3b",
"desc": "addr(bc1qay6jxstdwyma44ak8qfu52njqy9ujnfm37hllg)#dxsdzh08",
"hex": "0014e93523416d7137dad7b63813ca2a72010bc94d3b",
"address": "bc1qay6jxstdwyma44ak8qfu52njqy9ujnfm37hllg",
"type": "witness_v0_keyhash"
}
},
{
"value": 0.002,
"n": 1,
"scriptPubKey": {
"asm": "0 6421fa8a3caa1d76f817d81ca214b7e250f2cd05",
"desc": "addr(bc1qvssl4z3u4gwhd7qhmqw2y99hufg09ng9h5kmnd)#zllantcq",
"hex": "00146421fa8a3caa1d76f817d81ca214b7e250f2cd05",
"address": "bc1qvssl4z3u4gwhd7qhmqw2y99hufg09ng9h5kmnd",
"type": "witness_v0_keyhash"
}
}
],
"hex": "01000000000101bbe899bde41927e0a22fd11e7ef3149c8919632f242d7f84250c8380b2f83bd80000000000ffffffff02804f120000000000160014e93523416d7137dad7b63813ca2a72010bc94d3b400d030000000000160014β¦",
"blockhash": "00000000000000000001595977e6000ce56129f5c9b4073e31ccc30b90b97da9",
"confirmations": 136,
"time": 1788244455,
"blocktime": 1788244455
}
404 Response
{
"error": "Transaction not found"
}
500 Response
{
"error": "Could not connect to BTC node."
}
π Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Bitcoin transaction | Inline |
| 404 | Not Found | Node returned an empty result. Rarely seen β see the note above. | Inline |
| 500 | Internal Server Error | Node unreachable, or the txid is unknown to the node | Inline |
π Response Schema
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» txid | string | false | none | Transaction ID β the hash without witness data. This is the identifier to use everywhere: in explorers, in GET /transactions/{hash}, as the value returned by send-raw. |
| Β» hash | string | false | none | Witness hash (wtxid). Differs from txid for any segwit transaction β do not use it as a lookup key, getrawtransaction will not find it. |
| Β» version | integer | false | none | none |
| Β» size | integer | false | none | Serialised size in bytes, witness included. |
| Β» vsize | integer | false | none | Virtual size β this is what fee rates (sat/vB) are computed against. |
| Β» weight | integer | false | none | none |
| Β» locktime | integer | false | none | none |
| » blockhash | string¦null | false | none | Absent while the transaction is unconfirmed. |
| Β» confirmations | integer(int64)Β¦null | false | none | Absent while unconfirmed. Grows with every new block, so two calls a few minutes apart return different values for the same transaction. |
| Β» time | integer(int64)Β¦null | false | none | Same value as blocktime for a confirmed transaction. Seconds. |
| Β» blocktime | integer(int64)Β¦null | false | none | none |
| Β» hex | string | false | none | Full raw transaction. Feed it to decoderawtransaction through the JSON-RPC proxy if you want to re-parse it yourself. |
| Β» vin | [object] | false | none | none |
| »» txid | string¦null | false | none | Previous transaction being spent. Absent on a coinbase input. |
| »» vout | integer¦null | false | none | Index of the output being spent in txid. Absent on a coinbase input. |
| »» coinbase | stringΒ¦null | false | none | Arbitrary miner data β height, pool tag, extranonce. Present only on the coinbase input. |
| »» scriptSig | objectΒ¦null | false | none | Empty for segwit inputs β see the note above. |
| »»» asm | string | false | none | none |
| »»» hex | string | false | none | none |
| »» txinwitness | [string] | false | none | Witness stack, hex-encoded. Present only on segwit inputs. The last item of a P2WSH stack is the redeem script; the example transaction is a 2-of-2 multisig, hence the leading empty item (Bitcoin's OP_CHECKMULTISIG off-by-one) followed by two signatures and the script. |
| »» sequence | integer(int64) | false | none | 4294967295 (0xffffffff) means locktime and RBF are both disabled for this input. Any value below 0xfffffffe opts the transaction into replace-by-fee. |
| Β» vout | [object] | false | none | none |
| »» value | number(double) | false | none | Amount in BTC, as a JSON number β not satoshis, not a string. This is the single most common integration bug on this API: 0.012 cannot be represented exactly in IEEE-754, and small outputs come back in exponential notation (a real dust output in block 965000 serialises as 5.46e-06). Parse it with a decimal type, or multiply by 1e8 and round to get satoshis β never compare two values with == and never accumulate them as floats. |
| »» n | integer | false | none | Output index within the transaction. |
| »» scriptPubKey | object | false | none | The locking script. Bitcoin Core v30 β which this node runs β removed reqSigs and addresses. Integrations written against older docs that read scriptPubKey.addresses[0] will silently see undefined here; read the singular address instead. |
| »»» asm | string | false | none | Human-readable disassembly of the script. |
| »»» desc | string | false | none | Output descriptor with its checksum. |
| »»» hex | string | false | none | none |
| »»» address | string | false | none | Destination address. Absent for outputs that have no address form β nulldata (OP_RETURN) and non-standard scripts. Always check that the field exists before reading it. |
| »»» type | string | false | none | Script type: pubkeyhash, scripthash, witness_v0_keyhash, witness_v0_scripthash, witness_v1_taproot, nulldata, nonstandard. |
Status Code 404
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» error | string | false | none | Human-readable reason. |
Status Code 500
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» error | string | false | none | Human-readable reason. |