Coder Social home page Coder Social logo

yfar's Introduction

YFAR

A collection of functions to get data from the Yahoo! Fantasy API.

Introduction

The functions in this package can retrieve data from public leagues and the private leagues participated in by the current user logged into Yahoo.

The Yahoo Fantasy API uses Oauth2.0 for authentication. To use the functions in this package you will need a client id and client secret obtained by registering an app with the Yahoo Developer Network.

After creating a token and retrieving some simple input data you can use the functions to return data from games, leagues and teams.

  • There are no extensive instructions in this package for registering an app with the Yahoo Developer Network but here are some resources :

  • Package highlights:

    • 18 functions to get data from various resource of the API.
    • Notable functions include y_rosters(), y_players(), y_draft_results(), y_draft_adp().
    • Return data from both current and past leagues.
    • Functions by default return tibbles with an option to return a list.
    • Functions are written using the tidyverse.
  • Function mechanics in a nutshell:

    • Takes the keys and other provided arguments to generate a uri.
    • Using the internal function .y_get_request() sends a get request to the yahoo api.
    • The api returns a response which containts fantasy content in JSON format.
    • JSON fantasy content is parsed using internal functions heavily reliant on the purrr package.
    • Return a tibble.
    • Option to return a list which includes uri, response, content and the api resource.

Installation

# install.packages("devtools")
devtools::install_github("https://github.com/macraesdirtysocks/YFAR")

The Basics

  • At its core YFAR has 3 types of functions:
    • Authentication
    • Accessory Functions
      • Uninteresting but useful. Mostly for acquiring data to supply as arguments to other functions i.e. weeks, dates, team and league keys, etc.
    • The Beef
      • Probably why you are here. Rosters, stats, standings, match-ups etc.

Authentication

After creating and registering your app you should receive a client id and client secret.

Pass the client id and secret as arguments to YFAR::y_create_token() which are passed to httr to create an access token.

This token is an argument to all functions in this package.

my_token <- y_create_token(my_key, my_secret, app_name)

Auxiliary data functions

There a few of these but the most noteworthy is y_games(). This function will return a tibble containing information on all your fantasy leagues which can be used as arguments for the more interesting functions.

y_games(my_token)

The Beef

Some functions accept a team_key or league_key. Any function with an key argument as opposed to the more explicit league_key or team_key can accept a varitey of keys.

  • A few examples

    • Get League Rosters

      rosters <- y_rosters(key, my_token)

    • Get Draft Results

      y_draft_results <- function(key, token_name)

And much more. See the vignette for more info.

Other notes

If you have suggestions or want to colab shoot me an email.

yfar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.