Permalink
Browse files

Tidied up README as markdown

  • Loading branch information...
1 parent acd4560 commit 93c068a936d5b07c060cf3c4aed7113089b684e6 @bmalex bmalex committed Feb 26, 2012
Showing with 93 additions and 42 deletions.
  1. +93 −42 README
View
135 README
@@ -1,99 +1,137 @@
-===========
BETFAIR API
===========
------------
Installation
------------
-Betfair is available through [Rubygems](http://rubygems.org/gems/betfair) and can be installed via:
+Betfair is available through
+[Rubygems](http://rubygems.org/gems/betfair) and can be installed via:
+
+ gem install betfair
-gem install betfair OR with bundler: gem 'betfair' and `bundle install`
+OR with bundler: `gem 'betfair'` and `bundle install`
------------
Introduction
------------
-irb
-require 'betfair'
+ irb
-or from a Gemfile
+ require 'betfair'
-gem 'betfair'
-
-# create a client for the General API so that you can log in.
-bf = Betfair::API.new
+or from a Gemfile
-If you want to use a proxy or turn on Savon's logging then just pass in like so:
+ gem 'betfair'
-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, logging)
+ # create a client for the General API so that you can log in.
+ bf = Betfair::API.new
-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.
+If you want to use a proxy or turn on Savon's logging then just pass
+in like so:
-Just proxy via a server from a country that Betfair allow's, such as the UK.
+ # This is a local squid proxy I tunnel to from my local
+ # machine to access the host server in UK for dev purposes.
+ proxy = 'http://localhost:8888'
+ logging = true
+ bf = Betfair::API.new(proxy, logging)
-At the heart of the Betfair API is the session_token.
+Proxies 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 allows, such
+as the UK.
-In order to get one of these simply call:
+At the heart of the Betfair API is the `session_token`. In order to
+get one of these simply call:
-session_token = bf.login('username', 'password', 82, 0, 0, nil)
+ session_token = bf.login('username', 'password', 82, 0, 0, nil)
Username and Password are fairly obvious.
-82 is the standard Product Id, you may have a different one depending on the level of Betfair API access that you have.
+82 is the standard Product Id, you may have a different one depending
+on the level of Betfair API access that you have.
-You can ignore the rest as leave as is, but they refer to Vendor Software Id, Location Id, Ip Address as required by the Betfair API.
+You can ignore the rest as leave as is, but they refer to Vendor
+Software Id, Location Id, Ip Address as required by the Betfair API.
-----
Read
-----
-markets = bf.get_all_markets(session_token, 1, [1,3], nil, nil, nil, nil)
+ markets =
+ bf.get_all_markets(session_token, 1, [1,3], nil, nil, nil, nil)
+
+ # We can either pull the market ID out of `markets`, or use a
+ # stored value:
+
+ market_id = 100386338
+ exchange_id = 1 # or 2 for the Australian exchange
+
+ # get_market returns a Hash with the details of the identified
+ # market, including the commission as
+ # `details[:market_base_rate]`, and information on the runners
+ # (including their ids, which you need to place a bet) as
+ # `details[:runners]`.
+
+ details =
+ bf.get_market(session_token, exchange_id, market_id)
+
+ # This returns an encoded string with some back prices and depths
+ # for the given market.
-details = bf.get_market(session_token, 2, 100386338)
-prices = bf.get_market_prices_compressed(session_token, 2, 100386338)
+ prices = bf.get_market_prices_compressed(session_token,
+ exchange_id,
+ market_id)
-helpers = Betfair::Helpers.new
+ helpers = Betfair::Helpers.new
-helpers.market_info(details)
-helpers.combine(details, prices)
+ helpers.market_info(details)
+ helpers.combine(details, prices)
-# The get_all_markets api call returns all markets in one huge string, this helper provides them all in handy hashes with market id as key.
-helpers.all_markets(markets)
+ # The get_all_markets api call returns all markets in one huge
+ # string. This helper provides them all in handy hashes with
+ # market id as key.
+
+ helpers.all_markets(markets)
---
Bet
---
-bf.place_bet(session_token, 1, 104184109, 58805, 'B', 10.0, 5.0)
-bf.cancel_bet(session_token, 1, 16939730542)
+
+ bf.place_bet(session_token, 1, 104184109, 58805, 'B', 10.0, 5.0)
+ bf.cancel_bet(session_token, 1, 16939730542)
------------
Requirements
------------
-savon
+
+ savon
------------------------
Requirements for testing
------------------------
-savon_spec
-rspec
-rake
+
+ savon_spec
+ rspec
+ rake
----------
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
+- 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.
+Feel free to fork this repo, add what you need to with the relevant
+RSpec tests and send me a pull request.
-------
License
@@ -103,8 +141,21 @@ 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.
+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.

0 comments on commit 93c068a

Please sign in to comment.