{"id":17810075,"url":"https://github.com/butschster/kraken-api-client","last_synced_at":"2025-05-07T20:09:30.393Z","repository":{"id":29990550,"uuid":"123406891","full_name":"butschster/kraken-api-client","owner":"butschster","description":"The most powerful and extendable REST API / Websocket client for Kraken.com. Built on PHP8.0","archived":false,"fork":false,"pushed_at":"2024-05-06T06:24:15.000Z","size":115,"stargazers_count":47,"open_issues_count":4,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-07T20:09:20.926Z","etag":null,"topics":["kraken-api","kraken-exchange-api","laravel","php8","rest-api","websocket-client"],"latest_commit_sha":null,"homepage":"","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/butschster.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-03-01T08:41:46.000Z","updated_at":"2025-02-20T22:29:30.000Z","dependencies_parsed_at":"2024-05-06T06:33:12.108Z","dependency_job_id":"be45d6f3-e704-4329-88e6-6fbbaf0abce4","html_url":"https://github.com/butschster/kraken-api-client","commit_stats":{"total_commits":24,"total_committers":5,"mean_commits":4.8,"dds":0.25,"last_synced_commit":"71dfd0519f850964d8b0f2217acb4c5b8a7f2aee"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fkraken-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fkraken-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fkraken-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fkraken-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/butschster","download_url":"https://codeload.github.com/butschster/kraken-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949271,"owners_count":21830151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["kraken-api","kraken-exchange-api","laravel","php8","rest-api","websocket-client"],"created_at":"2024-10-27T15:25:19.232Z","updated_at":"2025-05-07T20:09:30.356Z","avatar_url":"https://github.com/butschster.png","language":"PHP","funding_links":["https://patreon.com/butschster"],"categories":[],"sub_categories":[],"readme":"![kraken](https://user-images.githubusercontent.com/773481/121415892-dc088c80-c970-11eb-9ce2-66de76749a44.jpg)\n\n# The most powerful and extendable REST API / Websocket client for Kraken.com. Built on PHP8.1\n\nThis is an unofficial Kraken.com PHP8.1 package, which should help users very quickly connect to API from their Laravel or other php project.\nOf course, the primary feature of this package is the ability to interact with [Kraken REST API](https://docs.kraken.com/rest/), but also it allows connecting to [Kraken Websocket server](https://docs.kraken.com/websockets/).\n\n[![Support me on Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dbutschster%26type%3Dpatrons\u0026style=flat)](https://patreon.com/butschster)\n[![Build Status](https://github.com/butschster/kraken-api-client/actions/workflows/php.yml/badge.svg)](https://github.com/butschster/kraken-api-client/actions/workflows/php.yml)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/butschster/kraken-api-client)](https://packagist.org/packages/butschster/kraken-api-client)\n[![License](https://poser.pugx.org/butschster/meta-tags/license)](https://packagist.org/packages/butschster/kraken-api-client)\n\n## Features\n- REST API client\n- Websocket client\n- Well documented\n- Well tested\n\n\n## Requirements\n- Laravel 8.x, Laravel 9.x, Laravel 10.x, or other framework\n- PHP 8.1 and above\n\n## Installation\nRequire this package with composer using the following command:\n`composer require butschster/kraken-api-client`\n\n## Using\n\n### Laravel Autodiscovery\nIf you're using Laravel 8.0+ or above, the package will automatically register the KrakenServiceProvider.\n\n### Other PHP frameworks\n\n**REST API client**\n```php\n$client = new \\Butschster\\Kraken\\Client(\n    new GuzzleHttp\\Client(),\n    new \\Butschster\\Kraken\\NonceGenerator(),\n    (new \\Butschster\\Kraken\\Serializer\\SerializerFactory())-\u003ebuild(),\n    'api-key',\n    'api-secret'\n);\n\n$client-\u003egetAccountBalance();\n```\n\n**Websocket client**\n```php\n$client = new \\Butschster\\Kraken\\WebsocketClient(\n   (new \\Butschster\\Kraken\\Serializer\\SerializerFactory())-\u003ebuild(),\n   \\React\\EventLoop\\Factory::create()\n);\n\n$client-\u003econnectToPublicServer(...);\n```\n\n#### Configuration\n\nYou can update your .env file with the following:\n```\nKRAKEN_KEY=my_api_key\nKRAKEN_SECRET=my_secret\nKRAKEN_OTP=my_otp_key # if two-factor enabled, otherwise not required\n```\n\n## REST API methods\n\n#### API client usage\n\nBy using dependency injection\n```php\nuse App\\Http\\Controllers\\Controller;\nuse Butschster\\Kraken\\Contracts\\Client;\n\nclass BalanceController extends Controller {\n\n    public function getBalance(Client $client)\n    {\n        $balances = $client-\u003egetAccountBalance();\n       \n        ...\n    }\n}\n```\n\n### Make request\nThis package uses [jms/serializer](https://jmsyst.com/libs/serializer) for converting API responses to object, so you have to pass class, \nthat will use for deserializing.\n\n*Note: For non exists API methods you have to create response classes by your self.*\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n// Public request\n$client-\u003erequest('public/Spread', RecentSpreadsResponse::class, array $params): RecentSpreadsResponse;\n\n// Private request\n$balance = $client-\u003erequest('private/Balance', \\Butschster\\Kraken\\Responses\\AccountBalanceResponse::class, array $params);\n```\n\n**If request return an error, will be thrown an exception `\\Butschster\\Kraken\\Exceptions\\KrakenApiErrorException`**\n\n### Get Server Time\nGet the server's time.\n\nSee: https://docs.kraken.com/rest/#operation/getServerTime\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n$response = $client-\u003egetServerTime();\n\n$response-\u003etime; // DateTimeInterface\n$response-\u003erfc1123; // string:\"Sun, 21 Mar 21 14:23:14 +0000\n```\n\n### Get System Status\nGet the current system status or trading mode.\n\nSee: https://docs.kraken.com/rest/#operation/getSystemStatus\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n$response = $client-\u003egetSystemStatus();\n\n$response-\u003estatus; // string:\"online\"\n$response-\u003etimestamp; // DateTimeImmutable\n```\n\n### Get Asset Info\nGet information about the assets that are available for deposit, withdrawal, trading and staking.\n\nSee: https://docs.kraken.com/rest/#operation/getAssetInfo\n\n```php\nuse Butschster\\Kraken\\ValueObjects\\AssetClass;\n\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n$response = $client-\u003egetAssetInfo(array $assets = ['all'], ?AssetClass $class = null);\n\nforeach ($response as $asset =\u003e $info) {\n    $asset; // string: \"XXBT\"\n    \n    $info-\u003eclass; // string:\"currency\"\n    $info-\u003ealtname; // string:\"XBT\"\n    $info-\u003edecimals; // int:10\n    $info-\u003edisplayDecimals; // int:5\n}\n```\n\n### Get Tradable Asset Pairs\nGet tradable asset pairs\n\nSee: https://docs.kraken.com/rest/#operation/getTradableAssetPairs\n\n```php\nuse Butschster\\Kraken\\ValueObjects\\AssetPair;\nuse Butschster\\Kraken\\ValueObjects\\TradableInfo;\nuse Butschster\\Kraken\\Responses\\Entities\\Fee;\n\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n$pair = new AssetPair('XXBTCZUSD', 'XETHXXBT');\n$info = TradableInfo::leverage();\n\n$response = $client-\u003egetTradableAssetPairs($pair, $info);\n\nforeach ($response as $pair =\u003e $assetPair) {\n    $pair ;// string:\"XETHXXBT\"\n    \n    $assetPair-\u003ealtname; // string:\"ETHXBT\"\n    $assetPair-\u003ewsname; // string:\"ETH/XBT\"\n    $assetPair-\u003eclassBase; // string:\"currency\"\n    $assetPair-\u003ebase; // string:\"XETH\"\n    $assetPair-\u003eclassQuote; // string:\"currency\"\n    $assetPair-\u003equote; // string:\"XXBT\"\n    $assetPair-\u003epairDecimals; // int:5\n    $assetPair-\u003elotDecimals; // int:8\n    $assetPair-\u003elotMultiplier; // int:1\n    $assetPair-\u003eleverageBuy; // array:[2,3,4,5]\n    $assetPair-\u003eleverageSell; // array:[2,3,4,5]\n    $assetPair-\u003efeeVolumeCurrency; // string:\"ZUSD\"\n    $assetPair-\u003emarginCall; // int:80\n    $assetPair-\u003emarginStop; // int:40\n    $assetPair-\u003eordermin; // string:\"0.005\"\n    \n    foreach ($assetPair-\u003efees as $fee) {\n        $fee-\u003egetPercentFee(); // float:0.2\n        $fee-\u003egetVolume(); // int:2500000\n    }\n    \n    foreach ($assetPair-\u003efeesMaker as $fee) {\n        $fee-\u003egetPercentFee(); // float:0.2\n        $fee-\u003egetVolume(); // int:2500000\n    }\n    \n}\n```\n\n### Get Ticker Information\nNote: Today's prices start at midnight UTC\n\nSee: https://docs.kraken.com/rest/#operation/getTickerInformation\n\n```php\nuse Brick\\Math\\BigDecimal;\n\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n$response = $client-\u003egetTickerInformation(['XBTUSD', 'XXBTZUSD', ...]);\n\nforeach ($response as $pair =\u003e $tickerInfo) {\n    $pair; // string: \"XXBTZUSD\"\n    \n    $tickerInfo-\u003eask-\u003egetLotVolume(); // BigDecimal\n    $tickerInfo-\u003eask-\u003egetPrice(); // BigDecimal\n    $tickerInfo-\u003eask-\u003egetWholeLotVolume(); // BigDecimal\n    \n    $tickerInfo-\u003ebid-\u003egetLotVolume(); // BigDecimal\n    $tickerInfo-\u003ebid-\u003egetPrice(); // BigDecimal\n    $tickerInfo-\u003ebid-\u003egetWholeLotVolume(); // BigDecimal\n    \n    $tickerInfo-\u003elastTradeClosed[0]; // string:\"52641.10000\"\n    $tickerInfo-\u003elastTradeClosed[1]; // string:\"0.00080000\"\n    \n    $tickerInfo-\u003evolume-\u003egetLast24Hours(); // BigDecimal\n    $tickerInfo-\u003evolume-\u003egetToday(); // BigDecimal\n    \n    $tickerInfo-\u003evolumeWightedAveragePrice-\u003egetLast24Hours(); // BigDecimal\n    $tickerInfo-\u003evolumeWightedAveragePrice-\u003egetToday(); // BigDecimal\n    \n    $tickerInfo-\u003etrades-\u003egetLast24Hours(); // int:0\n    $tickerInfo-\u003etrades-\u003egetToday(); // int:10\n    \n    $tickerInfo-\u003elow-\u003egetToday(); // BigDecimal\n    $tickerInfo-\u003elow-\u003egetLast24Hours(); // BigDecimal\n    \n    $tickerInfo-\u003ehigh-\u003egetToday(); // BigDecimal\n    $tickerInfo-\u003ehigh-\u003egetLast24Hours(); // BigDecimal\n    \n    $tickerInfo-\u003eopeningPrice; // BigDecimal\n}\n```\n\n### Get Order Book\nSee: https://docs.kraken.com/rest/#operation/getOrderBook\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003egetOrderBook(['XBTUSD', 'XXBTZUSD'], 100);\n\nforeach ($response as $pair =\u003e $orders) {\n    foreach ($orders-\u003easks as $order) {\n        $order-\u003egetPrice(); // BigDecimal\n        $order-\u003egetVolume(); // BigDecimal\n        $order-\u003egetTimestamp(); // int:1616663113\n        $order-\u003egetDate(); // DateTimeInterface\n    }\n    \n    foreach ($orders-\u003ebids as $order) {\n        $order-\u003egetPrice(); // BigDecimal\n        $order-\u003egetVolume(); // BigDecimal\n        $order-\u003egetTimestamp(); // int:1616663113\n        $order-\u003egetDate(); // DateTimeInterface\n    }\n}\n```\n\n### Get Account Balance\nRetrieve all cash balances, net of pending withdrawals.\n\nSee: https://docs.kraken.com/rest/#operation/getAccountBalance\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003egetAccountBalance();\n\nforeach ($response as $balance) {\n    $balance-\u003egetAsset(); // string:\"ZUSD\"\n    $balance-\u003egetBalance(); // BigDecimal\n}\n```\n\n### Get Trade Balance\nRetrieve a summary of collateral balances, margin position valuations, equity and margin level.\n\nSee: https://docs.kraken.com/rest/#operation/getTradeBalance\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003egetTradeBalance();\n\n$response-\u003eequivalentBalance; // BigDecimal\n$response-\u003etradeBalance; // BigDecimal\n$response-\u003emarginAmount; // BigDecimal\n$response-\u003enet; // BigDecimal\n$response-\u003ecost; // BigDecimal\n$response-\u003evaluation; // BigDecimal\n$response-\u003eequity; // BigDecimal\n$response-\u003efreeMargin; // BigDecimal\n$response-\u003emarginLevel; // BigDecimal\n```\n\n### Get Open Orders\nRetrieve information about currently open orders.\n\nSee: https://docs.kraken.com/rest/#operation/getOpenOrders\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003egetOpenOrders();\n\nforeach ($response as $txId =\u003e $order) {\n    $txId; // string:\"OQCLML-BW3P3-BUCMWZ\"\n    \n    $order-\u003erefId; // string|null\n    $order-\u003euserRef; // int:0\n    $order-\u003estatus; // string:\"online\"\n    $order-\u003eopenTimestamp; // int:1616666559.8974\n    $order-\u003estartTimestamp; // int:0\n    $order-\u003eexpireTimestamp; // int:0\n    \n    $order-\u003edescription-\u003epair; // string:\"XBTUSD\"\n    $order-\u003edescription-\u003etype; // string:\"buy\"\n    $order-\u003edescription-\u003eorderType; // string:\"limit\"\n    $order-\u003edescription-\u003eprice; // BigDecimal\n    $order-\u003edescription-\u003esecondaryPrice; // BigDecimal\n    $order-\u003edescription-\u003eleverage; // string:\"none\"\n    $order-\u003edescription-\u003eorder; // string:\"buy 1.25000000 XBTUSD @ limit 30010.0\"\n    $order-\u003edescription-\u003eclose; // string:\"\"\n    \n    $order-\u003evolume; // BigDecimal\n    $order-\u003evolumeExecuted; // BigDecimal\n    $order-\u003ecost; // BigDecimal\n    $order-\u003efee; // BigDecimal\n    $order-\u003eprice; // BigDecimal\n    $order-\u003estopPrice; // BigDecimal\n    $order-\u003elimitPrice; // BigDecimal\n    $order-\u003emiscellaneous; // array\u003cstring\u003e\n    $order-\u003eflags; // array:[\"fciq\"]\n    $order-\u003etrades; // array:[\"TCCCTY-WE2O6-P3NB37\"]\n}\n```\n\n### Get Closed Orders\nRetrieve information about orders that have been closed (filled or cancelled). 50 results are returned at a time, the most recent by default.\nNote: If an order's tx ID is given for start or end time, the order's opening time (opentm) is used\n\nSee: https://docs.kraken.com/rest/#operation/getClosedOrders\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$start = \\Carbon\\Carbon::now()-\u003esubDay();\n$end = \\Carbon\\Carbon::now();\n\n$response = $client-\u003egetClosedOrders(\n    start: $start, end: $end, offset: 100\n);\n\n$response-\u003ecount; // 5\n\nforeach ($response-\u003eclosed as $txId =\u003e $order) {\n    $txId; // string:\"OQCLML-BW3P3-BUCMWZ\"\n    \n    $order-\u003erefId; // string|null\n    $order-\u003euserRef; // int:0\n    $order-\u003estatus; // string:\"canceled\"\n    $order-\u003ereason; // string:\"User requested\"\n    $order-\u003eopenTimestamp; // int:1616666559.8974\n    $order-\u003estartTimestamp; // int:0\n    $order-\u003eexpireTimestamp; // int:0\n    \n    $order-\u003edescription-\u003epair; // string:\"XBTUSD\"\n    $order-\u003edescription-\u003etype; // string:\"buy\"\n    $order-\u003edescription-\u003eorderType; // string:\"limit\"\n    $order-\u003edescription-\u003eprice; // BigDecimal\n    $order-\u003edescription-\u003esecondaryPrice; // BigDecimal\n    $order-\u003edescription-\u003eleverage; // string:\"none\"\n    $order-\u003edescription-\u003eorder; // string:\"buy 1.25000000 XBTUSD @ limit 30010.0\"\n    $order-\u003edescription-\u003eclose; // string:\"\"\n    \n    $order-\u003evolume; // BigDecimal\n    $order-\u003evolumeExecuted; // BigDecimal\n    $order-\u003ecost; // BigDecimal\n    $order-\u003efee; // BigDecimal\n    $order-\u003eprice; // BigDecimal\n    $order-\u003estopPrice; // BigDecimal\n    $order-\u003elimitPrice; // BigDecimal\n    $order-\u003emiscellaneous; // array\u003cstring\u003e\n    $order-\u003eflags; // array:[\"fciq\"]\n    $order-\u003etrades; // array:[\"TCCCTY-WE2O6-P3NB37\"]\n}\n```\n\n### Query Orders Info\nRetrieve information about specific orders.\n\nSee: https://docs.kraken.com/rest/#operation/getOrdersInfo\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003equeryOrdersInfo(['OBCMZD-JIEE7-77TH3F', 'OMMDB2-FSB6Z-7W3HPO']);\n\nforeach ($response as $txId =\u003e $order) {\n    $txId; // string:\"OQCLML-BW3P3-BUCMWZ\"\n    \n    $order-\u003erefId; // string|null\n    $order-\u003euserRef; // int:0\n    $order-\u003estatus; // string:\"canceled\"\n    $order-\u003ereason; // string:\"User requested\"\n    $order-\u003eopenTimestamp; // int:1616666559.8974\n    $order-\u003estartTimestamp; // int:0\n    $order-\u003eexpireTimestamp; // int:0\n    \n    $order-\u003edescription-\u003epair; // string:\"XBTUSD\"\n    $order-\u003edescription-\u003etype; // string:\"buy\"\n    $order-\u003edescription-\u003eorderType; // string:\"limit\"\n    $order-\u003edescription-\u003eprice; // BigDecimal\n    $order-\u003edescription-\u003esecondaryPrice; // BigDecimal\n    $order-\u003edescription-\u003eleverage; // string:\"none\"\n    $order-\u003edescription-\u003eorder; // string:\"buy 1.25000000 XBTUSD @ limit 30010.0\"\n    $order-\u003edescription-\u003eclose; // string:\"\"\n    \n    $order-\u003evolume; // BigDecimal\n    $order-\u003evolumeExecuted; // BigDecimal\n    $order-\u003ecost; // BigDecimal\n    $order-\u003efee; // BigDecimal\n    $order-\u003eprice; // BigDecimal\n    $order-\u003estopPrice; // BigDecimal\n    $order-\u003elimitPrice; // BigDecimal\n    $order-\u003emiscellaneous; // array\u003cstring\u003e\n    $order-\u003eflags; // array:[\"fciq\"]\n    $order-\u003etrades; // array:[\"TCCCTY-WE2O6-P3NB37\"]\n}\n```\n\n### Add Order\nPlace a new order.\nNote: See the AssetPairs endpoint for details on the available trading pairs, their price and quantity precisions, order minimums, available leverage, etc.\n\nSee: https://docs.kraken.com/rest/#operation/addOrder\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Butschster\\Kraken\\ValueObjects\\CloseOrder;\nuse Butschster\\Kraken\\ValueObjects\\OrderDirection;\nuse Butschster\\Kraken\\ValueObjects\\OrderType;\n\n\n$order = new \\Butschster\\Kraken\\Requests\\AddOrderRequest(\n    OrderType::stopLoss(), OrderDirection::sell(), 'XXBTZUSD'\n);\n\n$order-\u003esetCloseOrder(new CloseOrder(OrderType::stopLoss(), '38000', '36000'));\n$order-\u003esetPrice('45000.1');\n$order-\u003e...\n\n$response = $client-\u003eaddOrder($order);\n\n$response-\u003edescription-\u003eorder; // string:\"sell 2.12340000 XBTUSD @ limit 45000.1 with 2:1 leverage\"\n$response-\u003edescription-\u003eclose; // string:\"close position @ stop loss 38000.0 -\u003e limit 36000.0\"\n$response-\u003etxId; // array:[\"OUF4EM-FRGI2-MQMWZD\"]\n```\n\n### Cancel Order\nCancel a particular open order (or set of open orders) by txid or userref\n\nSee: https://docs.kraken.com/rest/#operation/cancelOrder\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n$response = $client-\u003ecancelOrder('OYVGEW-VYV5B-UUEXSK');\n$response; // int:1\n```\n\n### Cancel All Orders\nCancel all open orders\n\nSee: https://docs.kraken.com/rest/#operation/cancelAllOrders\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n$response = $client-\u003ecancelAllOrders();\n$response; // int:1\n```\n\n### Cancel All Orders After X\nCancelAllOrdersAfter provides a \"Dead Man's Switch\" mechanism to protect the client from network malfunction, extreme latency or unexpected matching engine downtime. The client can send a request with a timeout (in seconds), that will start a countdown timer which will cancel all client orders when the timer expires. The client has to keep sending new requests to push back the trigger time, or deactivate the mechanism by specifying a timeout of 0. If the timer expires, all orders are cancelled and then the timer remains disabled until the client provides a new (non-zero) timeout.\n\nThe recommended use is to make a call every 15 to 30 seconds, providing a timeout of 60 seconds. This allows the client to keep the orders in place in case of a brief disconnection or transient delay, while keeping them safe in case of a network breakdown. It is also recommended to disable the timer ahead of regularly scheduled trading engine maintenance (if the timer is enabled, all orders will be cancelled when the trading engine comes back from downtime - planned or otherwise).\n\nSee: https://docs.kraken.com/rest/#operation/cancelAllOrdersAfter\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n$response = $client-\u003ecancelAllOrdersAfter(60);\n$response-\u003ecurrentTime; // DateTimeInterface\n$response-\u003etriggerTime; // DateTimeInterface\n```\n\n### Get Deposit Methods\nRetrieve methods available for depositing a particular asset.\n\nSee: https://docs.kraken.com/rest/#operation/getDepositMethods\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003egetDepositMethods('XBT');\n$response-\u003emethod; // string:\"Bitcoin\"\n$response-\u003elimit; // int|bool:false\n$response-\u003efee; // BigDecimal\n$response-\u003egeneratedAddress; // bool:true\n$response-\u003eaddressSetupFee; // string:\"\"\n```\n\n### Get Deposit Addresses\nRetrieve (or generate a new) deposit addresses for a particular asset and method.\n\nSee: https://docs.kraken.com/rest/#operation/getDepositAddresses\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n$response = $client-\u003egetDepositAddresses('XBT', 'Bitcoin');\n\nforeach ($response as $address) {\n    $address-\u003eaddress; // string:\"2N9fRkx5JTWXWHmXzZtvhQsufvoYRMq9ExV\"\n    $address-\u003eexpireTimestamp; // int:0\n    $address-\u003enew; // bool:true\n}\n```\n\n### Get Withdrawal Information\nRetrieve fee information about potential withdrawals for a particular asset, key and amount.\n\nSee: https://docs.kraken.com/rest/#operation/getWithdrawalInformation\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\nuse Brick\\Math\\BigDecimal;\n\n$response = $client-\u003egetWithdrawalInformation('XBT', 'btc_testnet_with1', BigDecimal::of(0.725));\n\n$response-\u003emethod; // string:\"Bitcoin\"\n$response-\u003elimit; // BigDecimal\n$response-\u003eamount; // BigDecimal\n$response-\u003efee; // BigDecimal\n```\n\n### Get Websockets Token\nAn authentication token must be requested via this REST API endpoint in order to connect to and authenticate with our Websockets API. The token should be used within 15 minutes of creation, but it does not expire once a successful Websockets connection and private subscription has been made and is maintained.\n\nSee: https://docs.kraken.com/rest/#operation/getWebsocketsToken\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\Client $client */\n\n$response = $client-\u003egetWebsocketsToken();\n$response-\u003etoken; // string:\"1Dwc4lzSwNWOAwkMdqhssNNFhs1ed606d1WcF3XfEMw\"\n$response-\u003eexpires; // int:900\n$response-\u003eexpiresAt(); // DateTimeInterface\n```\n\n---\n\n## Websocket Client\n\n### Websocket client usage\n\nBy using dependency injection\n\n```php\nnamespace App\\Console\\Commands\\ExampleCommand;\n\nuse Butschster\\Kraken\\Contracts\\WebsocketClient;\nuse Butschster\\Kraken\\Websocket\\Connection;\n\nclass ExampleCommand extends Command \n{\n    ...\n    \n    public function handle(WebsocketClient $client)\n    {\n        $client-\u003econnectToPublicServer(function (Connection $connection) {\n        \n            ...\n        \n        });\n    }\n}\n```\n\n### Ping\nClient can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated\n\nSee: https://docs.kraken.com/websockets/#message-ping\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\WebsocketClient $client */\n\nuse Butschster\\Kraken\\Websocket\\Connection;\nuse Butschster\\Kraken\\Websocket\\Requests\\Ping;\nuse Butschster\\Kraken\\Websocket\\Timer;\n\n$client-\u003econnectToPublicServer(function (Connection $connection) {\n    $connection-\u003esendEvent(new Ping());\n    \n    // or\n    \n    $connection-\u003eaddPeriodicTimer(\n        new Timer(5, new Ping())\n    );\n});\n\n\n$client-\u003econnectToPrivateServer('websocket-token', function (Connection $connection) {\n    ...\n});\n```\n\n### HeartBeat\nServer heartbeat sent if no subscription traffic within 1 second (approximately)\n\nSee: https://docs.kraken.com/websockets/#message-heartbeat\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\WebsocketClient $client */\n\nuse Butschster\\Kraken\\Websocket\\Connection;\nuse Butschster\\Kraken\\Websocket\\Requests\\HeartBeat;\nuse Butschster\\Kraken\\Websocket\\Timer;\n\n$client-\u003econnectToPublicServer(function (Connection $connection) {\n    $connection-\u003esendEvent(new HeartBeat());\n    \n    // or\n    \n    $connection-\u003eaddPeriodicTimer(\n        new Timer(5, new HeartBeat())\n    );\n});\n```\n\n### Subscribe to an event\nSubscribe to a topic on a single or multiple currency pairs.\n\nSee: https://docs.kraken.com/websockets/#message-subscribe\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\WebsocketClient $client */\n\nuse Butschster\\Kraken\\Websocket\\Connection;\nuse Butschster\\Kraken\\Websocket\\Requests\\Subscribe;\n\n$client-\u003econnectToPublicServer(function (Connection $connection) {\n    $connection-\u003esendEvent(\n        new Subscribe(\n            'ticker',\n            [\"XBT/USD\", \"XBT/EUR\"]\n        )\n    );\n    \n    $connection-\u003eonMessage(function (string $message) {\n        // Handle message\n    });\n});\n```\n\n### Custom events\nYou can create you own events\n\n```php\n/** @var \\Butschster\\Kraken\\Contracts\\WebsocketClient $client */\n\n// For public events you have to use \\Butschster\\Kraken\\Contracts\\WebsocketEvent interface\n// For private events you have to use \\Butschster\\Kraken\\Contracts\\PrivateWebsocketEvent interface\n\nclass OwnTradesEvent implements \\Butschster\\Kraken\\Contracts\\PrivateWebsocketEvent {\n    public string $event = 'subscribe';\n    public array $subscription = [\n        'name' =\u003e 'ownTrades'\n    ];\n    \n    public function setToken(string $token) : void{\n        $this-\u003esubscription['token'] = $toke;\n    }\n}\n\n$client-\u003econnectToPrivateServer('token', function (Connection $connection) {\n    $connection-\u003esendEvent(\n        new OwnTradesEvent()\n    );\n});\n```\n\n# Enjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutschster%2Fkraken-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbutschster%2Fkraken-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutschster%2Fkraken-api-client/lists"}