Files
namecheap-api/prices.py
kaffa 896699535d Initial commit: Namecheap API library with REST/MCP servers
Features:
- Domain management (check, register, renew, contacts)
- DNS management (nameservers, records)
- Glue records (child nameserver) support
- TLD price tracking with KRW conversion
- FastAPI REST server with OpenAI schema
- MCP server for Claude integration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 10:21:46 +09:00

44 lines
985 B
Python
Executable File

#!/usr/bin/env python3
"""
CLI to query TLD prices from database
"""
import sys
from db import get_prices, get_exchange_rate, init_db
def show_prices(filter_tld: str = None, limit: int = 30):
"""Display TLD prices"""
init_db()
prices = get_prices()
rate = get_exchange_rate()
if not prices:
print("No prices in database. Run update_prices.py first.")
return
if filter_tld:
prices = [p for p in prices if filter_tld.lower() in p["tld"].lower()]
print(f"Exchange rate: $1 = ₩{rate:,.0f}")
print(f"{'TLD':12} {'USD':>8} {'KRW':>10}")
print("-" * 32)
for p in prices[:limit]:
print(f".{p['tld']:11} ${p['usd']:7.2f} {p['krw']:>9,}")
if len(prices) > limit:
print(f"\n... and {len(prices) - limit} more")
def main():
if len(sys.argv) > 1:
filter_tld = sys.argv[1]
show_prices(filter_tld, limit=100)
else:
show_prices()
if __name__ == "__main__":
main()