# Zerodha API Connection Test Commands

## Prerequisites
1. Replace `YOUR_API_KEY` with your actual API key
2. Replace `YOUR_ACCESS_TOKEN` with your current access token

## 1. Test User Profile
```bash
curl -H "X-Kite-Version: 3" \
     -H "Authorization: token YOUR_API_KEY:YOUR_ACCESS_TOKEN" \
     https://api.kite.trade/user/profile
```

## 2. Test Account Margins
```bash
curl -H "X-Kite-Version: 3" \
     -H "Authorization: token YOUR_API_KEY:YOUR_ACCESS_TOKEN" \
     https://api.kite.trade/user/margins
```

## 3. Test Live Price (LTP)
```bash
curl -H "X-Kite-Version: 3" \
     -H "Authorization: token YOUR_API_KEY:YOUR_ACCESS_TOKEN" \
     "https://api.kite.trade/quote/ltp?i=NSE:RELIANCE"
```

## 4. Test Portfolio Holdings
```bash
curl -H "X-Kite-Version: 3" \
     -H "Authorization: token YOUR_API_KEY:YOUR_ACCESS_TOKEN" \
     https://api.kite.trade/portfolio/holdings
```

## 5. Test Order Book
```bash
curl -H "X-Kite-Version: 3" \
     -H "Authorization: token YOUR_API_KEY:YOUR_ACCESS_TOKEN" \
     https://api.kite.trade/orders
```

## Expected Responses

### Success Response (Profile):
```json
{
  "status": "success",
  "data": {
    "user_id": "XX1234",
    "user_name": "Your Name",
    "email": "your@email.com",
    "broker": "ZERODHA"
  }
}
```

### Error Response (Invalid Token):
```json
{
  "status": "error",
  "message": "Invalid API credentials",
  "error_type": "TokenException"
}
```

## PowerShell Commands (Windows)
If you prefer PowerShell:

```powershell
# Test User Profile
$headers = @{
    'X-Kite-Version' = '3'
    'Authorization' = 'token YOUR_API_KEY:YOUR_ACCESS_TOKEN'
}
Invoke-RestMethod -Uri 'https://api.kite.trade/user/profile' -Headers $headers
```

## Quick Check Commands

### 1. Check if API key is valid (will return login URL):
```bash
curl "https://kite.zerodha.com/connect/login?v=3&api_key=YOUR_API_KEY"
```

### 2. Health check (should return Zerodha's status):
```bash
curl https://api.kite.trade/
```