Skip to content

Instantly share code, notes, and snippets.

@benrules2
benrules2 / BasicTwitter.py
Last active March 12, 2018 19:29
Post a Message
import tweepy
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
access_key = 'access_key'
access_secret = 'access_secret'
def authorize_account(consumer_key = consumer_key, consumer_secret = consumer_secret,
access_key = access_key, access_secret = access_secret):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
if __name__ == "__main__":
base_url = "https://api.pinnaclesports.com"
username = <username>
password = <password>
stake = 1.5
balance = get_balance(base_url, username, password)
odds = get_sport_odds(base_url, username, password)
bet = find_bet(odds)
def place_bet(base_url, username, password, bet, stake):
url = base_url + "/v1/bets/place"
b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8'))
headers = {'Content-length' : '1',
'Content-type' : 'application/json',
'Authorization' : "Basic " + b64str.decode('utf-8')}
data = {
"uniqueRequestId":uuid.uuid4().hex,
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"
def find_bet(all_odds):
bet_info = {}
favourable_odds = 1.91
bet_info['sportId'] = all_odds['sportId']
for i in all_odds['leagues']:
bet_info['leagueId'] = i['id']
for j in i['events']:
bet_info['eventId'] = j['id']
for k in j['periods']:
bet_info['period'] = k['number']
def get_sport_odds(base_url, username, password, sport = '15'):
url = base_url + '/v1/odds?sportId=' + str(sport) + '&oddsFormat=DECIMAL'
b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8'))
headers = {'Content-length' : '0',
'Content-type' : 'application/json',
'Authorization' : "Basic " + b64str.decode('utf-8')
}
req = ulib.Request(url, headers=headers)
responseData = ulib.urlopen(req).read()
def get_balance(base_url, username, password):
url = base_url + "/v1/client/balance"
b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8'))
headers = {'Content-length' : '0',
'Content-type' : 'application/json',
'Authorization' : "Basic " + b64str.decode('utf-8')}
req = ulib.Request(url, headers=headers)
responseData = ulib.urlopen(req).read()
balance = json.loads(responseData.decode('utf-8'))