Welcome to integrate GMGN's Solana trading API for fast quantitative trading.
Maybe you still need:
How to Quickly Create an Automated Script for Trading with GMGN Bot
Invite Bots to Telegram group to earn trading commissions automatically
🌐 Language: English | 切换中文
Query Router Endpoint:
<https://gmgn.ai/defi/router/v1/sol/tx/get_swap_route?token_in_address=${inputToken}&token_out_address=${outputToken}&in_amount=${amount}&from_address=${fromAddress}&slippage=${slippage}>
Request Method: GET
API Key: Free to use, no need to request an API Key.
Input Parameters:
Parameter | Type | Description |
---|---|---|
token_in_address | string | The address of the token to spend, e.g., So11111111111111111111111111111111111111112 |
token_out_address | string | The address of the target token, e.g., 7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs |
in_amount | string | Amount in lamports, 100000000=0.1SOL |
from_address | string | The wallet address initiating the transaction, e.g., 2kpJ5QRh16aRQ4oLZ5LnucHFDAZtEFz6omqWWMzDSNrx |
slippage | float | Slippage percentage, e.g., 10 for 10% |
swap_mode | string | ExactIn or ExactOut, default is ExactIn |
fee | float | 0.001, unit in SOL |
Return Parameters:
Parameter | Type | Description |
---|---|---|
code | int | Error code, 0 |
msg | string | Result description, success |
data | Object | { |
quote: { | ||
inputMint: 'So11111111111111111111111111111111111111112', | ||
inAmount: '50000000', | ||
outputMint: '7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs', | ||
outAmount: '77920478752', | ||
otherAmountThreshold: '77530876359', | ||
swapMode: 'ExactIn', | ||
slippageBps: 50, | ||
platformFee: null, | ||
priceImpactPct: '0', | ||
routePlan: [Array], | ||
contextSlot: 240893434, | ||
timeTaken: 0.04250061 | ||
}, | ||
raw_tx: { | ||
swapTransaction: 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAIDxoVIz70VFGJdL5OoCKmFca4NP2MXOcNEiFO6y6JoFUNGWxA6mmc96B1sKHdcYHTM1M1QYNOOSahRPMddzM8XdRsp8RcOMdvjkujt1otIW/R6tIhAHlyC8kUDXj133RK+Ye1I/p3Gy551653GdDPX3KX0D4dWPXyZvsBemb3XlwHyQ+0ezK8pEPmQbXwZ8Tz3O52/YACoT20v0iE4A7D1bTgIWD7ScmJ4Koq6/mSOQVxqfFkoUZ5qTF4TbXDFfH1U+qMakgEp96ZVF6SJaXlGdV6w0mXkHJVedqOxh5rfjqMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBkZv5SEXMv/srbpyw5vnvIzlu8X3EmssQ5s6QAAAAAR51VvyMcBu7nTFbs5oFQf9sbLeo/SOUQKxzaJWvBOPBt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKlcnp1fowmGSs19gRjTJjE83nuG3xjhl5JKAxhv/p89eoKX5UT/REBqE7f6ZMLP+j7G4V34k14Ax0Fw3q7wE/N9jJclj04kifG7PRApFI4NgwtaE5na/xCEBI572Nvp+Fm0P/on9df2SnTAmx8pWHneSwmrNt/J3VFLMhqns4zl6PSRqslFk9OGKukg94vbePj7SOGor/mX5COZhlMmlOYbCAgABQI6UwcACAAJAyBOAAAAAAAADQYABQAnBwoBAQcCAAUMAgAAAIDw+gIAAAAACgEFARENBgACAAsHCgEBCTMKDAAFAwYCJwsJCQ4JIAoMHAMdAR4aHxsoIiMYDAEEFxkWFQokJiUgCgwSBhMEFBAPESEuwSCbM0HWnIEGAwAAABEBZAABGWQBAhEAZAIDgPD6AgAAAAAgJmwkEgAAADIAAAoDBQAAAQkDegmW2ZAMszm+4Eneq5orFPHiSoriEDigyGyG9FUTd+oGpqilp6GiAp+jq4YFkrWa2UlUnmJKVsvmeovDYVI3GhRB1TB5/repN9MFSEVDREcFQkxGSUuC/JDNwibla4b9UHQsSYKI/HmR9edfsxbKg36RCgUpKAaNi5CGiogCkY4=', | ||
lastValidBlockHeight: 221852977, | ||
prioritizationFeeLamports: 9601, | ||
recentBlockhash: 'HThJomQ74BKBYYfFewg9m5MrRwAsHjrpuTwEcohxpAEW' | ||
} | ||
} |
Explanation of data.quote
Fields: