A modern, scalable API for comparing air travel ticket prices across multiple currencies using the Amadeus API. This project provides both a REST API and a beautiful web interface for flight price comparison.
-
Flight Price Comparison
- Search flights between airports
- Compare prices across multiple currencies (USD, EUR, GBP, CAD, AUD)
- Find the lowest cost currency for tickets
- Real-time price data from Amadeus API
-
AI-Powered Travel Assistant with Grok π€
- Natural language flight search ("Find cheap flights to Paris next month")
- Grok AI travel recommendations and insights
- Smart destination suggestions
- Personalized travel advice
- Price trend analysis and booking recommendations
- Completely free AI assistance!
-
Modern API
- FastAPI-based REST API
- Async processing
- Automatic API documentation (Swagger/ReDoc)
- CORS support
- AI and currency conversion integration
-
Beautiful Web Interface
- Simple and intuitive UI with AI chat features
- Real-time search results with AI insights
- Responsive design with modern animations
- Search history and quick access
-
Docker Support
- Containerized application
- Easy deployment
- Environment variable management
- Python 3.12+
- Docker and Docker Compose (for containerized deployment)
- Amadeus API key and secret (free developer account)
- Grok API key (for AI features, optional - completely free!)
-
Sign up for Amadeus Developer Account:
- Go to https://developers.amadeus.com/
- Click "Register" and create your account
- Verify your email
-
Create an Application:
- Go to "My Apps" in your dashboard
- Click "Create a new app"
- Fill in the details (any name/description)
- Select "Flight Offers Search" API
-
Get Your API Keys:
- Your API Key and API Secret will be displayed
- Copy them to your
.envfile
Note: Amadeus provides 2000 free API calls per month for developers.
Note: AI features are optional. The flight search works without them, but you'll get enhanced experiences with Grok.
-
Go to xAI Console:
- Visit https://console.x.ai/
- Sign up or log in to your account
-
Create API Key:
- Generate a new API key from your dashboard
- Copy the key (save it securely)
-
Update .env file:
GROK_API_KEY=your-grok-api-key-here- Test the key:
python test-api-keys.pyCost: Grok is completely FREE with no usage limits or hidden costs! π
- OpenAI API key (for AI features at https://platform.openai.com/)
-
Connect to Netlify:
- Push your code to GitHub
- Connect your repository to Netlify
- Netlify will automatically detect the
netlify.tomlconfiguration
-
Environment Variables: Set these in your Netlify dashboard:
AMADEUS_API_KEY=your_amadeus_key AMADEUS_API_SECRET=your_amadeus_secret OPENAI_API_KEY=your_openai_key -
Deploy:
- Netlify will build and deploy automatically
- Your site will be available at the generated URL
- Clone the repository:
git clone <repository-url>
cd air-travel-price-comparison- Create a
.envfile:
cp .env.example .env
# Edit .env with your Amadeus API key and secret- Test your API keys (recommended):
python test-api-keys.py- Start the application:
docker-compose up -dThe API will be available at http://localhost:8000
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Test your API keys (recommended):
python test-api-keys.py- Start the API server:
python -m app.mainGET /api/flights/search- Search for flights and compare prices across currencies
- Query parameters: origin, destination, departure_date
- Returns price comparison results with lowest cost currency
Access the web interface at http://localhost:8000 to:
- AI-Powered Search: Describe your trip in plain English (e.g., "Find cheap flights from New York to London next month")
- Traditional Search: Enter origin and destination airport codes with detailed options
- Smart Comparisons: View price comparisons across currencies with AI insights
- Personalized Recommendations: Get AI-powered travel advice and destination insights
- Search History: Quick access to your recent searches
air-travel-price-comparison/
βββ app/
β βββ api/
β β βββ flight_routes.py # API endpoints for flight search
β βββ core/
β β βββ config.py # Configuration
β βββ services/
β β βββ flight_service.py # Flight search and price comparison logic
β βββ static/
β β βββ index.html # Web interface
β βββ main.py # FastAPI application
βββ tests/
β βββ api/
β β βββ test_flight_routes.py # API tests
β βββ services/
β βββ test_flight_service.py # Service tests
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose configuration
βββ requirements.txt # Python dependencies
βββ README.md # This file
Run the test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=app tests/The application can be configured using environment variables:
| Variable | Description | Default |
|---|---|---|
| API_HOST | API server host | 0.0.0.0 |
| API_PORT | API server port | 8000 |
| AMADEUS_API_KEY | Amadeus API key | - |
| AMADEUS_API_SECRET | Amadeus API secret | - |
| OPENAI_API_KEY | OpenAI API key (for AI features) | - |
Once the server is running, access the API documentation:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
The project includes full Netlify configuration for easy deployment:
Files included:
netlify.toml- Build configurationnetlify/functions/api.py- Serverless API functionsnetlify/requirements.txt- Python dependencies for functionsapp/static/_redirects- SPA routing
Deployment Steps:
- Push code to GitHub
- Connect repository to Netlify
- Set environment variables in Netlify dashboard
- Deploy automatically
Limitations: Full flight search requires backend server. Use Docker for complete functionality.
Use Docker for complete server-side functionality with real-time API integrations.
"Connection Error - Unable to connect to the flight search service"
This error occurs when Amadeus API keys are not properly configured:
- Check your
.envfile:
python test-api-keys.py-
Get real Amadeus API keys:
- Visit https://developers.amadeus.com/
- Create a free developer account
- Generate API Key and Secret
- Update your
.envfile
-
Restart the service:
# Stop the current service (Ctrl+C)
python -m app.main"AI Search Failed - Unable to process your natural language query"
This occurs when Grok API access is limited:
Possible causes:
- No API key configured - Add Grok key to
.env - Invalid API key - Verify the key is correct
- Network issues - Check internet connection
Solutions:
- For missing/invalid API key:
# Get free key from: https://console.x.ai/
# Add to .env: GROK_API_KEY=your-grok-key-here
python test-api-keys.py- Restart service:
python -m app.mainNote: AI features are optional. The regular flight search form works without Grok. Plus, Grok is completely free!
"AI features not available"
This is normal if OpenAI API key is not configured. The service will work without AI features.
- "Module not found": Run
pip install -r requirements.txt - "Port already in use": Change port in
app/core/config.py - "Permission denied": Check file permissions for
.env
For support, please open an issue in the GitHub repository or contact the maintainers.