GithubHelp home page GithubHelp logo

Comments (3)

wiscostret avatar wiscostret commented on May 26, 2024 1

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.

wiscostret avatar wiscostret commented on May 26, 2024

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.

py9mrg avatar py9mrg commented on May 26, 2024

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 an all_players = TRUE argument.
    What do you think?

from fplscrapr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.