uberfastman / yfpy

Python API wrapper for the Yahoo Fantasy Sports public API (supports NFL, NHL, MLB, and NBA).
https://pypi.org/project/yfpy/
GNU General Public License v3.0
163 stars 44 forks source link

Request: get_league_transactions() Waiver FAB bids and Trade draft picks #46

Closed PChabelski closed 7 months ago

PChabelski commented 9 months ago

Hello! I have been using the query.get_league_transactions() method to parse transaction data for my yahoo fantasy hockey league. I have noticed that there are two bits of information that are unavailable at the moment. I am currently using version 13.0.0.

1. FAB Spent on Waiver acquisitions: In cases where a GM has spent FAB to acquire a player off of waivers, the amount of $ spent is currently unavailable through the output. Is there a way to pull the FAB $ spent data?

(sample output for a transaction that has FAB $ spent):

{'transaction': {
   "players": [
     {
       "player": {
         "display_position": "C",
         "editorial_team_abbr": "CGY",
         "name": {
           "ascii_first": "Mikael",
           "ascii_last": "Backlund",
           "first": "Mikael",
           "full": "Mikael Backlund",
           "last": "Backlund"
         },
         "player_id": 4263,
         "player_key": "419.p.4263",
         "position_type": "P",
         "transaction_data": {
           "destination_team_key": "xxx.l.xxxxx.t.xx",
           "destination_team_name": "xxxxxxxxx",
           "destination_type": "team",
           "source_type": "waivers",
           "type": "add"
         }
       }
     },
     {
       "player": {
         "display_position": "D",
         "editorial_team_abbr": "TOR",
         "name": {
           "ascii_first": "Mark",
           "ascii_last": "Giordano",
           "first": "Mark",
           "full": "Mark Giordano",
           "last": "Giordano"
         },
         "player_id": 3614,
         "player_key": "419.p.3614",
         "position_type": "P",
         "transaction_data": {
           "destination_type": "waivers",
           "source_team_key": "xxx.l.xxxxx.t.xx",
           "source_team_name": "xxxxxxxxxxx",
           "source_type": "team",
           "type": "drop"
         }
       }
     }
   ],
   "status": "successful",
   "timestamp": 1678438787,
   "transaction_id": 1582,
   "transaction_key": "xxx.l.xxxxx.tr.1582",
   "type": "add/drop"
 }}

2. Draft Picks in Trades: In trades involving draft picks, the draft pick information is not displayed. Is there any way to add these picks to the trade transaction information?

(sample output where a few draft picks should be included):

 {'transaction': {
   "players": [
     {
       "player": {
         "display_position": "RW",
         "editorial_team_abbr": "VAN",
         "name": {
           "ascii_first": "Brock",
           "ascii_last": "Boeser",
           "first": "Brock",
           "full": "Brock Boeser",
           "last": "Boeser"
         },
         "player_id": 6765,
         "player_key": "419.p.6765",
         "position_type": "P",
         "transaction_data": {
           "destination_team_key": "xxx.l.xxxxxx.t.xx",
           "destination_team_name": "xxxxxxxxxxx",
           "destination_type": "team",
           "source_team_key": "yyy.l.yyyyy.t.y",
           "source_team_name": "yyyyyyyy",
           "source_type": "team",
           "type": "trade"
         }
       }
     },
     {
       "player": {
         "display_position": "LW",
         "editorial_team_abbr": "NSH",
         "name": {
           "ascii_first": "Filip",
           "ascii_last": "Forsberg",
           "first": "Filip",
           "full": "Filip Forsberg",
           "last": "Forsberg"
         },
         "player_id": 5691,
         "player_key": "419.p.5691",
         "position_type": "P",
         "transaction_data": {
           "destination_team_key": "yyy.l.yyyyy.t.y",
           "destination_team_name": "yyyyyyyyyy",
           "destination_type": "team",
           "source_team_key": "xxx.l.xxxxxx.t.xxx",
           "source_team_name": "xxxxxxxx",
           "source_type": "team",
           "type": "trade"
         }
       }
     }
   ],
   "status": "successful",
   "timestamp": 1676019280,
   "tradee_team_key": "xxx.l.xxxxxx.t.xx",
   "tradee_team_name": "xxxxxxxxxxx",
   "trader_team_key": "yyy.l.yyyyyy.t.y",
   "trader_team_name": "yyyyyyyyy",
   "transaction_id": 1334,
   "transaction_key": "xxx.l.xxxxx.tr.1334",
   "type": "trade"
 }}

Any chance this data can be parsed and added to a future release? Thanks so much for all the hard work!

uberfastman commented 7 months ago

Hi @PChabelski, thanks so much for bringing this to my attention! None of the hockey leagues I tested with had draft pick trading or FAAB, and unfortunately when a Yahoo league doesn't have something the data fields are just excluded. That being said, I just released v15.0.0 in #48, which adds in support for both of those data fields in transactions for you.

For future reference as well, if there is ever a data field that you are missing, you should be able to retrieve the value by parsing self._extracted_data from any YFPY model object, as that private field contains the raw cleaned data retrieved from the API before casting and parsing. Obviously I want to support all data fields I can find, but it is a way for you to still access anything that the API returns regardless of whether or not I've built in native support in the package.