# n8n-nodes-schwab

This is an n8n community node for the Charles Schwab Trader API. It allows you to integrate Schwab trading functionality into your n8n workflows.

[![npm version](https://img.shields.io/npm/v/n8n-nodes-schwab.svg)](https://www.npmjs.com/package/n8n-nodes-schwab)
[![npm downloads](https://img.shields.io/npm/dm/n8n-nodes-schwab.svg)](https://www.npmjs.com/package/n8n-nodes-schwab)

## Features

- ✅ **OAuth2 Authentication**: Automatic token management via n8n's built-in OAuth2 support
- 📊 **Account Management**: Get account information, balances, and positions
- 📈 **Order Management**: Place, cancel, and replace orders
- 💰 **Transactions**: Retrieve transaction history
- ⚙️ **User Preferences**: Access user preference settings

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

### Via npm:
```bash
npm install n8n-nodes-schwab
```

### Via n8n UI:
1. Go to **Settings** → **Community Nodes**
2. Click **Install**
3. Enter `n8n-nodes-schwab`
4. Click **Install**
5. Restart n8n

## Credentials Setup

This node uses **OAuth2** authentication with automatic token refresh.

### Quick Setup:

1. **Register your app** at [Schwab Developer Portal](https://developer.schwab.com/)
   - Get your Client ID and Client Secret
   - Set redirect URI to your n8n OAuth callback URL

2. **In n8n**:
   - Go to **Credentials** → **Create New**
   - Select "Schwab OAuth2 API"
   - Enter Client ID and Client Secret
   - Click **"Connect"** button
   - Authorize with Schwab
   - Done! ✨

**📖 Detailed setup guide**: See [OAUTH_SETUP.md](./OAUTH_SETUP.md) for complete instructions

### What's New in v0.2.0

- ✅ **Native n8n OAuth2**: No more manual authorization codes!
- ✅ **Automatic token refresh**: Tokens refresh automatically
- ✅ **Easier setup**: Just click "Connect" and authorize
- ✅ **Better error handling**: Clear OAuth error messages

## Operations

### Accounts
- Get Account Numbers
- Get All Accounts
- Get Specific Account

### Orders
- Get Orders (by account or all accounts)
- Place Order
- Cancel Order
- Replace Order
- Get Order by ID
- Preview Order (Coming Soon)

### Transactions
- Get Transactions
- Get Transaction by ID

### User Preferences
- Get User Preference

## Compatibility

Tested with n8n version 1.0+

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
- [Schwab Developer Portal](https://developer.schwab.com/)

## License

MIT
