{"id":19291489,"url":"https://github.com/devstar0209/alpaca-php-sdk","last_synced_at":"2026-02-02T14:28:30.904Z","repository":{"id":251300984,"uuid":"837002209","full_name":"devstar0209/alpaca-php-sdk","owner":"devstar0209","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-03T08:09:59.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-12T23:31:58.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devstar0209.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-02T02:31:33.000Z","updated_at":"2024-08-03T08:08:48.000Z","dependencies_parsed_at":"2024-08-02T04:14:02.631Z","dependency_job_id":"e3fb3a84-2bd3-43b3-b5a9-a8f254a7ec23","html_url":"https://github.com/devstar0209/alpaca-php-sdk","commit_stats":null,"previous_names":["devstar0209/alpaca-php-sdk","bitxpilot/alpaca-php-sdk"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/devstar0209/alpaca-php-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstar0209%2Falpaca-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstar0209%2Falpaca-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstar0209%2Falpaca-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstar0209%2Falpaca-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devstar0209","download_url":"https://codeload.github.com/devstar0209/alpaca-php-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstar0209%2Falpaca-php-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29012982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T12:48:30.580Z","status":"ssl_error","status_checked_at":"2026-02-02T12:46:38.384Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T22:25:35.875Z","updated_at":"2026-02-02T14:28:30.885Z","avatar_url":"https://github.com/devstar0209.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alpaca Trading PHP SDK\n\nThis package acts as a PHP SDK for the [Alpaca Trading API](https://docs.alpaca.markets/).\n\nAlso, check out the [Polygon PHP SDK](https://github.com/tmarois/polygon-php-sdk) for real time data.\n\n## Installation\n\nUse [Composer](http://getcomposer.org/) to install package.\n\nRun `composer require devstar/alpaca-php-sdk`\n\n## Getting Started\n\nFirst you need to instantiate the `Alpaca` object.\n\n```php\nuse Alpaca\\Alpaca;\n\n$alpaca = new Alpaca(\"YOUR_API_KEY_ID\", \"YOUR_API_SECRET_KEY\");\n```\n\n## Example Usage\n\n**[Get Account](https://docs.alpaca.markets/api-documentation/api-v2/account/)**: Get the account details\n\n```php\n// this will pull a request from alpaca to get account details\n$account = $alpaca-\u003eaccount();\n\n// here are some helper methods to quickly get the details\n$number = $account-\u003enumber();\n$id = $account-\u003eid();\n$status = $account-\u003estatus();\n$buyingPower = $account-\u003ebuyingPower();\n$cash = $account-\u003ecash();\n$longValue = $account-\u003elongValue();\n$shortValue = $account-\u003eshortValue();\n$portfolioValue = $account-\u003eportfolioValue();\n\n// gets the raw array from Alpaca\n// view documentation for the correct keys\n$raw = $account-\u003eraw();\n```\n\n**[Get Order](https://docs.alpaca.markets/api-documentation/api-v2/orders/#order-entity)**: Get a specific order\n\n```php\n$order = $alpaca-\u003eorders()-\u003eget('ORDER_ID');\n```\n\n**[Get All Orders](https://docs.alpaca.markets/api-documentation/api-v2/orders/#order-entity)**: Get an array of all open orders\n\n```php\n// get all open orders\n$orders = $alpaca-\u003eorders()-\u003egetAll();\n\n// get orders of specific types\n// type: open, closed, or all\n$orders = $alpaca-\u003eorders()-\u003egetAll($type,$limit,$dateFrom,$dateTo,$direction);\n```\n\n**[Cancel An Order](https://docs.alpaca.markets/api-documentation/api-v2/orders/#cancel-all-orders)**: Cancel a specific order\n\n```php\n$orders = $alpaca-\u003eorders()-\u003ecancel('ORDER_ID);\n```\n\n**[Cancel All Orders](https://docs.alpaca.markets/api-documentation/api-v2/orders/#cancel-all-orders)**: Cancel all open orders\n\n```php\n$orders = $alpaca-\u003eorders()-\u003ecancelAll();\n```\n\n**[Create An Order](https://docs.alpaca.markets/api-documentation/api-v2/orders/#request-a-new-order)**: Create a new order\n\n```php\n$alpaca-\u003eorders()-\u003ecreate([\n    // stock to purchase\n    'symbol' =\u003e 'AAPL',\n\n    // how many shares\n    'qty' =\u003e 1,\n\n    // buy or sell\n    'side' =\u003e 'buy',\n\n    // market, limit, stop, or stop_limit\n    'type' =\u003e 'market',\n\n    // day, gtc, opg, cls, ioc, fok.\n    // @see https://docs.alpaca.markets/orders/#time-in-force\n    'time_in_force' =\u003e 'day',\n\n    // required if type is limit or stop_limit\n    // 'limit_price' =\u003e 0,\n\n    // required if type is stop or stop_limit\n    // 'stop_price' =\u003e 0,\n\n    'extended_hours' =\u003e false,\n\n    // optional if adding custom id\n    // 'client_order_id' =\u003e ''\n]);\n```\n\n**[Replace An Order](https://docs.alpaca.markets/api-documentation/api-v2/orders/#replace-an-order)**: Replaces an existing order\n\n```php\n$alpaca-\u003eorders()-\u003ereplace('ORDER_ID',[\n    'qty' =\u003e 1,\n\n    // required if type is limit or stop_limit\n    // 'limit_price' =\u003e 0,\n\n    // required if type is stop or stop_limit\n    // 'stop_price' =\u003e 0,\n\n    // day, gtc, opg, cls, ioc, fok.\n    // @see https://docs.alpaca.markets/orders/#time-in-force\n    'time_in_force' =\u003e 'day',\n\n    // optional if adding custom id\n    // 'client_order_id' =\u003e ''\n]);\n```\n\n**[Get Position](https://docs.alpaca.markets/api-documentation/api-v2/orders/#get-open-positions)**: Get an open position\n\n```php\n$position = $alpaca-\u003epositions()-\u003eget('SYMBOL');\n```\n\n**[Get All Positions](https://docs.alpaca.markets/api-documentation/api-v2/orders/#get-an-open-position)**: Get all open positions\n\n```php\n$positions = $alpaca-\u003epositions()-\u003egetAll();\n```\n\n**Position Entity Response:**\n\n```json\n{\n  \"asset_id\": \"904837e3-3b76-47ec-b432-046db621571b\",\n  \"symbol\": \"AAPL\",\n  \"exchange\": \"NASDAQ\",\n  \"asset_class\": \"us_equity\",\n  \"avg_entry_price\": \"100.0\",\n  \"qty\": \"5\",\n  \"side\": \"long\",\n  \"market_value\": \"600.0\",\n  \"cost_basis\": \"500.0\",\n  \"unrealized_pl\": \"100.0\",\n  \"unrealized_plpc\": \"0.20\",\n  \"unrealized_intraday_pl\": \"10.0\",\n  \"unrealized_intraday_plpc\": \"0.0084\",\n  \"current_price\": \"120.0\",\n  \"lastday_price\": \"119.0\",\n  \"change_today\": \"0.0084\"\n}\n```\n\n**[Close a Position](https://docs.alpaca.markets/api-documentation/api-v2/orders/#close-a-position)**: Close a position\n\n```php\n$alpaca-\u003epositions()-\u003eclose('SYMBOL');\n```\n\n**[Close All Positions](https://docs.alpaca.markets/api-documentation/api-v2/orders/#close-a-position)**: Close all open positions\n\n```php\n$alpaca-\u003epositions()-\u003ecloseAll();\n```\n\n\n**[Get Activity](https://docs.alpaca.markets/api-documentation/api-v2/account-activities/)**: Get the account activity, like order fills, dividends etc.\n\n```php\n// type can be many, such as FILL, DIV, TRANS etc\n// view on this page https://docs.alpaca.markets/api-documentation/api-v2/account-activities/\n$activity = $alpaca-\u003eactivity()-\u003eget('TYPE');\n```\n\nThere are more in the [Alpaca Documentation](https://docs.alpaca.markets/) than what is presented above, if you want to extend this, please send in a pull request or request features you'd like to see added. Thanks!\n\n## Contributions\n\nAnyone can contribute to **alpaca-php-sdk**. Please do so by posting issues when you've found something that is unexpected or sending a pull request for improvements.\n\n## License\n\n**alpaca-php-sdk** (This Repository) is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n\nThis SDK has no affiliation with alpaca.markets, Alpaca Securities LLC and AlpacaDB and acts as an unofficial SDK designed to be a simple solution with using PHP applications. **Use at your own risk**. If you have any issues with the SDK please submit an issue or pull request.\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstar0209%2Falpaca-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevstar0209%2Falpaca-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstar0209%2Falpaca-php-sdk/lists"}