dambrogia / alpaca-php
PHP REST client for Alpaca.
Installs: 1 601
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 2
Requires
- guzzlehttp/guzzle: ^7.0
- ratchet/pawl: ^0.3.4
Requires (Dev)
- phpunit/phpunit: ^8
- squizlabs/php_codesniffer: ^3.4
- vlucas/phpdotenv: ^3.3
This package is auto-updated.
Last update: 2025-03-20 00:31:05 UTC
README
A PHP REST client for Alpaca.
Getting started:
composer require dambrogia/alpaca-php
Using the client within your package:
Declare your configuration:
use Dambrogia\Alpaca\Config;
...
$config = new Config($key, $secret, Config::ENV_PAPER);
// Can also use Config::ENV_LIVE here ^ as well for production mode.
Once you declare the configuration, there's 2 ways to use the package. The entire package can be loaded and specific endpoints/features can be navigated to, or only certain sets of endpoints can be loaded initially. The package is fairly small so the overhead to load the entire library isn't much.
use Dambrogia\Alpaca\Alpaca;
...
$account = (new Alpaca($config))->v2()->account()->get();
// or
use Dambrogia\Alpaca\Client\V2;
...
$account = (new V2($config))->account()->get();
Endpoints Covered
If there are missing/incorrect endpoints, please create an issue so that it can be addressed!
Testing
To run the tests, download the package, copy .env.sample
to .env
and place your paper trading credentials in the .env file. Feel free to look at the testing here.