get_quote_raw
Installation
pip install karrotcapital.spiderswap
Usage
Initialization
First, initialize the 'Spiderswap'
class with your API key.
from karrotcapital.spiderswap import Spiderswap
spiderswap = Spiderswap(ApiKey);
Method: get_quote_raw
Description
The 'get_quote_raw'
method retrieves a quote for a token swap by fetching raw quote data from the SpiderSwap API.
Parameters
'from_mint'
(string): The mint address of the token being swapped from.'to_mint'
(string): The mint address of the token being swapped to.'amount'
(number): The amount of the'from_mint'
token to swap, in lamports.'slippage'
(number): The acceptable slippage percentage for the swap, in basis points (bps).'provider'
(string): The liquidity provider.
Returns
'QuoteMap'
: A object containing the quote data.
'QuoteMap'
Class
'QuoteMap'
Classclass QuoteMap(TypedDict):
inputMint: str
inAmount: Any
outputMint: str
outAmount: Any
minimumReceived: Any
slippage: int
priceImpactPercent: Any
Example
async def get_quote():
try:
const quote_data = await spiderswap.quote.get_quote_raw(
'from_mint_address',
'to_mint_address',
1000000000, # Amount in lamports
50, # Slippage in bps
'provider_name'
);
print(f"Quote data: {quoteData}")
return quoteData
except Exception as e:
print(f"An error occurred: {e}")
get_quote();
Implementation Details
This method constructs a request body with the provided parameters and makes an API call to fetch the quote data. If the API call fails, it logs the error and throws an exception.
Last updated