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.jspip install solanacargo add solana-client
cargo add solana-sdkGet Your API Key
Visit turnpike.dev
Sign up for an account
Navigate to the API Keys section in your dashboard
Generate a new API key
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"const response = await fetch(
'https://api.turnpike.dev/token/info/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
}
);
const data = await response.json();
console.log(data);import requests
response = requests.get(
'https://api.turnpike.dev/token/info/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()
print(data)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
Explore the Lightning API for quick integration
Learn about Local Transaction Building for full control
Set up WebSocket streaming for real-time data
Check out code examples for your preferred language
Best Practices
Secure Your API Key - Never expose your API key in client-side code or public repositories
Handle Errors Gracefully - Implement proper error handling for network issues and API errors
Respect Rate Limits - Monitor your usage and upgrade your plan if needed
Test First - Use small amounts when testing to minimize risk
Monitor Transactions - Always verify transaction signatures and confirmations
Last updated