Casino Bet Info
The casinoBetInfo
query returns detailed information about a specific casino bet, including user details, game information, and calculated multipliers.
Authentication​
Required - This endpoint requires user authentication and only returns bets belonging to the authenticated user.
Query​
query CasinoBetInfo($id: String!) {
casinoBetInfo(id: $id) {
id
username
avatarUrl
betAmount
wonAmount
gameName
provider
gameThumbnailUrl
thumbnailBlurHash
thumbnailBlurHashWidth
thumbnailBlurHashHeight
multiplier
}
}
Parameters​
Parameter | Type | Required | Description |
---|---|---|---|
id | String! | Yes | Unique identifier of the casino bet |
Response​
CasinoBetInfoResponse​
The response contains detailed information about the specified casino bet:
Field | Type | Description |
---|---|---|
id | String! | Unique identifier of the bet |
username | String! | Username of the player who placed the bet |
avatarUrl | String | URL of the player's avatar image (optional) |
betAmount | String! | Original bet amount in USDC |
wonAmount | String! | Amount won in USDC |
gameName | String! | Name of the casino game |
provider | String! | Game provider name |
gameThumbnailUrl | String! | URL of the game thumbnail image |
thumbnailBlurHash | String | BlurHash for image placeholder (optional) |
thumbnailBlurHashWidth | Number | Width for BlurHash rendering (optional) |
thumbnailBlurHashHeight | Number | Height for BlurHash rendering (optional) |
multiplier | String! | Win multiplier (wonAmount/betAmount) |
Business Logic​
Access Control​
- Only returns bets belonging to the authenticated user
- Throws error if bet doesn't exist or belongs to another user
- Requires valid authentication token
Data Enrichment​
The query enriches the bet data with:
- User profile information (username, avatar)
- Game metadata (name, provider, thumbnail)
- Calculated multiplier for the win
- Currency conversion to USDC
Multiplier Calculation​
multiplier = wonAmountSystem / betAmountSystem
Formatted as a string with appropriate decimal places.
Currency Handling​
All monetary values are converted to USDC:
- Uses real-time USDC exchange rates
- Converts from system currency (EUR) to USDC
- Formatted as strings for precision
Example Usage​
Variables​
{
"id": "507f1f77bcf86cd799439011"
}
Response​
{
"data": {
"casinoBetInfo": {
"id": "507f1f77bcf86cd799439011",
"username": "player123",
"avatarUrl": "https://cdn.example.com/avatars/player123.jpg",
"betAmount": "$50.00",
"wonAmount": "$1,250.00",
"gameName": "Sweet Bonanza",
"provider": "Pragmatic Play",
"gameThumbnailUrl": "https://cdn.example.com/games/sweet-bonanza.jpg",
"thumbnailBlurHash": "LEHV6nWB2yk8pyo0adR*.7kCMdnj",
"thumbnailBlurHashWidth": 100,
"thumbnailBlurHashHeight": 100,
"multiplier": "25.00"
}
}
}
Error Handling​
Common Errors​
Authentication Required​
{
"errors": [
{
"message": "Unauthorized",
"extensions": {
"code": "UNAUTHENTICATED"
}
}
]
}
Bet Not Found​
{
"errors": [
{
"message": "Bet not found or access denied",
"extensions": {
"code": "NOT_FOUND"
}
}
]
}
Invalid Bet ID​
{
"errors": [
{
"message": "Invalid bet ID format",
"extensions": {
"code": "BAD_USER_INPUT",
"field": "id"
}
}
]
}
Token Service Errors​
{
"errors": [
{
"message": "USDC token not found",
"extensions": {
"code": "TOKEN_NOT_FOUND"
}
}
]
}
Use Cases​
Bet Details Modal​
Display comprehensive information about a specific bet when user clicks on it from their betting history.
Social Sharing​
Provide detailed bet information for sharing big wins on social platforms.
Audit Trail​
Allow users to review detailed information about their past bets for verification.
Customer Support​
Enable support team to view detailed bet information for dispute resolution.
Integration Examples​
React Component​
import { useQuery } from '@apollo/client';
import { CASINO_BET_INFO_QUERY } from './queries';
interface CasinoBetInfoProps {
betId: string;
}
function CasinoBetInfo({ betId }: CasinoBetInfoProps) {
const { data, loading, error } = useQuery(CASINO_BET_INFO_QUERY, {
variables: { id: betId }
});
if (loading) return <div>Loading bet details...</div>;
if (error) return <div>Error: {error.message}</div>;
const bet = data.casinoBetInfo;
return (
<div className="bet-info-modal">
<div className="bet-header">
<img src={bet.gameThumbnailUrl} alt={bet.gameName} />
<div>
<h2>{bet.gameName}</h2>
<p>by {bet.provider}</p>
</div>
</div>
<div className="bet-details">
<div className="player-info">
<img src={bet.avatarUrl} alt={bet.username} />
<span>{bet.username}</span>
</div>
<div className="amounts">
<div>
<label>Bet Amount</label>
<span>${bet.betAmount} USDC</span>
</div>
<div>
<label>Won Amount</label>
<span>${bet.wonAmount} USDC</span>
</div>
<div>
<label>Multiplier</label>
<span>{bet.multiplier}x</span>
</div>
</div>
</div>
</div>
);
}
JavaScript/Fetch​
async function fetchCasinoBetInfo(betId) {
const query = `
query CasinoBetInfo($id: String!) {
casinoBetInfo(id: $id) {
id
username
avatarUrl
betAmount
wonAmount
gameName
provider
gameThumbnailUrl
multiplier
}
}
`;
try {
const response = await fetch('/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
variables: { id: betId }
}),
credentials: 'include'
});
const result = await response.json();
if (result.errors) {
throw new Error(result.errors[0].message);
}
return result.data.casinoBetInfo;
} catch (error) {
console.error('Error fetching casino bet info:', error);
throw error;
}
}
Performance Considerations​
Database Queries​
- Single document lookup by bet ID
- Efficient joins with user and game collections
- Indexed queries for optimal performance
Security​
- User ownership verification prevents data leaks
- Input validation on bet ID parameter
- Proper error handling for unauthorized access
Caching​
- Individual bet information is not cached (real-time accuracy)
- Game and user metadata may be cached separately
- Currency rates cached for consistent conversion
Related Endpoints​
topCasinoWins
- Get user's top casino winsmyBets
- Get complete betting historylatestBets
- Get recent betting activity
Notes​
- This endpoint is specifically for casino bets only
- Only the bet owner can access the detailed information
- Currency conversion ensures consistent USDC representation
- BlurHash support enables smooth image loading
- Multiplier calculation provides quick win assessment