Getting Started

This guide will help you get started with the Turnpike API in minutes.

Prerequisites

Before you begin, ensure you have:

  • A Solana wallet with a public key

  • Basic understanding of Solana and SPL tokens

  • An API key from Turnpike (contact us for access)

Installation

No SDK installation is required! Turnpike API works with standard HTTP requests and WebSocket connections.

However, for local transaction building, you'll need the Solana web3 library:

npm install @solana/web3.js

Get Your API Key

  1. Sign up for an account

  2. Navigate to the API Keys section in your dashboard

  3. Generate a new API key

  4. Store your API key securely (never commit it to version control!)

Make Your First Request

Here's a simple example to get token information:

curl -X GET https://api.turnpike.dev/token/info/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
  -H "Authorization: Bearer YOUR_API_KEY"

Execute Your First Trade

Once you're comfortable with the API, try executing a buy order:

curl -X POST https://api.turnpike.dev/trade/buy \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "publicKey": "YOUR_WALLET_PUBLIC_KEY",
    "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": 0.01,
    "slippage": 10,
    "priorityFee": 0.0001
  }'

Next Steps

Best Practices

  1. Secure Your API Key - Never expose your API key in client-side code or public repositories

  2. Handle Errors Gracefully - Implement proper error handling for network issues and API errors

  3. Respect Rate Limits - Monitor your usage and upgrade your plan if needed

  4. Test First - Use small amounts when testing to minimize risk

  5. Monitor Transactions - Always verify transaction signatures and confirmations

Last updated