Skip to main content

Overview

These endpoints fetch detailed player statistics for your fantasy team from the Yahoo Fantasy API. Two variants are available: weekly stats for a specific week, and season-long cumulative stats.

Authentication

Both endpoints require an active user session with a selected league and team.

Weekly Player Stats

Retrieve player statistics for a specific week of the fantasy season.

Path Parameters

week
integer
required
The week number for which to retrieve player statistics

Response

fantasy_content
object
The root object containing player statistics from Yahoo Fantasy API

Example Request

curl -X GET "https://your-domain.com/api/player_stats_week/5" \
  -H "Cookie: session=your-session-cookie"

Season Player Stats

Retrieve cumulative season statistics for all players on your team.

Request

This endpoint does not accept any parameters. It automatically uses the league and team from the user’s session.

Response

fantasy_content
object
The root object containing player statistics from Yahoo Fantasy API

Example Request

curl -X GET "https://your-domain.com/api/player_stats_season" \
  -H "Cookie: session=your-session-cookie"

Error Responses

Both endpoints share common error responses:
error
string
Error message describing what went wrong

Possible Errors

  • 400 Bad Request - No league selected in session
    {"error": "no league chosen"}
    
  • 404 Not Found - Could not determine user’s team
    {"error": "could not find team key for your team"}
    
  • 500 Internal Server Error - Failed to fetch data from Yahoo API
    {"error": "Error details"}
    

Implementation Details

These endpoints are implemented in main.py:752-774 and perform the following:
  1. Validate that a league is selected in the user’s session
  2. Call get_user_team_key() to determine the user’s team key from league data
  3. Call the Yahoo Fantasy API with the appropriate parameters:
    • Weekly: fantasy/v2/team/{team_key}/players/stats;type=week;week={week}
    • Season: fantasy/v2/team/{team_key}/players/stats;type=season
  4. Return the complete Yahoo API response as JSON
  5. Log errors and return appropriate HTTP status codes on failure

Use Cases

  • Display current roster with player performance
  • Compare player statistics across weeks
  • Analyze player trends and consistency
  • Make lineup decisions based on recent performance
  • Build player comparison and ranking tools

Build docs developers (and LLMs) love