Overview
The bulk matchups endpoint efficiently fetches head-to-head matchup information for multiple weeks of your Yahoo Fantasy Basketball league in a single API call. This is ideal for displaying season schedules, analyzing strength of schedule, or building matchup calendars.Authentication
Requires an active user session with a selected league.Request
Specifies which weeks to retrieve matchup data for. Accepts two formats:
- Range format:
"1-5"- Retrieves weeks 1 through 5 (inclusive) - Comma-separated:
"13,14,15"- Retrieves specific weeks 13, 14, and 15
"1-5" if not provided.Response
The root object containing all matchup data from Yahoo Fantasy API
Error Responses
Error message describing what went wrong
HTTP status code returned by Yahoo API (included for Yahoo API errors)
Possible Errors
-
401 Unauthorized - User not authenticated or session expired
-
400 Bad Request - No league selected
-
Yahoo API Errors - Passes through Yahoo’s error messages with status code
-
500 Internal Server Error - Unexpected error
Example Requests
Example Response
Implementation Details
This endpoint is implemented inmain.py:934-968 and performs the following:
- Validates user authentication (checks for active session token)
- Validates league selection (checks for
league_keyin session) - Retrieves the
weeksparameter from query string (defaults to"1-5") - Constructs the Yahoo API path:
fantasy/v2/league/{league_key}/teams;out=matchups;weeks={weeks} - Calls the Yahoo Fantasy API via the
yahoo_api()helper function - Returns the complete Yahoo API response as JSON
- Handles errors with detailed logging and appropriate HTTP status codes
Error Handling
The endpoint includes sophisticated error handling:- HTTP errors from Yahoo: Extracts error description from Yahoo’s JSON response when available
- Network errors: Returns 500 with exception details
- Logging: All requests and errors are logged with request parameters for debugging
Yahoo API Format
The endpoint passes theweeks parameter directly to Yahoo’s API, which supports:
- Range syntax:
weeks=1-5fetches weeks 1, 2, 3, 4, 5 - List syntax:
weeks=13,14,15fetches only weeks 13, 14, 15 - Mixed syntax: While not tested, Yahoo may support
weeks=1-3,5,7-9
Use Cases
- Build complete season matchup calendars
- Display remaining schedule for each team
- Analyze strength of schedule (who plays who when)
- Identify playoff matchup opponents in advance
- Calculate potential tiebreaker scenarios
- Show head-to-head records between specific teams
- Plan roster moves based on upcoming opponent strength
Performance Considerations
- This endpoint fetches data for all teams in the league for the specified weeks
- Requesting many weeks (e.g.,
1-24) returns significantly more data than a single week - Consider requesting only the weeks you need to minimize response size
- Yahoo API rate limits apply; avoid excessive requests
- Response parsing may take longer for large week ranges in large leagues
Notes
- Week numbers must be valid for the current season (typically 1-24 for NBA fantasy)
- Invalid week numbers may cause Yahoo API errors
- Playoff weeks are included in the range if specified
- Bye weeks (if any) will show no matchup or special matchup status
- The response structure is complex due to Yahoo’s nested array/object format
Related Endpoints
- Scoreboard - Get detailed results for a single week’s matchups
- Season Averages - Compare team performance across the season