marcoblume / pinnacle.API

R Wrapper for the Pinnacle API
40 stars 13 forks source link

showOddsDF issues #17

Closed ractingmatrix closed 7 years ago

ractingmatrix commented 7 years ago

Hello,

I got the following error:


Error: lexical error: invalid char in json text. <!DOCTYPE html PUBLIC "-//W3C// (right here) ------^


when I run the following code:


Sport_data <- GetSports() Soccer_ID <- Sport_data$SportID[Sport_data$SportName=="Soccer"] League_data <- GetLeagues("Soccer") active_leagues <- League_data %>% filter(leagues.eventCount >= 1) Soccer_League_Ids <- active_leagues$leagues.id soccer_data <- showOddsDF(29,leagueids=Soccer_League_Ids,since=NULL,islive = 0,force = TRUE, tableformat = "mainlines", namesLength = 3,attachLeagueInfo = TRUE, oddsformat = "DECIMAL")


And if I changed the last line of the above code to :


soccer_data <- showOddsDF(29,leagueids=NULL,since=NULL,islive = 0,force = TRUE, tableformat = "mainlines", namesLength = 3,attachLeagueInfo = TRUE, oddsformat = "DECIMAL")


I got the following error:


Error in merge.data.table(., inrunning[sports.id %in% sportid], by.x = "leagues.events.id", : Elements listed in by.y must be valid column names in y.


Grateful for any advice!

Regards Ma

shapenaji commented 7 years ago

Hi ractingmatrix, that's an error you would typically get if the API is not visible from your location. I'll look at trying to create a better message for that in future. (Unfortunately it's difficult to test without being in a place where the API is unavailable)

ractingmatrix commented 7 years ago

Thx for the reply shapenaji. The code actually was working fine before and I just got these errors recently. What do you mean by "the API is not visible from your location "?

shapenaji commented 7 years ago

API isn't accessible in all regions, they block some regions. But if it was fine before... well it's definitely an issue coming from the API. Let me see.

shapenaji commented 7 years ago

My apologies, reproduced error, it appears to be connected to using leagueids. Hard to say if it's a bug on my side or from the API, I'll investigate

shapenaji commented 7 years ago

Okay, so this error happens if you use around 270 leagueids. What's happening is that the API will not allow you to send more leagueIds than a certain limit (I assume to prevent it from being used to impact their servers by sending a lot of data in requests)

I could potentially increase the number by switching to POST instead of GET, but I'll have to look at that more.

Is there a big reason not to just request all leagues and then filter? (that will still be 4 calls)

(Oh, and I can't reproduce the second error)

ractingmatrix commented 7 years ago

Thanks for looking into it shapenaji. I will see if i can do some filtering on leagueids to get below the 270 limit.

shapenaji commented 7 years ago

FYI, it could be less than 270, (if the league Ids are longer, it's a matter of digits, rather than fixed number of ids), I think pulling no more than 100 at a time is safe.