PHPackages                             michaeldrennen/schwab-api-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. michaeldrennen/schwab-api-php

ActiveLibrary[API Development](/categories/api)

michaeldrennen/schwab-api-php
=============================

A PHP library to connect to the Charles Schwab API.

v0.17(3mo ago)11572MITPHPPHP ^8.2

Since Nov 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/michaeldrennen/schwab-api-php)[ Packagist](https://packagist.org/packages/michaeldrennen/schwab-api-php)[ RSS](/packages/michaeldrennen-schwab-api-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (18)Used By (0)

Schwab API PHP Client
=====================

[](#schwab-api-php-client)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/b5d4f7901c58ad1ddfff679966f426cc25a9354bab763846b9a7276c2feab4e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d626c7565)](https://www.php.net/)

A comprehensive PHP library for interacting with the Charles Schwab Trader API. This library provides a clean, object-oriented interface to access account information, manage orders, retrieve transactions, and more.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
- [Authentication Flow](#authentication-flow)
- [API Reference](#api-reference)
    - [Account Operations](#account-operations)
    - [Order Management](#order-management)
    - [Transaction History](#transaction-history)
    - [Market Data](#market-data)
    - [User Preferences](#user-preferences)
- [Error Handling](#error-handling)
- [Security](#security)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- ✅ **Complete API Coverage** - All Schwab Trader API endpoints implemented
- ✅ **Type-Safe** - Full PHP 8.2+ type declarations
- ✅ **Modern PHP** - Uses traits, strict types, and best practices
- ✅ **OAuth 2.0** - Built-in authentication and token management
- ✅ **Comprehensive Error Handling** - Detailed exceptions with context
- ✅ **Well Documented** - Extensive PHPDoc comments throughout
- ✅ **Secure** - Credential masking and secure defaults
- ✅ **Tested** - PHPUnit test suite included

### Supported Operations

[](#supported-operations)

- **Accounts**: Get account numbers, balances, positions
- **Orders**: Place, modify, cancel, preview orders
- **Transactions**: Retrieve transaction history
- **Market Data**: Quotes, price history, option chains, market hours
- **Trading**: Equity and options trading support
- **User Preferences**: Access user settings

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Composer
- A Schwab Developer account with API credentials

Installation
------------

[](#installation)

Install via Composer:

```
composer require michaeldrennen/schwab-api-php
```

Configuration
-------------

[](#configuration)

### 1. Get API Credentials

[](#1-get-api-credentials)

1. Visit [Schwab Developer Portal](https://developer.schwab.com/)
2. Create an application and note your:
    - **API Key** (Client ID)
    - **API Secret** (Client Secret)
    - **Callback URL** (Redirect URI)

### 2. Environment Setup

[](#2-environment-setup)

Copy the example environment file:

```
cp .env.example .env
```

Edit `.env` or `phpunit.xml` with your credentials:

```
SCHWAB_API_KEY=your_api_key_here
SCHWAB_API_SECRET=your_api_secret_here
SCHWAB_CALLBACK_URI=https://your-domain.com/callback
```

Quick Start
-----------

[](#quick-start)

```
