Giter VIP home page Giter VIP logo

simplebetfairapiphp's Introduction

Thanks go to the original developer "dcro/simple-betfair-php-api"

All I have done is add an optional endpoint type the the configuration to set either 'betting' or 'accounts'.

Simple Betfair PHP API

This is a simple PHP implementation for Betfair's API (API-NG). It handles both authentication against the SSO endpoint & requests against the JSON-RPC endpoint.

Installation

You can either get the files from GIT or you can install the library via Composer. To use Composer, simply add the following to your composer.json file.

{
    "require": {
        "doug-thwaites/betfair-esa-client": "^1.0"
    }
}

How to use it?

To initialize the API, you'll need to pass an array with your application key (appKey), username, password and certificate file (cert). Check out the Betfair API documentation for details on how to get these.

// Set the API configuration
$configuration = array(
    'appKey'   => '<betfair-application-key>',
    'username' => '<betfair-api-username>',
    'password' => '<betfair-api-password>',
    'cert'     => '/path/to/your/certificate.pem',
)

$api = new Betfair\SimpleAPI($configuration);

To make a request against the API endpoint, call the request() method like this:

try {
    // List event types
    $response = $api->request('listEventTypes', '{"filter":{}}');

} catch (Exception $ex) {
    // handle the exception
}

A more complex request example, to get the market catalogue for a specific event type (<your-event-type-id>) from Great Britain and for the WIN market.

try {
    // Define the parameters
    $params = '{
                   "filter" : {
                       "eventTypeIds" : ["<your-event-type-id>"],
                       "marketCountries" : ["GB"],
                       "marketTypeCodes" : ["WIN"],
                       "marketStartTime" : {"from":"' . date('c') . '"}
                   },
                   "sort" : "FIRST_TO_START",
                   "maxResults" : "1000",
                   "marketProjection" : ["EVENT","MARKET_START_TIME","RUNNER_DESCRIPTION","MARKET_DESCRIPTION"]
              }';

    // Get the market catalogue
    $response = $api->request('listMarketCatalogue', $params);

} catch (Exception $ex) {
    // handle the exception
}

simplebetfairapiphp's People

Contributors

dcro avatar dougthwaites avatar

Stargazers

Metodi Tashev avatar

Watchers

James Cloos avatar  avatar

Forkers

tashev-net

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.