Betfair API-NG

Post Reply
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

API-NG was last mentioned on the Today's Racing thread, so I thought I'd move the discussion to a new one.
Euler wrote:We don't feel API-NG is ready enough at the moment. The DEV edition has elements of NG in it, but that is enough to know it's not ready.

We will introduce it when we are happy that it's worth doing so for our users.
I had another reminder by email from Betfair today about the cut-off in November. Peter, are you concerned about them attempting to push a hard deadline?

What in particular have you found unsatisfactory from their new API so far? Is it performance?

Are you raising your concerns with them?
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

I have been learning python / wrestling with the new API NG, it looks like I am on a very steep learning curve but loving it.

Does anyone know if there are still request limits? As my data collector decided to loop hitting the api every nanosecond :shock:
Bet Angel
Bet Angel
Bet Angel
Posts: 3999
Joined: Tue Apr 14, 2009 3:47 pm

There are no chargeable request limits, so you should be fine. The guidelines say you should only request price information every 200ms, so if you were to abuse that for any length of time you may get an e-mail.
Wainwright
Posts: 108
Joined: Mon Jan 23, 2012 1:10 pm

There are limits to the amount of information you can request per call, weighted by the type of information you ask for;

https://api.developer.betfair.com/servi ... est+Limits

The call will fail if you exceed the limit
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

I haven't been told off yet..
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Quick question regarding placing bets in-play, when you send the 'placeOrders' request do you receive the response immediately or does it take 1 second before you get it (e.g. horse racing)
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

I'm pretty sure it blocks for 1 second before returning a response. That's certainly the behaviour of the old API. I can't confirm 100% for API-NG but I think it does the same.
Wainwright
Posts: 108
Joined: Mon Jan 23, 2012 1:10 pm

Yes, that's my experience. The placeOrders call seems to block until the orders are actually placed or have failed to place - in-play it takes over a second to come back with the placeExecutionReport (pre-off it's more like 100ms).
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

That's what I thought, so what is the norm in placing an inplay bet whilst carrying on the program? Do I need to look into multi processes (using Python)

Thanks for the help guys
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

Yes, if you want your program to continue doing other stuff, then you'll either need to fork separate threads or use whatever support Python has for asynchronous calls and callbacks. I'm not familiar with Python but I'm sure there are modules you can use with a quick Google.

It does start to get a bit complicated once you consider all the possibilities of what might happen though. For example you don't really want to place any further bets on the same horse until you know the outcome (matched or unmatched?) of that first bet which is still pending. But perhaps you might still be interested in placing bets on other horses while the other bet is pending.

Personally, I'd suggest keeping it simple to start with. Just live with the fact your program blocks for 1 second while a bet is placed. Refine it later once you have to or want to optimise.
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

I am on a quest for speed so this morning I have modified my code to 'thread' placeOrders and cancelOrders. I just added a dictionary with the bet status to stop duplicates and it has made a massive difference to speed even pre-play.

Thanks for the help
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Is there some sort of limit per day? I record horse racing in-play and by about 7pm I get this error..
screenshot.png
But when I switch to a different account it works fine :?
You do not have the required permissions to view the files attached to this post.
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

That's unusual. I've been requesting market odds in-play at fairly high frequency (250ms) for the last couple weeks with no problems. I did read in one of the other posts that they don't recommend a frequency higher than 200ms though. However I would have expected a proper error response if you had been blacklisted or something. I'd recommend just contacting them for assistance.

Do let us know of you find out what the problem is though.
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Changing account didn't work, I put no delay in my requests so I am hitting the server every 100ms with no problems (normally) I put a simple try/except code in to trap the error (Thanks to Golfer)
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

For those of you who have been writing your own code to connect to the API-NG, have you found that requesting the status of your bets is sometimes very laggy?

In particular I'm talking about in-play horse racing. Sometimes it'll take over a second to return the status of my bets (while requested as part of the market book).

I'm pretty sure it's the status of the bets that's holding up the response because when I don't include them as part of the request it never seems to lag.

Perhaps this is one of the things that Peter is referring to when he says that API-NG just isn't ready yet? Kind of concerning when they keep warning of the cut off in November!
Post Reply

Return to “Betfair Exchange API”