Free £25 Bet!
Free £50 Bet at VCBet!
Free £25 Bet!

In association with Sports-Punter Free Bets Odds Comparison BetHelp Limso

We are the Official Forum of FreeBetting.net & FCBet.com


Sports News Sports Stats Live Scores OddsChecker Place Bets Suggest a Site


Go Back   The Punters Lounge - The World's Best Betting Forum > Systems, Strategy and General Betting Help > Punters Tools & General Betting Help Forum

Punters Tools & General Betting Help Forum Everyone has tools that use to help them bet. Match reports, odds comparison services, tipster services, betting calculators, selection software - discuss them here.

UK & Irish Football Forum | Western European Football Forum | UEFA Cup & Champions League Football Forum | International Football Forum | Eastern & Southern European Football Forum | Nordic & Scandinavian Football Forum | Non European Football Forum | At The Races Forum | At The Races Systems Forum | Other Sports Forum | USA Sports Forum | Fantasy & Fun Comps Forum | Free Bets Forum | Systems & Strategy Forum | Glory Hunter's Forum | Tipster's Challenge Forum | Daily Racing Comp Forum | Euro & Worldwide Comp Forum | Poker Tourneys Forum | Poker Strategy Forum | Poker Chat Forum | Poker Live Forum | Poker Challenges Forum | Poker Staking Forum | e-Sport Poker League Forum | Bookmakers & Exchanges Forum | Punter's Tools/Betting Help Forum | General Chat Forum | Tech & Gaming Forum | Sports Banter Forum | Live Sports Feeds Forum

Reply
 
Thread Tools Display Modes
Old 12-05-2008, 10:19   #1 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Betfair Free API

Has anyone here developed a program to work with the free API from betfair ?

Is it able to refresh the Horse Racing In-Running price movement quick enough to allow for a "Greening-Up" function to work ?

Only i have Googled this today and have read conflicting answers
Trilobite is offline   Reply With Quote
Old 12-05-2008, 11:37   #2 (permalink)
Pro Punter
 
Datapunter's Avatar
 
Join Date: 23 Oct 2003
Location: Westdorpe
Age: 43
Posts: 5,466
Default Re: Betfair Free API

Usualy yes,
speed depends on your infrastructure of course PC speed, internet speed, etc...
all being well ( recent ) you should have enough speed.

Things break down when the servers at Betfairs side get overworked, then response times can get too high to be practical for speed-betting.

