Comments (3)
We are now live for the 21-22 season and the function update includes a new function - get_player_ids() - which returns a data frame of all player ids and names. Should make things easier to combine datasets and work with the API data. Thanks for the suggestion!
from fplscrapr.
Hi there, thank you for this comment, and I agree with the conceptual idea. I will include this in the next package update, likely ahead of the new season in August. Or, if you are willing, you can submit a pull request with the functionality, then I will review and merge. Thanks again.
from fplscrapr.
Hello, thanks for the reply. Have had a quick look at the code and this seems pretty easy depending how much functionality you want to make inherent to the package. For example, in player_functions.R
the function get_player_id
has the line(s):
elements <- jsonlite::fromJSON("https://fantasy.premierleague.com/api/bootstrap-static/")$elements
I'm completely new to JSON and the FPL API so I didn't realise that that returns the info for all players for the current GW. That then means that nrow(elements)
will return the total number of players - and this can then be used in my example above. e.g. something like:
# I haven't actually run this so may not work as is, but roughly this:
max_id <- nrow(jsonlite::fromJSON("https://fantasy.premierleague.com/api/bootstrap-static/")$elements)
purrr::map_dfr(1:max_id, get_player_details)
As an aside - I really don't understand what FPL are doing as their API is confusing to me. For example, elements
above contains completely different columns as get_player_details
(which uses $history not $elements from the FPL API) - I mean, why don't they just include all columns in both so elements and history match? Aaaaanyway.
But this is where the questions come of how you want to do this.
- It could be as simple as creating a function like
get_player_ids
which literally returns the ids (of max id) for the players (maybe a data.frame of name and id?). Obviously this can change during the transfer window(s). - It could be a function which incorporates that with actually getting the player details - e.g. another function like
get_all_player_details
. - Or it could be incorporated into the
get_player_details
function itself. Something like anall_players = TRUE
argument.
What do you think?
from fplscrapr.
Related Issues (20)
- Error message from "get_player_details() " HOT 2
- parse_con error in get_player_details() HOT 2
- JSON parsing error with `get_player_details()` HOT 6
- Can't get function to work with current season data HOT 2
- Is not working anymore? HOT 2
- Possible to add entryid to the get_entry_picks function? HOT 5
- R Version 4.0.2 HOT 1
- Missing variables in get_player_details for season 19/20 HOT 2
- Can't get_player_details of 20/21 HOT 5
- get_player_details error HOT 1
- Authentication issues using get_league and get_league_entries HOT 7
- get_player_details() HOT 1
- SSL certificate problem: certificate has expired HOT 1
- Error in open.connection(con, "rb") HOT 1
- Obtain specific page for get_league_entries()
- testing
- Get Games List HOT 1
- Package installation issue HOT 4
- Install package HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fplscrapr.