Jupiter API Integration
This guide provides detailed information on integrating with Jupiter's API for token swaps and liquidity access within the Gold Digger ecosystem.
REST API Endpoints
Jupiter provides several REST API endpoints for token swaps and price quotes. Here are the key endpoints used in the Gold Digger platform:
Quote API
The Quote API provides price quotes and route information for token swaps.
Query Parameters
inputMint
: The mint address of the input tokenoutputMint
: The mint address of the output tokenamount
: The amount of input tokens in lamportsslippageBps
: Slippage tolerance in basis points (1 basis point = 0.01%)onlyDirectRoutes
: (Optional) If true, only direct routes will be returned
Example Request
Swap API
The Swap API allows you to execute token swaps based on the routes provided by the Quote API.
Request Body
route
: The route object returned by the Quote APIuserPublicKey
: The public key of the user's walletwrapUnwrapSOL
: (Optional) Whether to wrap/unwrap SOL automaticallyfeeAccount
: (Optional) The account to receive platform fees
Price API
The Price API provides current market prices for tokens without computing full swap routes.
Query Parameters
ids
: Comma-separated list of token mint addressesvsToken
: (Optional) The token to price against (default: USDC)
Gold Digger Integration Best Practices
When integrating Jupiter with Gold Digger, follow these best practices for optimal performance and user experience:
Caching
Implement client-side caching for price quotes to reduce API calls. Refresh quotes periodically (every 30 seconds) or when user actions require fresh data.
Error Handling
Implement robust error handling for network issues, rate limits, and transaction failures. Provide clear error messages to users and retry mechanisms where appropriate.
Transaction Monitoring
Track swap transactions and provide real-time updates to users. Implement a transaction history feature to allow users to view their past swaps.
Platform Fees
Configure platform fees to generate revenue for the Gold Digger ecosystem. Use the platformFeeBps
parameter to set a small fee (e.g., 0.25%) on swaps.
User Experience
Provide a seamless user experience with clear information about swap rates, fees, and slippage. Allow users to customize slippage tolerance and view multiple route options.