Skip to content

Instantly share code, notes, and snippets.

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'))
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 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_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 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,
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)
@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)
@benrules2
benrules2 / BasicTwitter.py
Created November 3, 2016 00:30
Get Username Mentions
def read_messages(twitter_account, since = 0):
mentions = tweepy.Cursor(twitter_account.mentions_timeline, since_id = str(since)).items()
tweets = []
for tweet in tweets:
tweets.append(tweet.text)
if (tweet.id > since):
since = tweet.id
return {"messages":tweets, "since_id": since}
@benrules2
benrules2 / sorry.py
Last active December 9, 2016 04:29
Reddit Sorry Counter
def get_reddit_agent(user_agent, client_id, client_secret, redirect='http://127.0.0.1'):
reddit_agent = praw.Reddit(user_agent = user_agent)
reddit_agent.set_oauth_app_info(client_id = client_id,
client_secret = client_secret,
redirect_uri = redirect)
return reddit_agent
@benrules2
benrules2 / sorry.py
Created November 6, 2016 17:54
Reddit Sorry Counter
def get_subreddit_comments(reddit_agent, subreddit, comments_out = [], count = 100):
#surrounded by try catch in case API calls get exceed
try:
sub = reddit_agent.get_subreddit(subreddit)
comments_raw = sub.get_comments(sub, limit=count)
comments_flat = praw.helpers.flatten_tree(comments_raw)
for comment in comments_flat:
#try catch handles end of reply tree containing a null comment
try:
if hasattr(comment, 'comments'):