Remember with the Free API you cannot place multiple bets at the same time, you have to do one by one and there are limits to the number of bets per second/minuut (?) ( sorry haven't got the details at hand )

If it is part of your strategy that to green up you place bets on multiple horses at the same time then i would go with the assumption you may not have enough speed with the Free API.

Bottom line is there's only one way to really find out and that is to do a test program.


p.s.
What other answers have you found ?
__________________
If you stay in the game long enough, you'll see everything, win everything, and lose everything.
Datapunter is offline   Reply With Quote
Old 12-05-2008, 12:13   #3 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Quote:

Remember with the Free API you cannot place multiple bets at the same time, you have to do one by one and there are limits to the number of bets per second/minuut (?) ( sorry haven't got the details at hand )

Right cheers DP

I basically cant calculate and input the best guaranteed return in running myself quick enough (whilst watching the race), so i want to set the BACK to win bet 1st and then continually poll the lay odds and calculate the LAY stake automatically.

So i can sit with my eyes on the race and a finger on a LAY button and just have to click once to best green up.

Quote:

Bottom line is there's only one way to really find out and that is to do a test program.
Yep, its just thinking out aloud at the moment, and it might not even work how i think it might


Quote:
p.s.
What other answers have you found ?
Not a lot, if anyone is feeling generous and has any VB5/6 code they would like to share
Trilobite is offline   Reply With Quote
Old 12-05-2008, 12:37   #4 (permalink)
Pro Punter
 
Datapunter's Avatar
 
Join Date: 23 Oct 2003
Location: Westdorpe
Age: 43
Posts: 5,466
Default Re: Betfair Free API

Can't help with any code, got all my stuff in Java.

I can get you some testdata if you want, got a bunch of races in a database with the prices/volume snapped every 2 seconds in-running. If you smooth it out by averaging you can get a continuous line of odds movement. Should allow you to simulate your "betting algorithm".
__________________
If you stay in the game long enough, you'll see everything, win everything, and lose everything.
Datapunter is offline   Reply With Quote
Old 12-05-2008, 16:26   #5 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Well ive managed to get a OK reply from a login routine i found and modified (on the BDP forum).

But this SOAP/XML stuff might as well be Chinese to me right now


Ive got the API4.0_xml_samples.zip from which i am trying to make my Envelope from, and ive got the API reference guide.




But i cant get a reply to the first function iam trying to make :

getBetHistory

return =

HTML Code:
<?xml version='1.0' ?> <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Body> <env:Fault> <faultcode>General</faultcode> <faultstring>Internal Error</faultstring> </env:Fault> </env:Body> </env:Envelope>
from my first attempt of:

HTML Code:
Private Sub get_bet_history_Click()
Dim sEnvelope As String, sReply As String


' create the SOAP Envelope   STRsessionToken = original_key from login
'QUOTE_MARK= """"


sEnvelope = sBody _
& "<m:getBetHistory xmlns:m=" & QUOTE_MARK & "http://www.betfair.com/publicapi/BFService/" & QUOTE_MARK & ">" _
& "<m:request>" & "<clientStamp>0</clientStamp>" _
& "<sessionToken>" & STRsessionToken & "</sessionToken>" _
& "<betTypesIncluded>M</betTypesIncluded>" _
& "<detailed>1</detailed>" _
& "<eventTypeIds><m0:int>0</m0:int></eventTypeIds>" _
& "<m0:int></m0:int>" _
& "<marketTypesIncluded><m0:MarketTypeEnum>O</m0:MarketTypeEnum></marketTypesIncluded>" _
& "<placedDateFrom>2008-01-01T09:30:47-05:00</placedDateFrom>" _
& "<placedDateTo>2008-05-01T09:30:47-05:00</placedDateTo>" _
& "recordCount>100</recordCount>" _
& "<sortBetsBy>NONE</sortBetsBy>" _
& "<startRecord>0</startRecord>" _
& "</m:request></m:getBetHistory></SOAP-ENV:Body></SOAP-ENV:Envelope>"

sReply = MakeSOAPRequest(sEnvelope, "getBetHistory")


txt_return.Text = sReply

HTML Code:
Private Function MakeSOAPRequest(ByVal sReq As String, ByVal sMethod As String) As String
' returns the response xml

' send message to server
oHTTP.open "POST", "https://api.betfair.com/betex-api-public-ws/BFService", False

' set standard SOAP/XML header for the content-type
oHTTP.setRequestHeader "Content-Length", CStr(Len(sReq))
oHTTP.setRequestHeader "Content-Type", "text/xml"
oHTTP.setRequestHeader "SOAPAction", sMethod

' make the SOAP call
oHTTP.send sReq

' get the response xml
MakeSOAPRequest = oHTTP.responseText

End Function




This is day 1 that my eyes have ever seen any Betfair API + SOAP + XML so be gentle with me

Last edited by Trilobite; 12-05-2008 at 16:29.
Trilobite is offline   Reply With Quote
Old 13-05-2008, 10:36   #6 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Ok, if anyone is interested in this stuff

Iam getting somewhere now

As far as i can tell the SOAP-ENV:Envelope part stays the same :

HTML Code:
Private Const QUOTE_MARK As String = """"

Private Const sEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=" _
& QUOTE_MARK & "http://schemas.xmlsoap.org/soap/envelope/" & QUOTE_MARK _
& " xmlns:SOAP-ENC=" & QUOTE_MARK & "http://schemas.xmlsoap.org/soap/encoding/" & QUOTE_MARK _
& " xmlns:xsi=" & QUOTE_MARK & "http://www.w3.org/2001/XMLSchema-instance" & QUOTE_MARK _
& " xmlns:xsd=" & QUOTE_MARK & "http://www.w3.org/2001/XMLSchema" & QUOTE_MARK & ">" _
& "<SOAP-ENV:Body>"
and the SOAP-ENV:Body part is the xml string you send to the server, which is different for each API function, like the keepAlive.xml


My first working function for the KeepAlive request is:

HTML Code:
Private Function Keep_session_alive(original_key As String) As String

Dim xml_to_send As String, sReply As String


'create the SOAP Envelope    original_key is the latest STRsessionToken

xml_to_send = sEnvelope _
& "<m:keepAlive xmlns:m=" & QUOTE_MARK & "http://www.betfair.com/publicapi/BFService/" & QUOTE_MARK & ">" _
& "<m:request>" _
& "<header>" _
& "<clientStamp>" & GetClientStamp & "</clientStamp>" _
& "<sessionToken>" & original_key & "</sessionToken>" _
& "</header>" _
& "</m:request>" _
& "</m:keepAlive>" _
& "</SOAP-ENV:Body>" _
& "</SOAP-ENV:Envelope>"

' post the request & check the return in sReply variable for errors etc
sReply = MakeSOAPRequest(xml_to_send, "KeepAlive")

Debug.Print sReply

'===============
If InStr(sReply, QUOTE_MARK & "n2:APIErrorEnum" & QUOTE_MARK & ">OK<") > 0 Then ' this indicates was sent OK

   MsgBox "REQUESTING KEEPALIVE WAS OK :-) ", vbInformation


' parse the new session key here and store it in STRsessionToken
STRsessionToken = get_sessionToken(sReply)

'===============
Else

MsgBox "ERROR REQUESTING KEEPALIVE !", vbCritical
End If
'===============

End Function
Trilobite is offline   Reply With Quote
Old 13-05-2008, 16:16   #7 (permalink)
Pocket Rocket
 
mcgin's Avatar
 
Join Date: 06 Nov 2005
Posts: 924
Default Re: Betfair Free API

Trilobite, Dealing with the raw XML soap strings is going to be buggy at the best of times, and it'll be a right pain in the ass to debug. Would you not look at using a framework of some kind that hides the SOAP implementation from you? I use an application called Axis in Java, not sure what you could use with VB, but presumably VB.net offers better support for web services then VB6 anyway.
mcgin is offline   Reply With Quote
Old 13-05-2008, 17:03   #8 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Iam not ever going over to DotNet mcgin. But your right, its not something most would do in VB6.

Its just something for myself, and like other stuff i use daily will probably never get further than IDE.

Theres no timescale so ill just plod on with it, doing a bit here and there mate
Trilobite is offline   Reply With Quote
Old 15-05-2008, 16:11   #9 (permalink)
Junior Punter
 
Join Date: 28 Oct 2004
Posts: 58
Default Re: Betfair Free API

Good luck. I ended up writing a whole perl module to access the free API using raw xml requests because there was no perl SOAP modules that supported document/literal encoding at the time.

I'd expect this will be more difficult for you in VB in one aspect - grabbing the data out of the more complicated xml replies. Perl has poweful regular expression capabilities to grep out the data, you'll need a similar vb library to do that also I'd imagine.
arcadia00 is offline   Reply With Quote
Old 15-05-2008, 18:18   #10 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Cheers arcadia00

I like a new challenge like this, its not too bad when there is no real pressure to produce something specific.


So far so good


Ive got the market prices (getMarketPricesCompressed, horse racing) refreshing OK, just the same as if i had Betfair in a browser .

Not knowing any SOAP or XML i thought i would struggle, but Its a lot easier than i thought it would be TBH.


The next step is actually placing a bet through my app


Iam not sure refreshing the getMarketPricesCompressed prices just 10 times a minute will be enough to pay though


Doh !


Ive just checked and i can send 60 p/m for the getMarketPricesCompressed request using the Free API

I have my timer set to 10 p/m, thinking it was the GetMarketPrices request !


Thats enough for tonight, a couple of for me now i think
Trilobite is offline   Reply With Quote
Old 15-05-2008, 19:22   #11 (permalink)
Junior Punter
 
Join Date: 28 Oct 2004
Posts: 58
Default Re: Betfair Free API

It doesn't affect me, but I think they start deducting cash from your balance if you hit them at 60 p/m.
arcadia00 is offline   Reply With Quote
Old 15-05-2008, 19:31   #12 (permalink)
Junior Punter
 
Join Date: 28 Oct 2004
Posts: 58
Default Re: Betfair Free API

opps strike that I think its 0.1p for each request over 20 per second which doesn't affect us.
arcadia00 is offline   Reply With Quote
Old 16-05-2008, 10:01   #13 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Here is the latest list of API and how many requests per minute can be sent :

Compare API Products
Trilobite is offline   Reply With Quote
Old 16-05-2008, 18:01   #14 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

arcadia00 ( or anyone else willing to help )


Have you got a working Logout xml ?

I cant get an OK reply to what i thought would be the correct xml to send.



Ive got the greening up function working ( in theory ) now.
Still got to placeBet for the first time yet though.



Its interesting to see my Suspended message box pop up before the race is complete when watching the race on the ATR channel.

Racing Uk tonight pops up just about the same time the winner crosses the line though.
Trilobite is offline   Reply With Quote
Old 16-05-2008, 21:07   #15 (permalink)
Junior Punter
 
Join Date: 28 Oct 2004
Posts: 58
Default Re: Betfair Free API

Dont think this is displaying right between CODE tags from the preview look I got, so having to strip out all the < and \>
Code:
 ?xml version=" target="_blank">http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:Body
logout xmlns="https://api.betfair.com/global/v3/BFGlobalService"
request
header
clientStamp0clientStamp
sessionTokensession_keysessionToken
header
request
logout
soap:Body
soap:Envelope 

Last edited by arcadia00; 16-05-2008 at 21:13.
arcadia00 is offline   Reply With Quote
Old 16-05-2008, 21:12   #16 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

You have to put it between the HTML tags.
Trilobite is offline   Reply With Quote
Old 16-05-2008, 21:15   #17 (permalink)
Junior Punter
 
Join Date: 28 Oct 2004
Posts: 58
Default Re: Betfair Free API

Oh right thanks.


HTML Code:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <logout xmlns="https://api.betfair.com/global/v3/BFGlobalService"> <request> <header> <clientStamp>0</clientStamp> <sessionToken>$BetfairAPI::session_key</sessionToken> </header> </request> </logout> </soap:Body> </soap:Envelope>
arcadia00 is offline   Reply With Quote
Old 16-05-2008, 22:52   #18 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Nah, still cant get it to work

Keeps returning a
HTML Code:
<faultstring>Rejected illegal operation logout (from client)</faultstring>
fault.


Not to worry, each login expires after 20 minute of in-activity anyway.
Trilobite is offline   Reply With Quote
Old 16-05-2008, 23:26   #19 (permalink)
Junior Punter
 
Join Date: 28 Oct 2004
Posts: 58
Default Re: Betfair Free API

Post up the full raw xml response you're getting to your logout request.
arcadia00 is offline   Reply With Quote
Old 17-05-2008, 07:20   #20 (permalink)
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,561
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Thanks for your help mate


This is what i am sending at the moment :

HTML Code:
xml_to_send = _
"<?xml version=" & QUOTE_MARK & "1.0" & QUOTE_MARK & " encoding=" & QUOTE_MARK & "utf-8" & QUOTE_MARK & "?>" _
& "<soap:Envelope xmlns:soap=" & QUOTE_MARK & "http://schemas.xmlsoap.org/soap/envelope/" & QUOTE_MARK _
& " xmlns:xsi=" & QUOTE_MARK & "http://www.w3.org/2001/XMLSchema-instance" & QUOTE_MARK _
& " xmlns:xsd=" & QUOTE_MARK & "http://www.w3.org/2001/XMLSchema" & QUOTE_MARK & ">" _
& "<soap:Body>" _
& "<logout xmlns=" & QUOTE_MARK & "https://api.betfair.com/global/v3/BFGlobalService" & QUOTE_MARK & ">" _
& "<request>" _
& "<header>" _
& "<clientStamp>0</clientStamp>" _
& "<sessionToken>" & STRsessionToken & "</sessionToken>" _
& "</header>" _
& "</request>" _
& "</logout>" _
& "</soap:Body>" _
& "</soap:Envelope>"



'call the function that posts the xml string to the betfair server
sReply = MakeSOAPRequest(xml_to_send, "logout")

HTML Code:
'###########################################################################################################
Public Function MakeSOAPRequest(ByVal sReq As String, ByVal sMethod As String) As String


' send message to server
oHTTP.open "POST", "https://api.betfair.com/betex-api-public-ws/BFService", False

' set standard SOAP/XML header for the content-type
oHTTP.setRequestHeader "Content-Length", CStr(Len(sReq))
oHTTP.setRequestHeader "Content-Type", "text/xml"
oHTTP.setRequestHeader "SOAPAction", sMethod

' make the SOAP call
oHTTP.send sReq

' get the response xml
MakeSOAPRequest = oHTTP.responseText

Set oHTTP = Nothing 

End Function



and this is the returned xml :


HTML Code:
<?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>Rejected illegal operation logout (from client)</faultstring></env:Fault></env:Body></env:Envelope>

Trilobite is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts



All times are GMT. The time now is 02:32.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Free £100 Bet!
Online Bookmakers
Free £100 Bet!

Recommended Bookies: Bet365 | BetDirect | | Blue Square | Canbet | Centrebet |