Fantasy football app?

Not sure if this has been talked about before but I think it would be a really cool idea to have either fantasy football scores. standings, or player news. Have the app link to either Yahoo, Sleepr, or ESPN fantasy football sites to have updates on our teams. It may be a stretch but even including our team’s logos (similar to other pro sports apps) would really make it worthwhile.

I am trying to work on this now (when I have time between work and school). It seems like it is pretty simple for Sleeper and ESPN public leagues. I can access the data, I just need to spend the time finding and formatting it. I don’t play in Yahoo so I haven’t tried that yet.

On another note, I am still trying to figure out how to access private ESPN leagues. Usually, I am able to set cookies to access the API data, but I cannot figure out how to do that in starlark language, so any help with that would be appreciated. I will post some code/app when I get it to a more complete state.

3 Likes

Played around with this a bit from my current slack bot code. I’ll try to test it out, but there are some variables that you will have to add for your unique league.

// import the necessary modules
import http
import json
import graphics
import time

// set up the Tidbyt screen dimensions
screen_width = 192
screen_height = 32

// set up the API endpoint and parameters
api_endpoint = "https://fantasy.espn.com/apis/v3/games/ffl/seasons/2022/segments/0/leagues/{LEAGUE_ID}"
api_params = {
  "view": "mTeam"
}

// make the API request
api_response = http.get(api_endpoint.format(LEAGUE_ID="your_league_id"), params=api_params)
api_data = json.loads(api_response.content)

// extract the relevant data from the API response
teams_data = api_data["teams"]
league_standings = [(team_data["location"], team_data["nickname"], team_data["record"]["overall"]["wins"], team_data["record"]["overall"]["losses"], team_data["record"]["overall"]["ties"], team_data["pointsFor"], team_data["pointsAgainst"]) for team_data in teams_data]

// sort the league standings by wins, then points for
league_standings.sort(key=lambda x: (x[2], x[5]), reverse=True)

// format the league standings for display
league_standings_text = "League standings:\n"
for i, standing in enumerate(league_standings):
    league_standings_text += str(i+1) + ". " + standing[0] + " " + standing[1] + ": " + str(standing[2]) + "-" + str(standing[3]) + "-" + str(standing[4]) + ", PF: " + str(standing[5]) + ", PA: " + str(standing[6]) + "\n"

// draw the matchup information on the screen
graphics.clear()
graphics.draw_text(x=0, y=0, text="This week's matchup:", size=12, color="#FFFFFF")

// display the matchup information for 5 seconds
graphics.show()
time.sleep(5)

// set up the API endpoint and parameters for the next screen
api_endpoint = "https://fantasy.espn.com/apis/v3/games/ffl/seasons/2022/segments/0/leagues/{LEAGUE_ID}"
api_params = {
  "view": "mTeam"
}

// make the API request for the next screen
api_response = http.get(api_endpoint.format(LEAGUE_ID="your_league_id"), params=api_params)
api_data = json.loads(api_response.content)

// extract the relevant data from the API response for the next screen
teams_data = api_data["teams"]
division_standings = {}
for team_data in teams_data:
    division_id = team_data["divisionId"]
    if division_id not in division_standings:
        division_standings[division_id] = []
    division_standings[division_id].append((team_data["location"], team_data["nickname"], team_data["record"]["overall"]["wins"], team_data["record"]["overall"]["losses"], team_data["record"]["overall"]["ties"]))

// format the division standings for display
division_standings_text = ""
for division_id, standings in division_standings.items():
    division_standings_text += "Division " + str(division_id) + ":\n"
    for standing in standings:
        division_standings_text += "- " + standing[0] + " " + standing[1] + ": " +



2 Likes

Wish I had the skill set to help. Excited, nonetheless.

The ability to see the scores of our league in Sleeper while watching redzone on Sundays would be amazing. I wish I could help develop

Hey all - I created the Yahoo Fantasy Football app. I just pushed an update that is awaiting approval that makes things a little simpler but check it out. Let me know if you think anything is missing.

-Jay

Any update to this app for espn and sleeper fantasy leagues? Season is sneaking up on us, and I’m sure if you make your espn league a public league (talk to your commish) data could be pulled.

I’m trying to learn how to test apps (since someone left code). I’m not that savvy so hopeful that someone smart figures it out. I’d even send you a Venmo for a drink or two as thank you

Any update on espn? See some code below

Can you publish this?

This topic was automatically closed after 365 days. New replies are no longer allowed.