Getting Started
Set up your development environment and make your first API call
Getting Started with Cap Bet
This guide will help you set up your development environment and make your first API call to Cap Bet.
Prerequisites
Before you begin, make sure you have:
- Node.js 18+ or Bun installed
- A Solana wallet (Phantom, Backpack, or any wallet supporting Solana)
- Basic knowledge of TypeScript and Solana
- SOL tokens on devnet (get them from Solana Faucet)
Installation
Using npm
npm install @capbet/sdkUsing bun
bun add @capbet/sdkQuick Example
Here's a simple example to get you started:
import { CapBetClient } from '@capbet/sdk';
// Initialize the client
const client = new CapBetClient({
cluster: 'devnet',
rpcUrl: 'https://api.devnet.solana.com',
});
// Fetch active markets
const markets = await client.getMarkets({
status: 'active',
limit: 10,
});
console.log('Active markets:', markets);Authentication
Cap Bet uses Solana wallet signatures for authentication. Here's how to authenticate:
import { Connection, Keypair } from '@solana/web3.js';
// Connect your wallet
const connection = new Connection('https://api.devnet.solana.com');
const wallet = Keypair.generate(); // Or use your wallet adapter
// Sign authentication message
const message = 'Sign in to Cap Bet';
const signature = await wallet.signMessage(Buffer.from(message));
// Use signature for API callsEnvironment Setup
Create a .env file in your project root:
SOLANA_RPC_URL=https://api.devnet.solana.com
SOLANA_CLUSTER=devnet
CAPBET_API_URL=https://api.cap.bet
WALLET_PRIVATE_KEY=your_private_key_hereNext Steps
Now that you've set up your environment, explore these guides:
- API Reference - Learn about all available API endpoints
- Smart Contracts - Interact with Cap Bet's Solana programs
- Bot Integration - Build automated betting bots
- Examples - See real-world code examples