Skip to content

commuterjoy/betfair

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

===========
BETFAIR API
===========

------------
Installation
------------

Betfair is available through [Rubygems](http://rubygems.org/gems/betfair) and can be installed via:

gem install betfair OR with bundler: gem 'betfair' and `bundle install`

------------
Introduction
------------
irb

require 'betfair'

or from a Gemfile

gem 'betfair'

# create your username & password in a pipe delimited, base64 encoded string, ie. 'username|password'
auth = 'dXNlcm5hbWV8cGFzc3dvcmQ'

# OR, you might want to store your login details in a file and 'chmod 400' it
auth = IO.read('~/.betfair/auth')

# ... Nb. this *isn't* secure, but means you don't have to store your credentials in the application

# create a client for the General API so that you can log in with the base64 credentials
bf = Betfair::API.new({:credentials => auth})

If you want to use a proxy or turn on Savon's logging then just pass in like so:

proxy = '	http://localhost:8888' # This is a local squid proxy I tunnel to from my local machine to access the host server in UK for dev purposes.
logging = true
bf = Betfair::API.new({:proxy => proxy, :logging => true, :credentials => auth})

Proxy's can be useful if you want to host on a cloud service such as Heroku, as you will be denied access to the Betfair API from the USA. 

Just proxy via a server from a country that Betfair allow's, such as the UK.

-----
Read
-----

markets = bf.get_all_markets(1, [1,3], nil, nil, nil, nil)

details = bf.get_market(2, 100386338)
prices = bf.get_market_prices_compressed(2, 100386338)

helpers = Betfair::Helpers.new

helpers.market_info(details)
helpers.combine(details, prices)

---
Bet
---
bf.place_bet(1, 104184109, 58805, 'B', 10.0, 5.0)
bf.cancel_bet(1, 16939730542)

------------
Requirements
------------
savon

------------------------
Requirements for testing
------------------------
savon_spec
rspec
rake
simplecov


----------
To Do
----------
- Add some error checking to the Betfair::Helper methods
- Finish of the mash method, to return a nice hash of all market and runner info
- Write a spec for the mashed method

----------
Contribute
----------
I have only added the Betfair API method calls that I need. 

Feel free to fork this repo, add what you need to with the relevant RSpec tests and send me a pull request.

-------
License
-------

(The MIT License)

Copyright (c) 2011 Luke Byrne

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Gem for accessing the Betfair API.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages