> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobula.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Token Trade by Transaction

> Retrieve a specific trade by transaction hash and blockchain. Returns the first trade found in the transaction.

### Query Details

This endpoint retrieves a single trade by its transaction hash on a specific blockchain.

| Parameter         | Required | Description                                             |
| ----------------- | -------- | ------------------------------------------------------- |
| `blockchain`      | Yes      | Blockchain identifier (e.g., "base", "ethereum", "bsc") |
| `transactionHash` | Yes      | Transaction hash of the trade                           |

### Step-by-Step Tutorial and Video Walkthrough

* Check out the guide: [Here](https://docs.mobula.io/guides/how-to-get-token-trade-by-transaction-hash)

***

### Response Overview

The response contains a single trade object with the following fields:

* **id**: Unique swap identifier
* **operation**: Swap operation type (regular, deposit, withdrawal)
* **type**: Trade type (`buy`, `sell`, `deposit`, or `withdrawal`)
* **baseTokenAmount**: Amount of base token traded (formatted)
* **baseTokenAmountRaw**: Amount of base token traded in smallest units
* **baseTokenAmountUSD**: USD value of base token traded
* **quoteTokenAmount**: Amount of quote token traded (formatted)
* **quoteTokenAmountRaw**: Amount of quote token traded in smallest units
* **quoteTokenAmountUSD**: USD value of quote token traded
* **date**: Trade timestamp in milliseconds
* **swapSenderAddress**: Address that executed the swap
* **transactionSenderAddress**: Transaction originator address
* **swapRecipient**: The actual beneficiary of the swap - the wallet that receives the output tokens. Critical for Account Abstraction (AA) scenarios. `null` if not available.
* **blockchain**: Blockchain name
* **transactionHash**: Transaction hash
* **marketAddress**: Pool/market address where trade occurred
* **marketAddresses**: Array of all market addresses involved (for multi-hop swaps)
* **preBalanceBaseToken**: Pre-swap balance of base token (raw string, nullable)
* **preBalanceQuoteToken**: Pre-swap balance of quote token (raw string, nullable)
* **postBalanceBaseToken**: Post-swap balance of base token (raw string, nullable)
* **postBalanceQuoteToken**: Post-swap balance of quote token (raw string, nullable)
* **baseTokenPriceUSD**: Base token price in USD at execution
* **quoteTokenPriceUSD**: Quote token price in USD at execution
* **labels**: Array of wallet labels (e.g., `smart-money`, `pro-trader`)
* **walletMetadata**: Enriched wallet metadata (entity name, logo, labels) from known wallets database. `null` if not available.
* **baseToken**: Full token details for the base token (includes all fields from the [Token Details](/rest-api-reference/endpoint/token-details) schema)
* **quoteToken**: Full token details for the quote token
* **platform**: Trading platform/aggregator used for the trade. Object with `id`, `name`, `logo` fields. `null` if not available.
* **totalFeesUSD**: Total fees paid in USD (sum of gas, platform, and MEV fees)
* **gasFeesUSD**: Gas fees paid in USD
* **platformFeesUSD**: Platform/aggregator fees paid in USD (e.g., Axiom, GMGN, Trojan)
* **mevFeesUSD**: MEV/priority fees paid in USD

<Tip>
  This endpoint is useful when you have a transaction hash and want to retrieve the trade details without knowing the pool or token address.
</Tip>

<Warning>
  If the transaction contains multiple swaps, only the most recent one will be returned. The transaction must exist in the indexed blockchain data.
</Warning>

### Usage Examples

**Query a trade by transaction hash (GET):**

```bash theme={null}
curl -X GET "https://api.mobula.io/api/2/token/trade?blockchain=base&transactionHash=0x123abc456def789..."
```

**Query a trade by transaction hash (POST):**

```bash theme={null}
curl -X POST "https://api.mobula.io/api/2/token/trade" \
  -H "Content-Type: application/json" \
  -d '{
    "blockchain": "base",
    "transactionHash": "0x123abc456def789..."
  }'
```

**Query on Ethereum:**

```bash theme={null}
curl -X GET "https://api.mobula.io/api/2/token/trade?blockchain=ethereum&transactionHash=0xabc123..."
```

#### Sample Response

```json theme={null}
{
  "data": {
    "id": "987654321",
    "operation": "regular",
    "type": "buy",
    "baseTokenAmount": 250.75,
    "baseTokenAmountRaw": "250750000000000000000",
    "baseTokenAmountUSD": 3000.9,
    "quoteTokenAmount": 3000.9,
    "quoteTokenAmountRaw": "3000900000",
    "quoteTokenAmountUSD": 3000.9,
    "date": 1699545600000,
    "swapSenderAddress": "0xabc123def456...",
    "transactionSenderAddress": "0xdef456abc789...",
    "swapRecipient": "0xabc123def456...",
    "blockchain": "Base",
    "transactionHash": "0x123abc456def789...",
    "marketAddress": "0x4200000000000000000000000000000000000006",
    "marketAddresses": ["0x4200000000000000000000000000000000000006"],
    "baseTokenPriceUSD": 11.96,
    "quoteTokenPriceUSD": 1.0,
    "labels": ["smart-money", "pro-trader"],
    "walletMetadata": null,
    "baseToken": { "...": "Full token details object" },
    "quoteToken": { "...": "Full token details object" },
    "platform": {
      "id": "axiom",
      "name": "Axiom",
      "logo": "https://..."
    },
    "totalFeesUSD": 3.25,
    "gasFeesUSD": 1.10,
    "platformFeesUSD": 1.50,
    "mevFeesUSD": 0.65
  }
}
```

### Error Responses

**404 - Trade not found:**

```json theme={null}
{
  "statusCode": 404,
  "message": "Trade not found"
}
```

**404 - Pool not found:**

```json theme={null}
{
  "statusCode": 404,
  "message": "Pool not found"
}
```

**400 - Missing parameters:**

```json theme={null}
{
  "statusCode": 400,
  "message": "Blockchain is required"
}
```

### Use Cases

* **Transaction monitoring**: Track specific trades after detecting a transaction on-chain
* **Trading analysis**: Analyze individual trades with full context
* **User history**: Show trade details when a user clicks on a transaction in their wallet
* **Price discovery**: Get the exact execution price for a specific trade
* **Compliance**: Retrieve detailed trade information for auditing purposes


## OpenAPI

````yaml get /2/token/trade
openapi: 3.0.0
info:
  version: 1.0.0
  title: Mobula API
  description: >-
    Documentation of the Mobula API


    **Demo API**: The default server (demo-api.mobula.io) is a demo API with
    rate limits.

    For production use, please use api.mobula.io with an API key from
    https://admin.mobula.io
servers:
  - url: https://demo-api.mobula.io/api/
    description: Demo API (rate limited, for testing only)
  - url: https://api.mobula.io/api/
    description: Production API (requires API key)
security: []
tags:
  - name: V2 - Token
    description: Token details, price, security, ATH, and holder data
  - name: V2 - Market Data
    description: Market details, OHLCV history, and lighthouse metrics
  - name: V2 - Trades
    description: Token trades, enriched trades, and trade filters
  - name: V2 - Wallet
    description: Wallet positions, activity, trades, analysis, and labels
  - name: V2 - Assets
    description: Cross-chain asset details and price history
  - name: V2 - Swap
    description: Swap quoting and execution
  - name: V2 - Perps
    description: Perpetual futures quoting, execution, and positions
  - name: V2 - Bridge
    description: Cross-chain bridge quoting and intent status (Alpha Preview)
  - name: V2 - DeFi
    description: Bonding pools and pulse data
  - name: V2 - Search
    description: Universal fast search
  - name: V2 - Blockchains
    description: System metadata and chain listings
  - name: V1 - Market Data
    description: Market prices, history, sparklines, pairs, and multi-data
  - name: V1 - Wallet
    description: Wallet portfolio, transactions, history, and NFTs
  - name: V1 - Token
    description: First buyers
  - name: V1 - Trades
    description: Market trades by pair
  - name: V1 - Metadata
    description: Token metadata, categories, trendings, and news
  - name: V1 - Assets
    description: List all assets
  - name: V1 - Search
    description: Search for assets, tokens, and pairs
  - name: V1 - DeFi
    description: Bonding pool pulse data
  - name: V1 - Blockchains
    description: Blockchain listings, pairs, and stats
  - name: V1 - Webhooks
    description: Webhook management
  - name: V1 - Feed
    description: Custom feed creation
paths:
  /2/token/trade:
    get:
      tags:
        - V2 - Trades
      summary: Get a single trade by transaction hash
      parameters:
        - schema:
            type: string
            description: Blockchain chain ID (e.g., "evm:56", "solana:solana")
          required: false
          description: Blockchain chain ID (e.g., "evm:56", "solana:solana")
          name: chainId
          in: query
        - schema:
            type: string
            minLength: 1
            description: Transaction hash
          required: true
          description: Transaction hash
          name: transactionHash
          in: query
      responses:
        '200':
          description: Token trade response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      operation:
                        type: string
                        enum:
                          - regular
                          - mev
                          - mev_sandwiched
                          - deposit
                          - withdrawal
                          - bond
                        description: >-
                          Trade operation type (regular, mev, mev_sandwiched,
                          deposit, withdrawal, bond)
                      type:
                        type: string
                        enum:
                          - buy
                          - sell
                          - deposit
                          - withdrawal
                        description: Trade type (buy, sell, deposit, withdrawal)
                      baseTokenAmount:
                        type: number
                      baseTokenAmountRaw:
                        type: string
                      baseTokenAmountUSD:
                        type: number
                      quoteTokenAmount:
                        type: number
                      quoteTokenAmountRaw:
                        type: string
                      quoteTokenAmountUSD:
                        type: number
                      date:
                        type: number
                      swapSenderAddress:
                        type: string
                      transactionSenderAddress:
                        type: string
                      swapRecipient:
                        type: string
                        nullable: true
                        description: >-
                          The actual beneficiary wallet of the swap. Most
                          important address for AA wallets and accurate PnL
                          tracking.
                      blockchain:
                        type: string
                      transactionHash:
                        type: string
                      marketAddress:
                        type: string
                      marketAddresses:
                        type: array
                        items:
                          type: string
                      baseTokenPriceUSD:
                        type: number
                      quoteTokenPriceUSD:
                        type: number
                      baseTokenMarketCapUSD:
                        type: number
                        nullable: true
                      quoteTokenMarketCapUSD:
                        type: number
                        nullable: true
                      labels:
                        type: array
                        nullable: true
                        items:
                          type: string
                        default: []
                      walletMetadata:
                        type: object
                        nullable: true
                        properties:
                          entityName:
                            type: string
                            nullable: true
                          entityLogo:
                            type: string
                            nullable: true
                          entityLabels:
                            type: array
                            items:
                              type: string
                          entityType:
                            type: string
                            nullable: true
                          entityDescription:
                            type: string
                            nullable: true
                          entityTwitter:
                            type: string
                            nullable: true
                          entityWebsite:
                            type: string
                            nullable: true
                          entityGithub:
                            type: string
                            nullable: true
                          entityDiscord:
                            type: string
                            nullable: true
                          entityTelegram:
                            type: string
                            nullable: true
                          extra:
                            type: object
                            additionalProperties:
                              nullable: true
                        required:
                          - entityName
                          - entityLogo
                          - entityLabels
                          - entityType
                          - entityDescription
                          - entityTwitter
                          - entityWebsite
                          - entityGithub
                          - entityDiscord
                          - entityTelegram
                      baseToken:
                        type: object
                        nullable: true
                        properties:
                          address:
                            type: string
                          name:
                            type: string
                            nullable: true
                          symbol:
                            type: string
                            nullable: true
                          logo:
                            type: string
                            nullable: true
                          decimals:
                            type: number
                        required:
                          - address
                          - name
                          - symbol
                          - logo
                          - decimals
                      quoteToken:
                        type: object
                        nullable: true
                        properties:
                          address:
                            type: string
                          name:
                            type: string
                            nullable: true
                          symbol:
                            type: string
                            nullable: true
                          logo:
                            type: string
                            nullable: true
                          decimals:
                            type: number
                        required:
                          - address
                          - name
                          - symbol
                          - logo
                          - decimals
                      platform:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          logo:
                            type: string
                            nullable: true
                        required:
                          - id
                          - name
                          - logo
                      totalFeesUSD:
                        type: number
                        nullable: true
                      gasFeesUSD:
                        type: number
                        nullable: true
                      platformFeesUSD:
                        type: number
                        nullable: true
                      mevFeesUSD:
                        type: number
                        nullable: true
                    required:
                      - id
                      - operation
                      - type
                      - baseTokenAmount
                      - baseTokenAmountRaw
                      - baseTokenAmountUSD
                      - quoteTokenAmount
                      - quoteTokenAmountRaw
                      - quoteTokenAmountUSD
                      - date
                      - swapSenderAddress
                      - transactionSenderAddress
                      - blockchain
                      - transactionHash
                      - marketAddress
                      - baseTokenPriceUSD
                      - quoteTokenPriceUSD
                required:
                  - data

````