# Get Transaction

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

GET https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}/api/v2/tx/{txid}

Returns normalized transaction data for the given transaction ID. Response shape is consistent across UTXO networks. Empty fields are omitted.


Reference: https://www.alchemy.com/docs/chains/bitcoin/utxo-api-endpoints/utxo-api-endpoints/get-transaction

## Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| apiKey | string | Yes | For higher throughput, [create your own API key](https://dashboard.alchemy.com/signup) |
| txid | string | Yes | Hex-encoded transaction ID. |

## Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| spending | boolean | No | When `true`, include spending metadata (`spentTxId`, `spentIndex`, `spentHeight`) on each output that has subsequently been spent.  |

## Code Examples

### cURL

```bash
curl --request GET \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1
```

### JavaScript

```javascript
const options = {method: 'GET'};

fetch('https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1"

response = requests.get(url)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.get("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /{apiKey}/api/v2/tx/{txid}
method: GET
operation:
  operationId: getTransaction
  summary: Get Transaction
  description: |
    Returns normalized transaction data for the given transaction ID. Response shape is consistent across UTXO networks. Empty fields are omitted.
  tags:
    - UTXO API Endpoints
  parameters:
    - name: apiKey
      in: path
      required: true
      schema:
        type: string
        default: docs-demo
      description: For higher throughput, [create your own API key](https://dashboard.alchemy.com/signup)
    - in: path
      name: txid
      required: true
      description: Hex-encoded transaction ID.
      schema:
        type: string
      example: 8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1
    - in: query
      name: spending
      required: false
      description: |
        When `true`, include spending metadata (`spentTxId`, `spentIndex`, `spentHeight`) on each output that has subsequently been spent.
      schema:
        type: boolean
        default: false
  responses:
    '200':
      description: Transaction details.
      content:
        application/json:
          schema:
            type: object
            properties:
              txid:
                type: string
              version:
                type: integer
              lockTime:
                type: integer
              vin:
                type: array
                items:
                  type: object
                  properties:
                    txid:
                      type: string
                    vout:
                      type: integer
                    sequence:
                      type: integer
                    'n':
                      type: integer
                    addresses:
                      type: array
                      items:
                        type: string
                    isAddress:
                      type: boolean
                    value:
                      type: string
                      description: Value in the smallest denomination, as a decimal string.
              vout:
                type: array
                items:
                  type: object
                  properties:
                    value:
                      type: string
                      description: Value in the smallest denomination, as a decimal string.
                    'n':
                      type: integer
                    spent:
                      type: boolean
                    spentTxId:
                      type: string
                      description: |
                        Transaction ID that spent this output. Only present when the request included `spending=true` and the output has been spent.
                    spentIndex:
                      type: integer
                      description: |
                        Input index within the spending transaction that consumed this output. Only present when the request included `spending=true` and the output has been spent.
                    spentHeight:
                      type: integer
                      description: |
                        Block height at which this output was spent. Only present when the request included `spending=true` and the output has been spent.
                    hex:
                      type: string
                    addresses:
                      type: array
                      items:
                        type: string
                    isAddress:
                      type: boolean
              blockHash:
                type: string
              blockHeight:
                type: integer
                description: Height of the block, or `-1` for unconfirmed transactions.
              confirmations:
                type: integer
              confirmationETABlocks:
                type: integer
                description: Estimated blocks to first confirmation (only set when unconfirmed).
              confirmationETASeconds:
                type: integer
                description: Estimated seconds to first confirmation (only set when unconfirmed).
              blockTime:
                type: integer
              size:
                type: integer
              vsize:
                type: integer
              value:
                type: string
              valueIn:
                type: string
              fees:
                type: string
              hex:
                type: string
              rbf:
                type: boolean
          example:
            txid: 8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1
            version: 2
            lockTime: 860729
            vin:
              - txid: 0eb7b574373de2c88d0dc1444f49947c681d0437d21361f9ebb4dd09c62f2a66
                vout: 1
                sequence: 4294967293
                'n': 0
                addresses:
                  - bc1qmgwnfjlda4ns3g6g3yz74w6scnn9yu2ts82yyc
                isAddress: true
                value: '10106300'
            vout:
              - value: '175000'
                'n': 0
                hex: 76a914ecc999d554eaa3efa5e871c28f58b549c36ec51788ac
                addresses:
                  - 1Nb1ykSD7J5k4RFjJQGsrD9gxBE6jzfNa9
                isAddress: true
            blockHash: 00000000000000000000effeb0c4460480e6a347deab95332c63007a68646ee5
            blockHeight: 860730
            confirmations: 1
            blockTime: 1725956288
            size: 225
            vsize: 144
            value: '10063100'
            valueIn: '10106300'
            fees: '43200'
    '400':
      description: Malformed request.
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
                description: Human-readable error message.
          example:
            error: invalid request
    '404':
      description: Resource not found on the requested network.
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
                description: Human-readable error message.
          example:
            error: not found
```
