How joaovictortb/espn-tennis-api works
ESPN Tennis API is a Fastify service that exposes a stable, normalized and cached API over undocumented ESPN tennis feeds. The main workflow is client request → /v1 validation and dispatch → tennis service orchestration → ESPN fetch → normalization → enveloped response; player, tournament, news and rankings capabilities share this flow. App setup also enriches responses with resolved player photos. The excerpts establish the central calls and module dependencies; links for unsampled route branches rely on README documentation, and photo-provider details are not shown.
Main entry points: tennis.ts Tennis Services · app.ts Fastify App · v1.ts V1 Routes · matches.ts Match Normalizer
Components 19
HTTP API
- Fastify App
src/app.ts - V1 Routes
src/routes/v1.ts - Response Contract
src/domain/types.ts
Domain Services
- Tennis Services
src/services/tennis.ts - Photo Resolver
src/services/photos.ts
Normalization
- Match Normalizer
src/normalize/matches.ts - Player Normalizer
src/normalize/players.ts - News Normalizer
src/normalize/news.ts - Rankings Normalizer
src/normalize/rankings.ts - Normalize Helpers
src/normalize/common.ts
ESPN Access
- ESPN Feeds
src/espn/client.ts
Shared Runtime
- HTTP Transport
src/lib/http.ts - TTL Cache
src/lib/cache.ts - Date Utilities
src/lib/dates.ts - Error Mapping
src/lib/errors.ts - Runtime Config
src/config.ts
Other components
- API Client
- ESPN
- Photo Providers
Connections 26
- API Client → Fastify App: requests
README.md - Fastify App → V1 Routes: registers
src/app.ts - V1 Routes → Tennis Services: dispatches
src/routes/v1.ts - V1 Routes → Match Normalizer: normalizes summaries
src/routes/v1.ts - Tennis Services → ESPN Feeds: fetches data
src/services/tennis.ts - Tennis Services → TTL Cache: caches results
README.md - Tennis Services → Match Normalizer: normalizes scores
src/services/tennis.ts - Tennis Services → Player Normalizer: normalizes profiles
src/services/tennis.ts - Tennis Services → News Normalizer: normalizes articles
src/services/tennis.ts - Tennis Services → Rankings Normalizer: normalizes rankings
src/services/tennis.ts - ESPN Feeds → HTTP Transport: fetches JSON
src/espn/client.ts - ESPN Feeds → ESPN: requests feeds
src/espn/client.ts - Match Normalizer → Normalize Helpers: uses helpers
src/normalize/matches.ts - Player Normalizer → Normalize Helpers: uses helpers
src/normalize/players.ts - News Normalizer → Normalize Helpers: uses helpers
src/normalize/news.ts - Rankings Normalizer → Normalize Helpers: uses helpers
src/normalize/rankings.ts - Match Normalizer → Date Utilities: converts dates
src/normalize/matches.ts - Player Normalizer → Date Utilities: converts dates
src/normalize/players.ts - News Normalizer → Date Utilities: converts dates
src/normalize/news.ts - Fastify App → Photo Resolver: enriches responses
src/app.ts - Photo Resolver → Photo Providers: resolves photos
- Fastify App → Runtime Config: configures server
src/app.ts - Fastify App → Error Mapping: formats errors
src/app.ts - Tennis Services → Runtime Config: uses settings
src/services/tennis.ts - V1 Routes → Response Contract: serves typed data
src/routes/v1.ts - Tennis Services → Response Contract: returns domain data
src/services/tennis.ts