Authenticating and Making Your First Call
This guide will walk you through authenticating with the BettorEdge API and making your first authenticated request.
Prerequisites
- A BettorEdge account with username and password
- API access enabled on your account (see Getting Started with API Access if you haven't requested access yet)
- Access to make HTTP requests (curl, Postman, or your preferred programming language)
Step 1: Obtain a Bearer Token
To access protected endpoints, you need to authenticate and obtain an access token.
Login Request
Make a POST request to /v1/authenticate/login with:
- Basic Authentication: Your credentials encoded as
username:passwordin base64 - Request Body: Specify
"attribute": "username"to indicate you're logging in with username
- cURL
- JavaScript
- Python
curl -X POST https://proxy.bettoredge.com/players/v1/authenticate/login \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n 'your_username:your_password' | base64)" \
-d '{
"attribute": "username"
}'
const username = 'your_username';
const password = 'your_password';
// Create base64 encoded credentials
const credentials = btoa(`${username}:${password}`);
const response = await fetch('https://proxy.bettoredge.com/players/v1/authenticate/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${credentials}`
},
body: JSON.stringify({
attribute: 'username'
})
});
const data = await response.json();
console.log('Login successful!');
console.log('Access Token:', data.access_token);
import requests
import base64
username = 'your_username'
password = 'your_password'
# Create base64 encoded credentials
credentials = base64.b64encode(f'{username}:{password}'.encode()).decode()
response = requests.post(
'https://proxy.bettoredge.com/players/v1/authenticate/login',
headers={
'Content-Type': 'application/json',
'Authorization': f'Basic {credentials}'
},
json={
'attribute': 'username'
}
)
data = response.json()
print('Login successful!')
print('Access Token:', data['access_token'])
Response
{
"result": "success",
"message": "Login successful",
"player_id": "player_abc123",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expire_datetime": "2024-01-15T12:00:00Z"
}
Store Your Token
Important: Save the access_token securely. You'll need it for all subsequent authenticated requests.
// Example: Store in memory or secure storage
const accessToken = data.access_token;
Step 2: Make Your First Authenticated Request
Now that you have a Bearer token, let's make an authenticated request to get your player profile.
Get Player Profile Request
Make a GET request to /v1/players/player/me with your Bearer token in the Authorization header.
- cURL
- JavaScript
- Python
curl -X GET https://proxy.bettoredge.com/players/v1/players/player/me \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const response = await fetch('https://proxy.bettoredge.com/players/v1/players/player/me', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
const profile = await response.json();
console.log('Player Profile:', profile);
console.log('Username:', profile.player.username);
console.log('Email:', profile.player.email);
response = requests.get(
'https://proxy.bettoredge.com/players/v1/players/player/me',
headers={
'Authorization': f'Bearer {access_token}'
}
)
profile = response.json()
print('Player Profile:', profile)
print('Username:', profile['player']['username'])
print('Email:', profile['player']['email'])
Response
{
"message": "Success",
"player": {
"player_id": "player_abc123",
"username": "your_username",
"email": "you@example.com",
"type": "premium",
"verified": true,
"profile_pic": "https://...",
"first_name": "John",
"last_name": "Doe"
},
"player_premium_items": []
}
Success!
🎉 Congratulations! You've successfully:
- ✅ Authenticated with the BettorEdge API using Basic Auth
- ✅ Obtained a Bearer token
- ✅ Made an authenticated request to get your player profile
Next Steps
Now that you're authenticated, you can:
- Get Your Balance - Check your account balance
- Browse Markets - View available markets to trade
- Place an Order - Make your first trade
Tips
- Token Expiration: Access tokens expire after a period of time. Store the
refresh_tokento obtain new access tokens without re-authenticating - Security: Never hardcode credentials in your application. Use environment variables or secure configuration
- Error Handling: Always check for
result: "fail"in responses and handle errors appropriately
Need help? Check out the API Reference for detailed endpoint documentation.