Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data Credentials = Credentials {}
- class HasCredentials c where
- credentials :: Lens' c Credentials
- apiKey :: Lens' c Text
- certificateCertificateFile :: Lens' c FilePath
- certificatePrivateKeyFile :: Lens' c FilePath
- password :: Lens' c Text
- username :: Lens' c Text
- openBetfair :: MonadIO m => Credentials -> m Betfair
- closeBetfair :: MonadIO m => Betfair -> m ()
- data Betfair
- request :: forall a b m. (MonadIO m, Request a b) => a -> Betfair -> m b
- class (ToJSON a, FromJSON b) => Request a b | a -> b
- module Network.Betfair.Types
Credentials
data Credentials Source
Login credentials.
Credentials | |
|
class HasCredentials c where Source
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
Operations
request :: forall a b m. (MonadIO m, Request a b) => a -> Betfair -> m b Source
Perform a request to Betfair
.
class (ToJSON a, FromJSON b) => Request a b | a -> b Source
Class of types that can be used as requests to Betfair, with their response defined as the second type variable.
requestMethod, requestUrl
Types
module Network.Betfair.Types