Skip to content

Instantly share code, notes, and snippets.

@benrules2
Created October 29, 2016 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benrules2/2e21186645bab06e12853dbe5c8de764 to your computer and use it in GitHub Desktop.
Save benrules2/2e21186645bab06e12853dbe5c8de764 to your computer and use it in GitHub Desktop.
Get Bet Info
def get_bet_info(base_url, username, password, bet, favourable_odds = 1.91):
b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8'))
headers = {'Content-length' : '0',
'Content-type' : 'application/json',
'Authorization' : "Basic " + b64str.decode('utf-8')}
url_without_team = base_url + "/v1/line?sportId={0}&leagueId={1}&eventId={2}&periodNumber={3}&betType=MONEYLINE&OddsFormat=DECIMAL"\
.format(bet['sportId'], bet['leagueId'], bet['eventId'],bet['period'])
url = url_without_team + "&Team=Team1"
req = ulib.Request(url, headers=headers)
responseData = ulib.urlopen(req).read()
line_info = json.loads(responseData.decode('utf-8'))
if line_info['price'] < favourable_odds:
bet['minRiskStake'] = line_info['minRiskStake']
bet['team'] = "Team1"
return
url = url_without_team + "&Team=Team2"
req = ulib.Request(url, headers=headers)
responseData = ulib.urlopen(req).read()
line_info = json.loads(responseData.decode('utf-8'))
bet['minRiskStake'] = line_info['minRiskStake']
bet['team'] = "Team2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment