Cap Bet LogoCap Bet Docs

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/sdk

Using bun

bun add @capbet/sdk

Quick 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 calls

Environment 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_here

Next Steps

Now that you've set up your environment, explore these guides:

Need Help?

  • Join our Discord for community support
  • Check out our GitHub for source code
  • Read the FAQ for common questions
Getting Started | Cap Bet Docs