PHPackages                             michaeldrennen/td-ameritrade-api - 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/td-ameritrade-api

ActiveLibrary[API Development](/categories/api)

michaeldrennen/td-ameritrade-api
================================

A PHP library used to interact with the TD Ameritrade API.

v0.2.3(2y ago)54781[2 issues](https://github.com/michaeldrennen/td-ameritrade-api/issues)[1 PRs](https://github.com/michaeldrennen/td-ameritrade-api/pulls)MITPHPPHP ^8.1

Since Mar 29Pushed 1y ago2 watchersCompare

[ Source](https://github.com/michaeldrennen/td-ameritrade-api)[ Packagist](https://packagist.org/packages/michaeldrennen/td-ameritrade-api)[ RSS](/packages/michaeldrennen-td-ameritrade-api/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (8)Versions (22)Used By (0)

td-ameritrade-api
=================

[](#td-ameritrade-api)

[![Packagist](https://camo.githubusercontent.com/24e3d5ed0f3e143ce76e93e4bc3b2c68fd63b39b87e5ece0feba48c1ac506399/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69636861656c6472656e6e656e2f74642d616d65726974726164652d617069)](https://camo.githubusercontent.com/24e3d5ed0f3e143ce76e93e4bc3b2c68fd63b39b87e5ece0feba48c1ac506399/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69636861656c6472656e6e656e2f74642d616d65726974726164652d617069) [![GitHub issues](https://camo.githubusercontent.com/0b1264b62f7c80920daffae102f7069b7532ac9703da789c539b0a7a6116b3c4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d69636861656c6472656e6e656e2f74642d616d65726974726164652d617069)](https://github.com/michaeldrennen/td-ameritrade-api/issues) [![GitHub stars](https://camo.githubusercontent.com/e8b56e0e165488cea3873ec9a082090ef8540a3b3a600a169d3b8b67f86ef9ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6d69636861656c6472656e6e656e2f74642d616d65726974726164652d617069)](https://github.com/michaeldrennen/td-ameritrade-api/stargazers) [![GitHub forks](https://camo.githubusercontent.com/bfb4adad8db57d48fa081a317665dd0d25257c0ffe07bf1fa67521f3ab1edef6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6d69636861656c6472656e6e656e2f74642d616d65726974726164652d617069)](https://github.com/michaeldrennen/td-ameritrade-api/network) [![GitHub license](https://camo.githubusercontent.com/edf42dd2eff384f7287f1661290869dfe9b8b9a3375a736a716a9a2d691fc233/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d69636861656c6472656e6e656e2f74642d616d65726974726164652d617069)](https://github.com/michaeldrennen/td-ameritrade-api/blob/master/LICENSE)

A PHP library used to interact with the TD Ameritrade API

Visit the link below to set up your developer account with TD Ameritrade, and get information on how to authenticate with their API.

```
// How to create a TDAmeritrade API client.
$userName                     = 'joeuser123';
$accessToken                  = 'stringFromTDAmeritradeAuthentication';
$refreshToken                 = 'anotherStringFromTDAmeritradeAuthentication';
$refreshTokenExpiresInSeconds = intFromTDAmeritradeAuthentication;
$debug                        = false;
$tdaClient = TDAmeritradeAPI( $userName,
                              $accessToken,
                              $refreshToken,
                              $refreshTokenExpiresInSeconds,
                              $debug );
```

```
// Once you have a client, you can buy stocks at market price.
$accountId = 123456789;
$ticker    = 'LODE';
$quantity  = 1;

try {
   $tdaClient->buyStockSharesMarketPrice($accountId, $ticker, $quantity);
} catch (Exception $exception) {
   echo $exception->getMessage();
}

// Now, log into your TDAmeritrade account online, and you should see a new order.

// To sell some shares at the market price...
try {
   $tdaClient->sellStockSharesMarketPrice($accountId, $ticker, $quantity);
} catch (Exception $exception) {
   echo $exception->getMessage();
}
```

You can look through the TDAmeritradeAPI.php file for a complete list of the actions I have written code for.

Happy trading!

-Mike

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance22

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Recently: every ~116 days

Total

20

Last Release

1039d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b701baeed9e105a4a117e363b478d932306516c9365b4f2e3ef2dfed358f608b?d=identicon)[michaeldrennen](/maintainers/michaeldrennen)

---

Top Contributors

[![michaeldrennen](https://avatars.githubusercontent.com/u/5288190?v=4)](https://github.com/michaeldrennen "michaeldrennen (60 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michaeldrennen-td-ameritrade-api/health.svg)

```
[![Health](https://phpackages.com/badges/michaeldrennen-td-ameritrade-api/health.svg)](https://phpackages.com/packages/michaeldrennen-td-ameritrade-api)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
