Skip to main content

Overview

The team logo endpoint fetches the logo image URL for the currently authenticated user’s fantasy team. This allows you to display custom team branding in your application.

Authentication

Requires an active user session with a selected league and team.

Request

This endpoint does not accept any query parameters. It automatically identifies the current user’s team based on session data.

Response

logo_url
string
The URL of the team’s logo image. Returns null if no logo is found or set for the team.

Example Success Response

{
  "logo_url": "https://yahoofantasysports-res.cloudinary.com/image/upload/..."
}
{
  "logo_url": null
}

Error Responses

error
string
Error message describing what went wrong

Possible Errors

  • 400 Bad Request - No league selected in session
    {"error": "no league chosen"}
    
  • 500 Internal Server Error - Failed to parse team data
    {"error": "could not find teams structure in league data"}
    
  • 500 Internal Server Error - Failed to fetch data from Yahoo API
    {"error": "Error details"}
    

Example Request

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

Implementation Details

This endpoint is implemented in main.py:776-831 and performs the following:
  1. Validates that a league is selected in the user’s session
  2. Calls the Yahoo Fantasy API: fantasy/v2/league/{league_key}/teams
  3. Iterates through all teams in the league to find the current user’s team by:
    • Matching the team name from session (team_name)
    • Checking for is_current_login flag in manager data
  4. Extracts the logo URL from the team’s team_logos array
  5. Returns the logo URL or null if no logo is found
  6. Logs errors and returns appropriate HTTP status codes on failure

Team Identification

The endpoint uses multiple methods to identify the current user’s team:
  • Team Name Match: Compares team name from session data
  • Manager Login Status: Checks the is_current_login flag in manager data
This dual approach ensures reliable team identification even if team names have changed.

Logo Structure

Yahoo’s team data includes a team_logos array. The endpoint:
  • Extracts the first logo from the array
  • Returns the url property from the logo object
  • Typically returns the “large” size variant

Use Cases

  • Display team branding in dashboards
  • Show team logos in matchup views
  • Personalize user interface with team identity
  • Build league standings with team imagery

Notes

  • Not all teams have custom logos; default/missing logos return null
  • Logo URLs are hosted by Yahoo’s CDN (typically Cloudinary)
  • URLs are persistent but may change if team logo is updated
  • Consider caching logo URLs to reduce API calls

Build docs developers (and LLMs) love