Getting Started
Making Your First Request
This guide walks you through making your first API request.
- An account with API access
- An API key (see Authentication)
- Your preferred HTTP client or programming language
Let's start by retrieving your active sessions:
cURL
curl https://api.b337.ai/v3/sessions \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"
Python
import requests
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://api.b337.ai'
def get_active_sessions():
headers = {
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
}
try:
response = requests.get(
f'{BASE_URL}/v3/sessions',
headers=headers
)
response.raise_for_status()
data = response.json()
print('Active Sessions:', data)
return data
except requests.exceptions.RequestException as e:
print(f'Error: {e}')
raise
get_active_sessions()
Expected Response:
{
"sessions": [
{
"session_id": "uuid-string",
"bookie": "tab",
"username": "user@example.com",
"pc_id": "pc-identifier",
"status": "running"
}
]
}
Every session is listed except housekeeping sessions and hidden accounts. Bet only on sessions whose status is running; see Sessions for the other statuses.
Now let's check the balance for a session:
cURL
curl -X POST https://api.b337.ai/v3/balance \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "your-session-id"
}'
Python
def get_balance(session_id):
headers = {
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
}
payload = {
'session_id': session_id,
}
try:
response = requests.post(
f'{BASE_URL}/v3/balance',
headers=headers,
json=payload
)
response.raise_for_status()
data = response.json()
print('Balance:', data)
return data
except requests.exceptions.RequestException as e:
print(f'Error: {e}')
raise
get_balance('your-session-id')
Expected Response:
{
"bookie": "tab",
"username": "user@example.com",
"balance": 1000.50,
"bonus_balance": 50.00
}
Now that you've made your first requests, you're ready to:
- Learn about Sessions - Understand session management
- Place Your First Bet - Complete guide to placing a bet
- Explore the API Reference - Full endpoint documentation for Racing and Sports