# Get Transaction

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

GET https://bitcoincash-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/bitcoincash/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://bitcoincash-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a
```

### JavaScript

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

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

### Python

```python
import requests

url = "https://bitcoincash-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a"

response = requests.get(url)

print(response.text)
```

### Go

```go
package main

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

func main() {

	url := "https://bitcoincash-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a"

	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://bitcoincash-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoincash-mainnet.g.alchemy.com/v2/docs-demo/api/v2/tx/0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a");
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: 0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a
    - 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: 0ddda32c1004ba0cdb6544ac4622f7affc895b8f582b27f202d9745186f72d0a
            version: 1
            vin:
              - txid: 9a3a10888fb4e8b6ecc83a5add5c5bc8db33650feeaac9a2a94fe114d4e311fd
                vout: 2
                sequence: 4294967295
                'n': 0
                addresses:
                  - bitcoincash:qzk7vrrk3x87psq5x8kateumge0crzsd3g6r84k0ef
                isAddress: true
                value: '546'
            vout:
              - value: '546'
                'n': 1
                hex: 76a91462e9075c5cbf27d50a539e7afbe1f6a1d772479e88ac
                addresses:
                  - bitcoincash:qp3wjpa3tjlj042z2wv7hahsldgwhwy0rq9sywjpyy
                isAddress: true
            blockHash: 000000000000000000b9cc8d1b01604a308f872fae0408045466e82ec6ae9ac1
            blockHeight: 941680
            confirmations: 9484
            blockTime: 1773119738
            size: 479
            value: '45484'
            valueIn: '45965'
            fees: '481'
    '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
```
