Giter VIP home page Giter VIP logo

jbetfairng's Introduction

Betfair API-NG Java Client API

A feature complete Java Betfair API-NG client that builds on the Betfair sample code. It's based on the C# betfairng library, however lacks the Reactive Extensions (rx) concurrency layer.

How to use it

To login to Betfair using this library, you'll need both a) a self signed certificate (follow the process described here), and b) an application key directions here.

BetfairClient client = new BetfairClient(Exchange.AUS, "ASDF1234qwerty");
client.login("client-2048.p12", "certpass", "username", "password");

The "BetfairClient" class is where the magic happens. Be sure to import the Helpers class:

List<MarketCatalogue> marketCatalogue = client.listMarketCatalogue(
    Helpers.horseRaceFilter("AU"),
    Helpers.horseRaceProjection(),
    MarketSort.FIRST_TO_START,
    15).getResponse();

for (MarketCatalogue c : marketCatalogue) { 
    // ... print the available markets
}

List<String> marketIds = new ArrayList<String>();
marketIds.add(marketCatalogue.get(0).getMarketId());    
List<MarketBook> marketBooks = client.listMarketBook(
    marketIds, 
    Helpers.horseRacePriceProjection(),
    null,
    null).getResponse();

for (MarketBook book : marketBooks) {
    // ... print the market book
}

Or for soccer

 List<MarketCatalogue> marketCatalogueList = client.listMarketCatalogue(
                Helpers.soccerMatchFilter(null),
                Helpers.soccerMatchProjection(),
                MarketSort.FIRST_TO_START, 20).getResponse();

        for (MarketCatalogue marketCatalogue : marketCatalogueList) {
            printMarketCatalogue(marketCatalogue);
        }
        
        
 private void printMarketCatalogue(MarketCatalogue mk) {
        System.out.println("Market Name: " + mk.getMarketName() + "; Id: " + mk.getMarketId()
                + ";Competition: " + mk.getCompetition() + "; Time: " + mk.getDescription().getMarketTime() + "\n");

        List<RunnerCatalog> runners = mk.getRunners();
        if (runners != null) {
            for (RunnerCatalog rCat : runners) {
                System.out.println("Runner Name: " + rCat.getRunnerName() + "; Selection Id: " + rCat.getSelectionId() + "\n");
            }
        }
    }        

jbetfairng's People

Contributors

cmincu avatar joelpob avatar mbil74 avatar u983101 avatar

Watchers

James Cloos 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.