Need help to set right API endpoints, and correct marketUrl #96
Unanswered
enrico0506
asked this question in
Q&A
Replies: 1 comment
-
Hi @enrico0506 It looks like you're trying to use Python for your Cloudbet API integration. While we can't help you with specific programming questions, we can guide you to some existing Python resources for the Cloudbet API which could be helpful:
Cheers, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to retrieve necessary information about a tt elite series match, and then place a bet on the home or away team. But my problem is i don't find the correct endpoints and i don't know how to build the correct marketUrl
`import requests
import json
API Key for authentication (replace with your actual API key)
API_KEY = "your_api_key_here"
URLs for API endpoints
FIXTURES_URL = "https://sports-api.example.com/v2/fixtures?competition=tt_elite_series" # Replace with the correct URL
ODDS_URL = "https://sports-api.example.com/v2/odds/events/{event_id}" # Replace with the correct URL
PLACE_BET_URL = "https://sports-api.example.com/v3/bets/place"
Headers for API requests
HEADERS = {
"accept": "application/json",
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
Step 1: Retrieve fixtures for the TT Elite Series
def get_fixtures():
response = requests.get(FIXTURES_URL, headers=HEADERS)
if response.status_code == 200:
return response.json() # Return fixture data in JSON format
else:
print("Error fetching fixtures:", response.status_code)
return None
Step 2: Retrieve odds for a specific event
def get_odds(event_id):
url = ODDS_URL.format(event_id=event_id)
response = requests.get(url, headers=HEADERS)
if response.status_code == 200:
return response.json() # Return odds data in JSON format
else:
print("Error fetching odds:", response.status_code)
return None
Step 3: Place a bet
def place_bet(event_id, market_url, stake, price):
bet_data = {
"acceptPriceChange": "BETTER",
"currency": "PLAY_EUR", # Test currency; replace with real currency if needed
"eventId": str(event_id),
"marketUrl": market_url,
"price": str(price),
"referenceId": "unique_ref_id_123", # A unique reference ID for tracking bets
"stake": str(stake)
}
Main function
def main():
# Step 1: Get the list of upcoming TT Elite Series fixtures
fixtures = get_fixtures()
if fixtures:
# For demonstration, we'll bet on the first available fixture
first_fixture = fixtures["events"][0] # Adjust based on your API's response structure
event_id = first_fixture["id"]
print("Betting on event:", first_fixture["name"], "| Event ID:", event_id)
if name == "main":
main()
`
Beta Was this translation helpful? Give feedback.
All reactions