Data Sync Guide
Data Sync Guide
Learn how to sync data from sports data providers into Sports Stack.
Overview
Sports Stack integrates with multiple data providers (SportRadar, FTN, API Sports, etc.) to fetch and normalize sports data. This guide covers how to configure and trigger data synchronization.
How Data Sync Works
flowchart LR
A[CMS Sync Request] --> B[Oban Job Queue]
B --> C[Provider API Call]
C --> D[Feed File Created]
D --> E[RabbitMQ Message]
E --> F[Conversion Pipeline]
F --> G[Database Storage]
Sync Flow
- Trigger: User clicks "Sync now" in CMS or automated cron job
- Job Creation: Oban job created for each route/league combination
- API Call: Provider makes HTTP request to external API
- Feed File: Raw response saved as FeedFileEntity
- Message Queue: Message published to RabbitMQ
- Conversion: Data converted to Common Model format
- Storage: Entities saved to database
Setting Up Data Providers
Step 1: Configure Provider
- Navigate to Integrations → Data Providers in CMS
- Select a provider (e.g., SportRadar, FTN)
- Click "Configure"
- Enter API credentials:
- API Key
- Base URL (if different from default)
- Additional configuration options
Step 2: Enable Provider
- Toggle "Active" switch to enable provider
- Select leagues you want to sync
- Configure fetch settings (which entities to sync)
- Save configuration
Step 3: Test Sync
- Navigate to Sync Data tab
- Select a route (e.g., "Teams", "Events")
- Choose a league (e.g., NFL, NBA)
- Click "Sync now"
- Monitor progress in Recent API Calls
Sync Methods
Manual Sync (CMS UI)
Use Case: One-time syncs, testing, troubleshooting
Steps:
- Go to Integrations → Data Providers → [Provider]
- Click Sync Data tab
- Select route and league
- Click "Sync now" button
- Wait for completion (check Recent API Calls)
Example URLs:
http://localhost:4001/integrations/data_providers/sportradar?tab=Sync+Data&league=nfl
http://localhost:4001/integrations/data_providers/sportradar?tab=Sync+Data&league=nba
Quick Sync (Entity Pages)
Use Case: Sync data for specific entities (teams, players, events)
Steps:
- Navigate to entity detail page (e.g., Team, Event)
- Find Quick Actions section
- Select provider and action (e.g., "Sync Team Players")
- Click sync button
- Monitor in Recent API Calls
Available Actions:
- Teams: Sync players, sync events
- Events: Sync statistics, sync player stats
- Players: Sync team roster
Automated Sync (Cron Jobs)
Use Case: Regular scheduled syncs
Configuration:
- Set up cron schedule in provider configuration
- Configure fetch settings (which entities/leagues)
- Provider automatically syncs on schedule
Example:
{
"cron": "0 */6 * * *", // Every 6 hours
"fetch": {
"nfl": {
"core": ["events", "teams"],
"stats": ["event_scoped_stats"]
}
}
}Sync Routes
Common Routes
| Route | Description | Entities Created |
|---|---|---|
| Teams | Fetch team rosters | team |
| Players | Fetch player information | player |
| Events | Fetch game schedules | event |
| Seasons | Fetch season information | season |
| League Hierarchy | Fetch league structure | team, league, divisions |
| Statistics | Fetch game statistics | event_scoped_stats |
| Player Statistics | Fetch player stats | season_scoped_stats |
Route Categories
Routes are organized by category in the CMS:
- Baseline Reference: Core entities (teams, players, leagues)
- Data: General data sync routes
- Advanced Stats: Statistical data and projections
- Custom: Provider-specific routes
Sync Configuration
Fetch Settings
Configure which entities to sync:
{
"fetch": {
"nfl": {
"core": ["teams", "players", "events"],
"stats": ["event_scoped_stats", "season_scoped_stats"]
},
"nba": {
"core": ["teams", "players"]
}
}
}Route Parameters
Some routes require additional parameters:
Players Route:
team_id: Required - Team ID to fetch players for
Events Route:
season_year: Optional - Season year (defaults to current)week: Optional - Week number
Statistics Route:
event_id: Required - Event ID to fetch stats for
Monitoring Syncs
Recent API Calls
View sync status in Integrations → Recent API Calls:
- Status: Success (200) or error codes
- Timestamp: When sync occurred
- Trace ID: Link to detailed trace logs
- Response: Preview of response data
Trace Logs
Each sync creates a trace with:
- API request/response details
- Conversion processing logs
- Error messages (if any)
- Processing time
Access: Click trace ID in Recent API Calls
Common Sync Scenarios
Initial League Setup
-
Sync League Hierarchy:
- Creates league structure
- Creates teams with divisions/conferences
- Sets up team colors and metadata
-
Sync Seasons:
- Creates season records
- Links seasons to leagues
-
Sync Teams (if needed):
- Updates team rosters
- Creates/updates players
-
Sync Events:
- Creates game schedules
- Links events to seasons
Daily Updates
-
Sync Events (scheduled):
- Updates game schedules
- Updates event statuses
- Creates new events
-
Sync Statistics (after games):
- Fetches game statistics
- Updates player stats
- Updates team stats
Troubleshooting Syncs
-
Check Provider Status:
- Verify provider is active
- Check API credentials are valid
- Verify network connectivity
-
Review Trace Logs:
- Check for API errors
- Review conversion logs
- Identify processing issues
-
Validate Results:
- Check entities were created
- Verify data completeness
- Compare with provider data
Best Practices
1. Sync Order Matters
Sync in this order for best results:
- League Hierarchy → Creates league structure
- Seasons → Creates season records
- Teams → Creates/updates teams
- Players → Creates/updates players
- Events → Creates game schedules
- Statistics → Fetches game stats
2. Use Appropriate Routes
- Baseline Reference: Use for initial setup
- Data: Use for regular updates
- Advanced Stats: Use for statistical analysis
3. Monitor Sync Frequency
- Reference Data: Sync daily or weekly
- Event Data: Sync multiple times per day
- Live Data: Sync every 30-60 seconds during games
- Statistics: Sync after games complete
4. Handle Errors Gracefully
- Check Recent API Calls for failures
- Review trace logs for details
- Retry failed syncs manually
- Contact support for persistent issues
Troubleshooting
Sync Not Starting
-
Check Provider Configuration:
- Verify provider is active
- Check API credentials
- Verify league is selected
-
Check Oban Queue:
- Verify Oban is running
- Check queue for stuck jobs
- Review Oban dashboard
Sync Completing But No Data
-
Check Conversion Logs:
- Review trace logs
- Check for conversion errors
- Verify processor matching
-
Validate Data:
- Check entities in Explore
- Verify tenant filtering
- Check entity filters
Rate Limiting
-
Reduce Sync Frequency:
- Increase time between syncs
- Sync fewer entities at once
- Use cron scheduling
-
Contact Support:
- Request rate limit increase
- Optimize sync patterns
Related Documentation
- Testing Guide - How to test syncs
- API Reference - API endpoint documentation
- Webhooks Guide - Real-time notifications
Support
For sync issues:
- Check Recent API Calls for errors
- Review Trace Logs for details
- Check Provider Configuration status
- Contact support with trace IDs
Updated 29 days ago
