Closed samgledhill closed 2 years ago
Sam,
I've just looked back through the API docs (https://docs.developer.betfair.com/pages/viewpage.action?pageId=3834909) and there is no obvious way to test if there is an active session. I would use a tryCatch to see if it is logged in and then log in if required. Would that work for your code? I use this technique for scraping some websites and it is pretty painless.
Soccerama
Ah yes - Thanks Soccerama - great suggestion and I'll definitely incorporate that. What do you recommend as best practice for storing the Username, Password and API details? I'm guessing store them as local environment variables? Thanks for your help!
It's probably best to ask someone else what best practice is. For the record, I store the details in a csv file and my code looks like this:
details <- read.csv(paste0(DATA_PATH,"login_details.csv"))
loggedin <- loginBF(details[[1,1]], details[[2,1]], details[[3,1]])
There are probably more robust and secure ways to do this.
Also, if you are logged in with the API and you log in again then it doesn't seem to break anything, so you may not even need the tryCatch.
PhillC is having some troubles logging in to GitHub at the moment but he suggested that you could also use the keepAlive()
function. It returns this:
> keepAlive()
[1] "FAIL:INPUT_VALIDATION_ERROR"
if you are not logged in.
Thanks folks - this has been so helpful! Appreciate your support.
Hi there Phil - great package and I'm loving it's simplicity and ease of use - Thanks!!
I'm building a shiny app that looks for value bets by combining a web-scraper for bookmaker odds and betfair markets.
One thing that repeatedly halts the Shiny app is when I forget to run the Login function upfront.
Is there any opportunity to check for "Logged In" status at Betfair? Or is a better alternative to use a Login and Logout call for every session?