Forums

General Betting

Welcome to Live View – Take the tour to learn more
Start Tour
There is currently 1 person viewing this thread.
Escapee
26 Aug 11 12:02
Joined:
Date Joined: 27 Aug 04
| Topic/replies: 10,861 | Blogger: Escapee's blog
Does anyone use JSON to access betfair's web page ?

I'm looking into the effect of Betfairs X-Matcher which isn't visible to the API
but can be seen on the standard web page.

Basically, I know sweet FA about JSON and was thinking I might be able to
merge some JSON into my .net ( or natve c++ ) apps to be able to analyse the X-Matcher.

Would be greatful if some kind soul could give me a few starting pointers to accessing
betfair via JSON


Many, Many, MANY thanks in advance for any help you might profer.
Pause Switch to Standard View JSON, Anyone use it to...?
Show More
Loading...
Report Ghetto Joe August 26, 2011 1:05 PM BST
You'll find almost all languages have inbuilt JSON decoders so it's actually very simple to extract and use the info. I usually just use a bit of regex to grab any JSON code from the page then use the decoders to stick it into a standard array which you should then be able to use the info the same as you'd do for any other multidimensional array.

.NET and C++ are bound to have JSON decoders either built in or available as functions, just search if they're not in your manual
Report Mr Magoo August 26, 2011 1:17 PM BST
JSON makes getting Betfair data easy:

e.g. getting odds for the 17:05 at Newmarket today, there are two URLs:

http://uk.site.sports.betfair.com/betting/api/json/getBootstrapData.do?mi=103519456

This gives you all the market data, rules, horse names and so on. To just refresh the odds, instead use:

http://uk.site.sports.betfair.com/betting/api/json/getPartialMarketData.do?mi=103519456

Parsing the output is easy, as there are JSON decoders for every language out there: http://www.json.org/
It's even vaguely human-readable, unlike most XML.

Oh, you will need to trim some of the output of those URLs, they start with a short line of javascript before the JSON follows.
Report Escapee August 26, 2011 2:01 PM BST
BRILLIANT ! Just what I was looking for..... Thankyou


Knowing nada about JSON I had kind of assumed I would need to dynamically create a java script, and do an HTTP post/get and it would be a lot more faffing about than just posting a URL and parsing the result.


can I ask how one acertains the URL ( not the "?mi=103519456" part as I realise that is the market query ) but http://uk.site.sports.betfair.com/betting/api/json/getPartialMarketData

did you just glean it from  manually ( visually ) examining betfairs web page source ?
or is there an elegant way of say determining any acessible json on any web page ?


Thanks again to you both for taking the time to help me out.
Report Ghetto Joe August 26, 2011 2:43 PM BST
I just got the URL's from using an HTTP sniffer something like HTTP Watch that lets you see the url's the web pages are actually accessing within the framesets.

Like Mr Magoo states the only url's you need are the following


http://uk.site.sports.betfair.com/betting/api/json/getBootstrapData.do?mi=103519456

http://uk.site.sports.betfair.com/betting/api/json/getFullMarketData.do?mi=103519456

http://uk.site.sports.betfair.com/betting/api/json/getPartialMarketData.do?mi=103519456

They basically populate the web page of all the info needed like runner name etc and once all fields are filled getPartialMarketData.do is then called to update price data only.

Think the only thing you need to parse out of the page is the while(1) {}; as that's used by the javascript, all the remaining data in the page is the json data which is easily decoded
Report Escapee August 26, 2011 3:05 PM BST
Thanks Joe, I've just gotta pop out for a few hours but will come back and maybe add a question or two later

thanks again
Report Ghetto Joe August 26, 2011 3:23 PM BST
No problem.

A lot depends on what you want to do with the data as web scraping or using the API both have advantages and disadvantages. Remember if you're scraping you'll need to be logged in and sending the correct cookies etc as they do delay the data, plus all calls are charged doubled the api if you hit data request territory.

If you want the x match prices it may turn out to be easier just to code it into your app using the algorithm available at http://bdp.betfair.com/index.php?option=com_content&task=view&id=237&Itemid=62 rather than trying to mix and match the API and web scrape.
Post Your Reply
<CTRL+Enter> to submit
Please login to post a reply.

Wonder

Instance ID: 13539
www.betfair.com