Code Monkey home page Code Monkey logo

betfair_api_client's Introduction

Betfair API Client

This package contains a class that acts as an interface to the Betfair Odds API. It allows you to pull the latest betting market info from any sport.

Installation

pip install betfair_api_client

Usage

You can use it like this;

from betfair_api_client import BetfairApiClient

client = BetfairApiClient(
    username=BETFAIR_USERNAME, 
    password=BETFAIR_PASSWORD,
    apiKey=BETFAIR_API_KEY,
    clientCertificatePath=BETFAIR_CLIENT_CERTIFICATE_PATH,
    certificateKeyPath=BETFAIR_CLIENT_CERTIFICATE_KEY_PATH
)

competitions = client.list_competitions(countryCodes=['GB'], sportTypeIds=[1])

# return a list of "Event" classes
comingEvents = client.get_coming_events(
    sportTypeId=1,
    marketTypes=['MATCH_ODDS', 'HALF_TIME_SCORE'], 
    countryCodes=['GB'],
    textQuery='Liverpool',
    daysAhead=7,
)  

# return a list of "Event" classes with latest runner prices
eventsWithLatestOdds = client.update_prices_for_events(events=comingEvents)

exampleEvent = eventsWithLatestOdds[0]

# print out an "Event" class
print(exampleEvent)
# Liverpool v Tottenham (2020-12-16 20:00:00) - English Premier League (GB)

allEventMarkets = exampleEvent.get_all_markets()

# print a list of "Market" classes
print(allEventMarkets)
# [Market: "Match Odds".  Starts at: 2020-12-16 20:00:00, Market: "Half Time Score".  Starts at: 2020-12-16 20:00:00]

exampleMarket = allEventMarkets[0]

# return a list of "Runner" classes.
allRunners = exampleMarket.get_all_runners()
print(allRunners)
# [Liverpool (56323), Tottenham (48224), The Draw (58805)]

exampleRunner = allRunners[0]

# get the available runner prices (returned as a list of "RunnerPrice" classes)
print(exampleRunner.get_all_available_runner_prices())

# [betType: availableToBack, price: 1.84, size: 834.72,
# betType: availableToBack, price: 1.83, size: 984.71,
# betType: availableToBack, price: 1.82, size: 171.47,
# betType: availableToLay, price: 1.85, size: 221.73,
# betType: availableToLay, price: 1.86, size: 1562.24,
# betType: availableToLay, price: 1.87, size: 1458.99]

print(exampleRunner.get_best_lay_price())
# betType: availableToLay, price: 1.85, size: 221.73

print(exampleRunner.get_best_back_price())
# betType: availableToBack, price: 1.84, size: 834.72

betfair_api_client's People

Contributors

miksyr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.