Skip to content

raghavx03/api-key

Repository files navigation

🔑 API Key Management Dashboard

A complete, production-ready API key management system with a beautiful dashboard. Create, manage, and validate API keys with enterprise-grade security.

Status Python Node License

✨ Features

  • Unlimited API Keys - Jitne chahiye utne keys create karo
  • NVIDIA Integration - NVIDIA API keys ko add aur validate karo
  • Fast Validation - Zero lag, instant response with caching
  • Secure Storage - AES-256 encryption ke saath
  • Usage Tracking - Dekho kab last use hua tha
  • Easy to Use - Simple aur clean UI
  • Local First - Apne machine pe run karo

🚀 Quick Start

1. Backend Setup

cd backend

# Install dependencies
pip install -r requirements.txt

# Generate encryption key
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

# Create .env file
cat > .env << EOF
DATABASE_URL=sqlite:///./api_keys.db
ENCRYPTION_KEY=<your-generated-key>
NVIDIA_API_KEY=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
EOF

# Run backend
python main.py

Backend ab chal raha hai: http://localhost:8000

2. Frontend Setup

cd frontend

# Install dependencies
npm install

# Run frontend
npm run dev

Frontend ab chal raha hai: http://localhost:3000

📖 Usage

1. Register/Login

  • Browser mein http://localhost:3000 kholo
  • Naya account banao ya login karo

2. Create API Key

  • "Create New Key" button pe click karo
  • Label do (optional)
  • Provider select karo (Internal ya NVIDIA)
  • Key create hone ke baad copy kar lo - ye sirf ek baar dikhega!

3. Use API Key Anywhere

Apne application mein API key validate karne ke liye:

Option 1: Header mein

curl -X POST http://localhost:8000/api/validate \
  -H "X-API-Key: akm_your_key_here"

Option 2: Query parameter

curl "http://localhost:8000/api/validate?api_key=akm_your_key_here"

Option 3: Request body

curl -X POST http://localhost:8000/api/validate \
  -H "Content-Type: application/json" \
  -d '{"apiKey": "akm_your_key_here"}'

4. NVIDIA Key Validation

NVIDIA keys automatically NVIDIA API ke against validate hote hain aur 5 minutes ke liye cache hote hain for fast response!

🎯 API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login
  • POST /api/auth/logout - Logout

Key Management

  • GET /api/keys - List all keys
  • POST /api/keys - Create new key
  • PATCH /api/keys/{keyId} - Update key (label, status)
  • DELETE /api/keys/{keyId} - Delete key

Validation

  • POST /api/validate - Validate API key (supports header, query, body)

🔒 Security Features

  • AES-256 Encryption - Keys encrypted at rest
  • SHA-256 Hashing - Fast lookup without decryption
  • Rate Limiting - 5 failed login attempts = 15 min block
  • Session Management - 24 hour sessions
  • CORS Protection - Only allowed origins

⚡ Performance

  • Validation Speed: < 10ms for internal keys
  • NVIDIA Validation: < 50ms (with 5-min cache)
  • Database: SQLite for local, PostgreSQL ready for production
  • Caching: LRU cache for NVIDIA validations

🛠️ Tech Stack

Backend:

  • FastAPI (Python)
  • SQLAlchemy (ORM)
  • Cryptography (Encryption)
  • bcrypt (Password hashing)

Frontend:

  • React + TypeScript
  • Vite (Build tool)
  • date-fns (Date formatting)
  • Lucide React (Icons)

📝 Environment Variables

DATABASE_URL=sqlite:///./api_keys.db
ENCRYPTION_KEY=<your-encryption-key>
NVIDIA_API_KEY=<your-nvidia-key>

🎨 Features in Dashboard

  • ✅ View all keys with status
  • ✅ Create unlimited keys
  • ✅ Toggle active/inactive status
  • ✅ Delete keys with confirmation
  • ✅ Filter by provider (Internal/NVIDIA)
  • ✅ See last used timestamp
  • ✅ Copy key to clipboard
  • ✅ NVIDIA badge for NVIDIA keys
  • ✅ Real-time updates

🚀 Production Deployment

For production:

  1. Use PostgreSQL instead of SQLite
  2. Use Redis for session storage
  3. Enable HTTPS
  4. Use proper KMS for encryption keys
  5. Set up monitoring and logging

💡 Tips

  • NVIDIA Keys: Automatically validated against NVIDIA API
  • Caching: NVIDIA validations cached for 5 minutes
  • Fast Response: Internal keys validate in < 10ms
  • Unlimited Keys: No limit on key creation
  • Secure: Keys encrypted, never exposed after creation

🐛 Troubleshooting

Backend not starting?

  • Check if port 8000 is free
  • Verify all dependencies installed
  • Check .env file exists

Frontend not connecting?

  • Check if backend is running on port 8000
  • Clear browser cache
  • Check console for errors

NVIDIA validation failing?

  • Verify NVIDIA_API_KEY in .env
  • Check internet connection
  • NVIDIA API might be rate limiting

📄 License

MIT License - Use freely!


Made with ❤️ for easy API key management

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors