# Flight API Setup Instructions
## Using Real Flight Data
The flight status tool currently uses mock data for demonstration purposes. To get real flight data, follow these steps:
### 1. Get an API Key
1. Visit [AviationStack](https://aviationstack.com)
2. Sign up for a free account
3. Copy your API access key from the dashboard
### 2. Set Environment Variable
```bash
# Option 1: Set for current session
export AVIATIONSTACK_API_KEY=your_actual_api_key_here
# Option 2: Add to your shell profile (~/.zshrc, ~/.bashrc)
echo 'export AVIATIONSTACK_API_KEY=your_actual_api_key_here' >> ~/.zshrc
source ~/.zshrc
# Option 3: Create a .env file (not recommended for production)
echo 'AVIATIONSTACK_API_KEY=your_actual_api_key_here' > .env
```
### 3. Rebuild and Test
```bash
# Rebuild the server
npm run build
# Test with real API
node test-flight-status.js
```
### 4. API Usage Examples
```bash
# Example 1: Flight number only
# This will search for any flight with that number
{
"name": "get_flight_status",
"arguments": {
"flightNumber": "1234"
}
}
# Example 2: Flight with airline code
# This creates a specific flight identifier like "AA1234"
{
"name": "get_flight_status",
"arguments": {
"flightNumber": "1234",
"airlineIata": "AA"
}
}
```
### 5. Free Tier Limitations
AviationStack free tier includes:
- 1,000 API requests per month
- Real-time flight data
- Historical flight data (limited)
- Airport and airline information
### 6. Alternative APIs
If you prefer other flight APIs, you can modify `src/tools/flight-status.ts`:
- **FlightAware AeroAPI**: More comprehensive but requires paid plan
- **Aviation Edge**: Another free option with similar features
- **RapidAPI Flight APIs**: Various flight data providers
### 7. Error Handling
The tool includes comprehensive error handling for:
- Invalid API keys
- API rate limits
- Network timeouts
- Invalid flight numbers
- No flight data found
### 8. Troubleshooting
If you encounter issues:
1. **Check your API key**: Verify it's correctly set in the environment
2. **Check rate limits**: Free tier has monthly request limits
3. **Verify flight numbers**: Use real, recent flight numbers for testing
4. **Check network**: Ensure your internet connection is working
### 9. Mock vs Real Data
- **Mock Data**: Used when `AVIATIONSTACK_API_KEY` is not set or equals `"demo_key"`
- **Real Data**: Used when a valid API key is provided
- **Fallback**: If API fails, the tool will show an error message
The mock data is useful for:
- Development and testing
- Demonstrations
- When you don't need real flight data
- Avoiding API rate limits during development