Get a single trade by transaction hash
curl --request GET \
--url https://demo-api.mobula.io/api/2/token/tradeimport requests
url = "https://demo-api.mobula.io/api/2/token/trade"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://demo-api.mobula.io/api/2/token/trade', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://demo-api.mobula.io/api/2/token/trade",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://demo-api.mobula.io/api/2/token/trade"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://demo-api.mobula.io/api/2/token/trade")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api.mobula.io/api/2/token/trade")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"operation": "regular",
"type": "buy",
"baseTokenAmount": 123,
"baseTokenAmountRaw": "<string>",
"baseTokenAmountUSD": 123,
"quoteTokenAmount": 123,
"quoteTokenAmountRaw": "<string>",
"quoteTokenAmountUSD": 123,
"date": 123,
"swapSenderAddress": "<string>",
"transactionSenderAddress": "<string>",
"blockchain": "<string>",
"transactionHash": "<string>",
"marketAddress": "<string>",
"baseTokenPriceUSD": 123,
"quoteTokenPriceUSD": 123,
"swapRecipient": "<string>",
"marketAddresses": [
"<string>"
],
"legs": [
{
"marketAddress": "<string>",
"tokenIn": "<string>",
"tokenOut": "<string>",
"amountIn": 123,
"amountInRaw": "<string>",
"amountInUSD": 123,
"amountOut": 123,
"amountOutRaw": "<string>",
"amountOutUSD": 123,
"poolFeesPercentage": 123
}
],
"baseTokenMarketCapUSD": 123,
"quoteTokenMarketCapUSD": 123,
"labels": [],
"walletMetadata": {
"entityName": "<string>",
"entityLogo": "<string>",
"entityLabels": [
"<string>"
],
"entityType": "<string>",
"entityDescription": "<string>",
"entityTwitter": "<string>",
"entityWebsite": "<string>",
"entityGithub": "<string>",
"entityDiscord": "<string>",
"entityTelegram": "<string>",
"extra": {}
},
"baseToken": {
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"logo": "<string>",
"decimals": 123
},
"quoteToken": {
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"logo": "<string>",
"decimals": 123
},
"platform": {
"id": "<string>",
"name": "<string>",
"logo": "<string>"
},
"totalFeesUSD": 123,
"gasFeesUSD": 123,
"platformFeesUSD": 123,
"mevFeesUSD": 123,
"poolFeesPercentage": 123
}
}Trades Data
Get Token Trade by Transaction
Retrieve a specific trade by transaction hash and blockchain. Returns the first trade found in the transaction.
GET
/
2
/
token
/
trade
Get a single trade by transaction hash
curl --request GET \
--url https://demo-api.mobula.io/api/2/token/tradeimport requests
url = "https://demo-api.mobula.io/api/2/token/trade"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://demo-api.mobula.io/api/2/token/trade', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://demo-api.mobula.io/api/2/token/trade",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://demo-api.mobula.io/api/2/token/trade"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://demo-api.mobula.io/api/2/token/trade")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api.mobula.io/api/2/token/trade")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"operation": "regular",
"type": "buy",
"baseTokenAmount": 123,
"baseTokenAmountRaw": "<string>",
"baseTokenAmountUSD": 123,
"quoteTokenAmount": 123,
"quoteTokenAmountRaw": "<string>",
"quoteTokenAmountUSD": 123,
"date": 123,
"swapSenderAddress": "<string>",
"transactionSenderAddress": "<string>",
"blockchain": "<string>",
"transactionHash": "<string>",
"marketAddress": "<string>",
"baseTokenPriceUSD": 123,
"quoteTokenPriceUSD": 123,
"swapRecipient": "<string>",
"marketAddresses": [
"<string>"
],
"legs": [
{
"marketAddress": "<string>",
"tokenIn": "<string>",
"tokenOut": "<string>",
"amountIn": 123,
"amountInRaw": "<string>",
"amountInUSD": 123,
"amountOut": 123,
"amountOutRaw": "<string>",
"amountOutUSD": 123,
"poolFeesPercentage": 123
}
],
"baseTokenMarketCapUSD": 123,
"quoteTokenMarketCapUSD": 123,
"labels": [],
"walletMetadata": {
"entityName": "<string>",
"entityLogo": "<string>",
"entityLabels": [
"<string>"
],
"entityType": "<string>",
"entityDescription": "<string>",
"entityTwitter": "<string>",
"entityWebsite": "<string>",
"entityGithub": "<string>",
"entityDiscord": "<string>",
"entityTelegram": "<string>",
"extra": {}
},
"baseToken": {
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"logo": "<string>",
"decimals": 123
},
"quoteToken": {
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"logo": "<string>",
"decimals": 123
},
"platform": {
"id": "<string>",
"name": "<string>",
"logo": "<string>"
},
"totalFeesUSD": 123,
"gasFeesUSD": 123,
"platformFeesUSD": 123,
"mevFeesUSD": 123,
"poolFeesPercentage": 123
}
}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
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, orwithdrawal) - 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.
nullif 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.
nullif not available. - baseToken: Full token details for the base token (includes all fields from the Token Details schema)
- quoteToken: Full token details for the quote token
- platform: Trading platform/aggregator used for the trade. Object with
id,name,logofields.nullif 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
- poolFeesPercentage: The pool’s LP fee as a percentage (e.g.
0.3for a 0.3% pool), for the pool atmarketAddress.nullwhen the fee is dynamic (decided at swap time by a hook) or unknown. For multi-hop trades, each entry inlegscarries its ownpoolFeesPercentage.
This endpoint is useful when you have a transaction hash and want to retrieve the trade details without knowing the pool or token address.
If the transaction contains multiple swaps, only the most recent one will be returned. The transaction must exist in the indexed blockchain data.
Usage Examples
Query a trade by transaction hash (GET):curl -X GET "https://api.mobula.io/api/2/token/trade?blockchain=base&transactionHash=0x123abc456def789..."
curl -X POST "https://api.mobula.io/api/2/token/trade" \
-H "Content-Type: application/json" \
-d '{
"blockchain": "base",
"transactionHash": "0x123abc456def789..."
}'
curl -X GET "https://api.mobula.io/api/2/token/trade?blockchain=ethereum&transactionHash=0xabc123..."
Sample Response
{
"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,
"poolFeesPercentage": 0.3
}
}
Error Responses
404 - Trade not found:{
"statusCode": 404,
"message": "Trade not found"
}
{
"statusCode": 404,
"message": "Pool not found"
}
{
"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