A Python SDK for interacting with Jupiter Protocol on Solana. This SDK provides a simple interface to Jupiter's swap aggregator, DCA (Dollar Cost Average) trading, and price data services.
- Token Swaps
- Price Quotes
- DCA Trading
- Limit Orders
- Token Price Data
- Market Information
- Type Hints & Async Support
Install the package using pip:
pip install tetsuo-ganymede
from solana.rpc.async_api import AsyncClient
from solders.keypair import Keypair
from tetsuo_ganymede import Jupiter
# Initialize client
async def main():
# Connect to Solana
client = AsyncClient("https://api.mainnet-beta.solana.com")
# Initialize with your wallet
keypair = Keypair.from_bytes(your_private_key)
jupiter = Jupiter(client, keypair)
# Get a quote for swapping 1 SOL to USDC
quote = await jupiter.quote(
input_mint="So11111111111111111111111111111111111111112", # SOL
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", # USDC
amount=1_000_000_000 # 1 SOL (in lamports)
)
print(f"1 SOL = {int(quote['amount'])/1_000_000} USDC")
# Get quote and execute swap
quote = await jupiter.quote(
input_mint="So11111111111111111111111111111111111111112", # SOL
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", # USDC
amount=1_000_000_000, # 1 SOL
slippage_bps=50 # 0.5% slippage
)
# Execute the swap
tx = await jupiter.swap(
input_mint="So11111111111111111111111111111111111111112",
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount=1_000_000_000,
quote_response=quote
)
# Create a DCA schedule to buy USDC with SOL
dca = await jupiter.dca.create_dca(
input_mint="So11111111111111111111111111111111111111112", # SOL
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", # USDC
total_amount=10_000_000_000, # 10 SOL total
amount_per_cycle=1_000_000_000, # 1 SOL per trade
cycle_frequency=86400 # Daily trades
)
# Get DCA positions
positions = await jupiter.dca.get_dca_positions('active')
# Close a DCA position
await jupiter.dca.close_dca(dca_account="your_dca_account")
# Get token prices
prices = await jupiter.get_token_price([
"So11111111111111111111111111111111111111112", # SOL
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" # USDC
])
# Get tradeable tokens
tokens = await jupiter.get_tradeable_tokens(min_liquidity=1000000) # $1M min liquidity
# Get tokens by tag
stables = await jupiter.get_tokens_by_tag("stable")
# Place limit order
order = await jupiter.open_order(
input_mint="So11111111111111111111111111111111111111112", # SOL
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", # USDC
in_amount=1_000_000_000, # 1 SOL
out_amount=20_000_000 # 20 USDC (price target)
)
# Get open orders
open_orders = await jupiter.query_open_orders(wallet_address)
# Cancel orders
await jupiter.cancel_orders(orders=[order_id])
Main class providing access to Jupiter Protocol functionality.
quote()
- Get swap route quotesswap()
- Execute token swapsget_token_price()
- Get token pricesget_tradeable_tokens()
- List tradeable tokensget_tokens_by_tag()
- Filter tokens by tagget_market_mints()
- Get market token pairs- And more...
Handles Dollar Cost Average trading functionality.
create_dca()
- Create DCA scheduleclose_dca()
- Close DCA positionget_dca_positions()
- List DCA positionsget_dca_trades()
- Get DCA trade history
The SDK uses custom exceptions for different error cases:
try:
quote = await jupiter.quote(...)
except Exception as e:
print(f"Error getting quote: {str(e)}")
Jupiter API has rate limits. Consider implementing retries and rate limiting in production:
from asyncio import sleep
async def get_quote_with_retry(jupiter, retries=3):
for i in range(retries):
try:
return await jupiter.quote(...)
except Exception as e:
if i == retries - 1:
raise
await sleep(1)
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details
Built on top of Jupiter Protocol - https://jup.ag
- GitHub Issues: Create an issue
- Discord: Join our community
- Initial release
- Basic swap functionality
- DCA trading support
- Price data endpoints