# hkyplyr/yfantasy-api architecture

> Architecture diagram of the GitHub repository hkyplyr/yfantasy-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hkyplyr/yfantasy-api
- Repository: https://github.com/hkyplyr/yfantasy-api

## Overview

Yahoo Fantasy API is a fluent Python client: users build game, league, team, or user resource queries, then call get() to retrieve Yahoo data as Python models. Authentication obtains or refreshes OAuth tokens and caches them locally. The README highlights roster/player statistics and league draft results; the API modules also expose broader resource capabilities. Edges reflect shown calls or imports; some resource details are based on the source index rather than inspected implementations.

Main entry points: [`yfantasy_api/api/api.py`](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/api.py) (YahooFantasyApi), [`yfantasy_api/api/terminal.py`](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/terminal.py) (Query terminal), [`yfantasy_api/api/league.py`](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/league.py) (League queries), [`yfantasy_api/api/team.py`](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/team.py) (Team queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client orchestration"]
  node_client["YahooFantasyApi<br/>[api.py]"]
end

subgraph group_resources["Resource queries"]
  node_game_api["Game queries<br/>[game.py]"]
  node_league_api["League queries<br/>[league.py]"]
  node_team_api["Team queries<br/>[team.py]"]
  node_user_api["User queries<br/>[user.py]"]
  node_terminal["Query terminal<br/>[terminal.py]"]
end

subgraph group_models["Response models"]
  node_game_model["Game models<br/>[game.py]"]
  node_league_model["League models<br/>[league.py]"]
  node_team_player["Team and player models<br/>[common.py]"]
  node_user_model["User model<br/>[user.py]"]
  node_transactions["Transaction models<br/>[transaction.py]"]
  node_model_helpers["Model conversions<br/>[helpers.py]"]
end

subgraph group_auth["Authentication"]
  node_auth_service["Authentication service<br/>[auth.py]"]
  node_token_cache[("Token cache<br/>[auth.py]")]
end

node_user(("API user"))
node_yahoo{{"Yahoo Fantasy API"}}

node_user -->|"configures"| node_client
node_client -->|"creates"| node_auth_service
node_auth_service -->|"loads and saves"| node_token_cache
node_auth_service -->|"requests tokens"| node_yahoo
node_client -->|"builds"| node_game_api
node_client -->|"builds"| node_league_api
node_client -->|"builds"| node_team_api
node_client -->|"builds"| node_user_api
node_game_api -.->|"creates"| node_terminal
node_league_api -->|"creates"| node_terminal
node_team_api -->|"creates"| node_terminal
node_user_api -.->|"creates"| node_terminal
node_terminal -->|"invokes query"| node_client
node_league_api -->|"requests league"| node_client
node_team_api -->|"requests team"| node_client
node_client -->|"sends requests"| node_yahoo
node_league_api -->|"parses response"| node_league_model
node_team_api -->|"parses response"| node_team_player
node_game_api -.->|"parses response"| node_game_model
node_user_api -.->|"parses response"| node_user_model
node_league_model -->|"uses player and team"| node_team_player
node_league_model -->|"uses transaction types"| node_transactions
node_team_player -->|"converts attributes"| node_model_helpers
node_league_model -->|"converts attributes"| node_model_helpers
node_transactions -->|"creates player models"| node_team_player

click node_client "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/api.py"
click node_auth_service "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/auth.py"
click node_token_cache "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/auth.py"
click node_game_api "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/game.py"
click node_league_api "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/league.py"
click node_team_api "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/team.py"
click node_user_api "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/user.py"
click node_terminal "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/terminal.py"
click node_game_model "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/game.py"
click node_league_model "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/league.py"
click node_team_player "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/common.py"
click node_user_model "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/user.py"
click node_transactions "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/transaction.py"
click node_model_helpers "https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/helpers.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_user toneBlue
class node_game_api,node_league_api,node_team_api,node_user_api,node_terminal toneAmber
class node_game_model,node_league_model,node_team_player,node_user_model,node_transactions,node_model_helpers,node_yahoo toneMint
class node_auth_service,node_token_cache toneRose
```

## Components

### Client orchestration

- [YahooFantasyApi](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/api.py): `yfantasy_api/api/api.py`

### Resource queries

- [Game queries](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/game.py): `yfantasy_api/api/game.py`
- [League queries](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/league.py): `yfantasy_api/api/league.py`
- [Team queries](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/team.py): `yfantasy_api/api/team.py`
- [User queries](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/user.py): `yfantasy_api/api/user.py`
- [Query terminal](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/terminal.py): `yfantasy_api/api/terminal.py`

### Response models

- [Game models](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/game.py): `yfantasy_api/models/game.py`
- [League models](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/league.py): `yfantasy_api/models/league.py`
- [Team and player models](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/common.py): `yfantasy_api/models/common.py`
- [User model](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/user.py): `yfantasy_api/models/user.py`
- [Transaction models](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/transaction.py): `yfantasy_api/models/transaction.py`
- [Model conversions](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/models/helpers.py): `yfantasy_api/models/helpers.py`

### Authentication

- [Authentication service](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/auth.py): `yfantasy_api/api/auth.py`
- [Token cache](https://github.com/hkyplyr/yfantasy-api/blob/main/yfantasy_api/api/auth.py): `yfantasy_api/api/auth.py`

### Other components

- **API user**
- **Yahoo Fantasy API**

## Connections

- API user → YahooFantasyApi: configures (evidence: `README.md`)
- YahooFantasyApi → Authentication service: creates (evidence: `yfantasy_api/api/api.py`)
- Authentication service → Token cache: loads and saves (evidence: `yfantasy_api/api/auth.py`)
- Authentication service → Yahoo Fantasy API: requests tokens (evidence: `yfantasy_api/api/auth.py`)
- YahooFantasyApi → Game queries: builds (evidence: `yfantasy_api/api/api.py`)
- YahooFantasyApi → League queries: builds (evidence: `yfantasy_api/api/api.py`)
- YahooFantasyApi → Team queries: builds (evidence: `yfantasy_api/api/api.py`)
- YahooFantasyApi → User queries: builds (evidence: `yfantasy_api/api/api.py`)
- Game queries → Query terminal: creates (evidence: `yfantasy_api/api/game.py`)
- League queries → Query terminal: creates (evidence: `yfantasy_api/api/league.py`)
- Team queries → Query terminal: creates (evidence: `yfantasy_api/api/team.py`)
- User queries → Query terminal: creates (evidence: `yfantasy_api/api/user.py`)
- Query terminal → YahooFantasyApi: invokes query (evidence: `yfantasy_api/api/terminal.py`)
- League queries → YahooFantasyApi: requests league (evidence: `yfantasy_api/api/league.py`)
- Team queries → YahooFantasyApi: requests team (evidence: `yfantasy_api/api/team.py`)
- YahooFantasyApi → Yahoo Fantasy API: sends requests (evidence: `yfantasy_api/api/api.py`)
- League queries → League models: parses response (evidence: `yfantasy_api/api/league.py`)
- Team queries → Team and player models: parses response (evidence: `yfantasy_api/api/team.py`)
- Game queries → Game models: parses response
- User queries → User model: parses response
- League models → Team and player models: uses player and team (evidence: `yfantasy_api/models/league.py`)
- League models → Transaction models: uses transaction types (evidence: `yfantasy_api/models/league.py`)
- Team and player models → Model conversions: converts attributes (evidence: `yfantasy_api/models/common.py`)
- League models → Model conversions: converts attributes (evidence: `yfantasy_api/models/league.py`)
- Transaction models → Team and player models: creates player models (evidence: `yfantasy_api/models/transaction.py`)
