rest/tx - Bitcoin

This endpoint returns a transaction by its id, decoded into JSON. The same transaction is available as raw hex at .hex and as raw binary at .bin.

Parameters

ParameterTypeLocationRequiredDescription
txidstringpathYesThe transaction id
formatstringpathYesResponse format appended to the txid: json, hex, or bin

Request

bashcurl --location --request GET 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/rest/tx/98bde4a7f407769028cbe725695d388324ab6b83fab4f310005082dd9b8b2de9.json'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/rest/tx/98bde4a7f407769028cbe725695d388324ab6b83fab4f310005082dd9b8b2de9.json'
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.get('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/rest/tx/98bde4a7f407769028cbe725695d388324ab6b83fab4f310005082dd9b8b2de9.json')

print(response.json())

Response

json{
    "txid": "98bde4a7f407769028cbe725695d388324ab6b83fab4f310005082dd9b8b2de9",
    "hash": "290ba098c730ca593384647c6c55f4233a60fbdaa9055fd1fe54f51f49a30ad0",
    "version": 2,
    "size": 205,
    "vsize": 154,
    "weight": 616,
    "locktime": 0,
    "vin": [
        {
            "txid": "5be5b34a8291c73bd91dd71a36306403151ce55deee37a3008232d3fc6c8a29a",
            "vout": 1,
            "scriptSig": {
                "asm": "",
                "hex": ""
            },
            "txinwitness": [
                "0643405bf90e906d26ef8b871201657f..."
            ],
            "sequence": 4294967295
        }
    ],
    "vout": [
        {
            "value": 0.0011348,
            "n": 0,
            "scriptPubKey": {
                "asm": "1 4507d40a378867a30aa9c77c02bf59852771d2e65ebef9e176c9951ef451d92b",
                "desc": "rawtr(4507d40a378867a30aa9c77c02bf59852771d2e65ebef9e176c9951ef451d92b)#ecmzx8gj",
                "hex": "51204507d40a378867a30aa9c77c02bf59852771d2e65ebef9e176c9951ef451d92b",
                "address": "bc1pg5ragz3h3pn6xz4fca7q906es5nhr5hxt6l0nctkex23aaz3my4sl5g9ax",
                "type": "witness_v1_taproot"
            }
        }
    ],
    "blockhash": "000000000000000000019c481c042c0625abe1dc04fe26795e2e24b152791e5f",
    "hex": "020000000001019aa2c8c63f2d2308307ae3ee5de51c15036430361ad71dd93b..."
}

The vin, vout, and witness arrays are truncated to one entry, and hex is abbreviated.

Response Parameters

FieldTypeDescription
txidstringThe transaction id
hashstringThe witness transaction id. Differs from txid for SegWit transactions
versionnumericTransaction version
sizenumericSerialized size in bytes
vsizenumericVirtual size in vbytes, the basis for fee rates
weightnumericTransaction weight
locktimenumericTransaction lock time
vinarrayInputs, each with the outpoint it spends and its witness
voutarrayOutputs, each with a value in BTC and a decoded scriptPubKey
blockhashstringHash of the containing block, when the transaction is confirmed
hexstringThe complete serialized transaction, hex-encoded

The response carries no fee field and no confirmation count, because the node would have to look up each input's previous output to compute them. Fetch the inputs' transactions and subtract, or use the JSON-RPC getrawtransaction method with verbosity 2, which returns a fee directly.

Output values are in BTC as decimals, not satoshis. Parsing them as floats loses precision; the Blockbook api/v2/tx endpoint reports integer satoshi strings instead.

Use Cases

  • Transaction Inspection: Read a decoded transaction without running a node
  • Raw Retrieval: Fetch the serialized transaction with the .hex or .bin form
  • Script Analysis: Read each output's asm, desc, and address
  • Fee Calculation: Use vsize as the denominator for a fee rate

Error Handling

HTTP StatusMessageDescription
400Bad requestThe path is malformed, or a hash or height is invalid
403ForbiddenMissing or invalid ACCESS-TOKEN
404Not foundNo object matches the requested hash, height, or outpoint
500Internal errorThe node failed to process the request