bet-0.1.2.1: Betfair API bindings. Bet on sports on betting exchanges.

Safe HaskellNone
LanguageHaskell2010

Network.Betfair

Contents

Description

API to Betfair (http://www.betfair.com).

You need a Betfair account, API keys and registered SSL certificates to use this module.

Using the API may subject you to data charges:

http://www.betfair.com/aboutUs/Betfair.Charges/

By default this library will not let you do more than 4 requests per second. This limit is global and is enforced even if you have multiple Betfair connections.

This should stop you from being able to do anything that incurs data charges by API use only (you can still ruin yourself by making bad bets), even the heavily weighted charges.

Use request to make calls to Betfair. Look at Network.Betfair.Types for commands to use with request.

Examples

This example opens a connection to Betfair and lists all your current bets.

   {-# LANGUAGE OverloadedStrings #-}

   import Network.Betfair

   -- Use your actual credentials here. You need to see Betfair
   -- documentation about that
   credentials :: Credentials
   credentials = {
         _username = "Mr. Example"
       , _password = "supersecret"
       , _certificatePrivateKeyFile = "ssl/supersecret-client.key"
       , _certificateCertificateFile = "ssl/supersecret-client.crt"
       , _apiKey = "abcde12345"
       }

   main = do
       bf <- openBetfair credentials
       -- Many request types have a default (so you can use 'default'
       -- function) but if they don't, you can check Network.Betfair.Types
       -- module for the all the data types you can use in request.
       results <- request (default { lcoOrderBy = Just ByMatchTime } :: ListCurrentOrders)
       print results

Synopsis

Credentials

Connection

openBetfair :: MonadIO m => Credentials -> m Betfair Source

Connect to Betfair with given credentials.

The connection is cut when the returned Betfair value is garbage collected or closed with closeBetfair.

closeBetfair :: MonadIO m => Betfair -> m () Source

Close a Betfair connection promptly.

Does nothing if it was already closed. Trying to use Betfair after this call will result in a user error.

data Betfair Source

A handle to a Betfair connection.

Instances

Operations

request :: forall a b m. (MonadIO m, Request a b) => a -> Betfair -> m b Source

Perform a request to Betfair.

Types