项目作者: dynastyprocess

项目描述 :
R API Client for Fantasy Football League Platforms
高级语言: R
项目地址: git://github.com/dynastyprocess/ffscrapr.git
创建时间: 2020-05-18T19:41:15Z
项目社区:https://github.com/dynastyprocess/ffscrapr

开源协议:Other

下载


" class="reference-link">ffscrapr

An R Client for Fantasy Football League APIs

CRAN
status
Dev
status
Lifecycle:
stable
Codecov test
coverage
R build
status
API
status
nflverse
discord

Helps access various Fantasy Football APIs (currently MFL, Sleeper,
Fleaflicker, and ESPN - perhaps eventually Yahoo and others) by handling
authentication/rate-limiting/caching, forming appropriate calls, and
returning tidy dataframes which can be easily connected to other data
sources.

Installation

Install the stable version of this package from CRAN:

  1. install.packages("ffscrapr")

Install the development version from either
r-universe or GitHub:

  1. install.packages("ffscrapr", repos = c("https://ffverse.r-universe.dev", getOption("repos")))
  2. # pak is recommended, see https://github.com/r-lib/pak
  3. pak::pak("ffverse/ffscrapr")
  4. # can also use remotes
  5. remotes::install_github("ffverse/ffscrapr")

Usage

All ffscrapr functions start with a connection object created by
ff_connect(), which stores connection, authentication, and other
user-defined parameters. This object is used by all other functions to
help return the correct data.

  1. library(ffscrapr)
  2. ssb <- ff_connect(platform = "mfl", league_id = "54040", season = 2020)
  3. # Get a summary of league settings
  4. ff_league(ssb) %>% str()
  5. #> tibble [1 × 17] (S3: tbl_df/tbl/data.frame)
  6. #> $ league_id : chr "54040"
  7. #> $ league_name : chr "The Super Smash Bros Dynasty League"
  8. #> $ season : int 2020
  9. #> $ league_type : chr NA
  10. #> $ franchise_count : num 14
  11. #> $ qb_type : chr "1QB"
  12. #> $ idp : logi FALSE
  13. #> $ scoring_flags : chr "0.5_ppr, TEPrem, PP1D"
  14. #> $ best_ball : logi FALSE
  15. #> $ salary_cap : logi FALSE
  16. #> $ player_copies : num 1
  17. #> $ years_active : chr "2018-2021"
  18. #> $ qb_count : chr "1"
  19. #> $ roster_size : num 33
  20. #> $ league_depth : num 462
  21. #> $ draft_type : chr " email draft"
  22. #> $ draft_player_pool: chr "Both"
  23. # Get rosters
  24. ff_rosters(ssb)
  25. #> # A tibble: 417 × 11
  26. #> franchise_id franchise_name player_id player_name pos team age
  27. #> <chr> <chr> <chr> <chr> <chr> <chr> <dbl>
  28. #> 1 0001 Team Pikachu 13189 Engram, Evan TE NYG 28.4
  29. #> 2 0001 Team Pikachu 11680 Landry, Jarvis WR CLE 30.2
  30. #> 3 0001 Team Pikachu 13645 Smith, Tre'Quan WR NOS 27.1
  31. #> 4 0001 Team Pikachu 12110 Brate, Cameron TE TBB 31.6
  32. #> 5 0001 Team Pikachu 13168 Reynolds, Josh WR LAR 28
  33. #> # … with 412 more rows, and 4 more variables: roster_status <chr>,
  34. #> # drafted <chr>, draft_year <chr>, draft_round <chr>
  35. #> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
  36. # Get transactions
  37. ff_transactions(ssb)
  38. #> # A tibble: 1,145 × 12
  39. #> timestamp type type_desc franchise_id franchise_name
  40. #> <dttm> <chr> <chr> <chr> <chr>
  41. #> 1 2021-02-12 14:32:39 TRADE traded_away 0008 Team Bowser
  42. #> 2 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
  43. #> 3 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
  44. #> 4 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
  45. #> 5 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
  46. #> # … with 1,140 more rows, and 7 more variables: player_id <chr>,
  47. #> # player_name <chr>, pos <chr>, team <chr>, bbid_spent <dbl>,
  48. #> # trade_partner <chr>, comments <chr>
  49. #> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

Platform-specific guides on getting started with ffscrapr are here:

There are also some more advanced guides for custom API calls in the
Articles section, as well as
some guides on optimizing ffscrapr’s
performance
.

Support

The best places to get help on this package are:

Contributing

Many hands make light work! Here are some ways you can contribute to
this project:

Terms of Use

The R code for this package is released as open source under the MIT
license
.

The APIs and data accessed by this package belong to their respective
owners, and are governed by their terms of use.