This is a Node.js example demonstrating how to use the Titan SDK TypeScript library to connect to the Titan exchange WebSocket API and receive real-time swap quotes.
- Node.js (v18.19 or higher)
- npm or yarn
- A Titan API authentication token
- Clone this repository:
git clone <repository-url>
cd titan-sdk-ts-example-node- Install dependencies:
npm installCreate a .env file in the project root with the following environment variables:
# Required: WebSocket URL for the Titan API
WS_URL=wss://api.titan.exchange/api/v1/ws
# Required: Authentication token for the API
AUTH_TOKEN=your_auth_token_here
# Required: Base58-encoded public key for user swapping tokens
USER_PUBLIC_KEY=your_public_key_here
INPUT_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
OUTPUT_MINT=So11111111111111111111111111111111111111112
# Amount in atoms
AMOUNT=1000000
# Slippage in basis points (defaults to 50 = 0.5%)
SLIPPAGE_BPS=50
# Maximum number of quotes per stream event (defaults to 3)
NUM_QUOTES=3Start the example script:
npm run start