{"id":36398335,"url":"https://github.com/zhouaini528/bitmex-php","last_synced_at":"2026-01-11T16:01:28.832Z","repository":{"id":57015323,"uuid":"155164723","full_name":"zhouaini528/bitmex-php","owner":"zhouaini528","description":"Bitmex API Like the official document interface, Support for arbitrary extension.","archived":false,"fork":false,"pushed_at":"2021-10-27T01:26:36.000Z","size":168,"stargazers_count":15,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-03T07:57:48.460Z","etag":null,"topics":["binance","bitmex","exchanges","huobi","kucoin","kumex","okex"],"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/zhouaini528.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}},"created_at":"2018-10-29T06:46:46.000Z","updated_at":"2024-08-14T19:59:21.000Z","dependencies_parsed_at":"2022-08-22T09:30:34.697Z","dependency_job_id":null,"html_url":"https://github.com/zhouaini528/bitmex-php","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/zhouaini528/bitmex-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouaini528%2Fbitmex-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouaini528%2Fbitmex-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouaini528%2Fbitmex-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouaini528%2Fbitmex-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhouaini528","download_url":"https://codeload.github.com/zhouaini528/bitmex-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouaini528%2Fbitmex-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28312074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: 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":["binance","bitmex","exchanges","huobi","kucoin","kumex","okex"],"created_at":"2026-01-11T16:00:30.427Z","updated_at":"2026-01-11T16:01:28.818Z","avatar_url":"https://github.com/zhouaini528.png","language":"PHP","readme":"### It is recommended that you use the test server first\n\nOnline interface testing [https://www.bitmex.com/api/explorer/](https://www.bitmex.com/api/explorer/)\n\nAddress of the test [https://testnet.bitmex.com](https://testnet.bitmex.com)\n\nThe official address [https://www.bitmex.com](https://www.bitmex.com)\n\nAll interface methods are initialized the same as those provided by Bitmex. See details [src/api](https://github.com/zhouaini528/bitmex-php/tree/master/src/Api)\n\nSupport [Websocket](https://github.com/zhouaini528/bitmex-php/blob/master/README.md#Websocket)\n\nMost of the interface is now complete, and the user can continue to extend it based on my design, working with me to improve it.\n\n[中文文档](https://github.com/zhouaini528/bitmex-php/blob/master/README_CN.md)\n\n### Other exchanges API\n\n[Exchanges](https://github.com/zhouaini528/exchanges-php) It includes all of the following exchanges and is highly recommended.\n\n[Bitmex](https://github.com/zhouaini528/bitmex-php) Support [Websocket](https://github.com/zhouaini528/bitmex-php/blob/master/README.md#Websocket)\n\n[Okex](https://github.com/zhouaini528/okex-php) Support [Websocket](https://github.com/zhouaini528/okex-php/blob/master/README.md#Websocket)\n\n[Huobi](https://github.com/zhouaini528/huobi-php) Support [Websocket](https://github.com/zhouaini528/huobi-php/blob/master/README.md#Websocket)\n\n[Binance](https://github.com/zhouaini528/binance-php) Support [Websocket](https://github.com/zhouaini528/binance-php/blob/master/README.md#Websocket)\n\n[Kucoin](https://github.com/zhouaini528/kucoin-php)\n\n[Mxc](https://github.com/zhouaini528/Mxc-php)\n\n[Coinbase](https://github.com/zhouaini528/coinbase-php)\n\n[ZB](https://github.com/zhouaini528/zb-php)\n\n[Bitfinex](https://github.com/zhouaini528/bitfinex-php)\n\n[Bittrex](https://github.com/zhouaini528/bittrex-php)\n\n[Kraken](https://github.com/zhouaini528/kraken-php)\n\n[Gate](https://github.com/zhouaini528/gate-php)   \n\n[Bigone](https://github.com/zhouaini528/bigone-php)   \n\n[Crex24](https://github.com/zhouaini528/crex24-php)   \n\n[Bybit](https://github.com/zhouaini528/bybit-php)  \n\n[Coinbene](https://github.com/zhouaini528/coinbene-php)   \n\n[Bitget](https://github.com/zhouaini528/bitget-php)   \n\n[Poloniex](https://github.com/zhouaini528/poloniex-php)\n\n**If you don't find the exchange SDK you want, you can tell me and I'll join them.** \n\n#### Installation\n```\ncomposer require linwj/bitmex\n```\n\nSupport for more request Settings [More](https://github.com/zhouaini528/bitmex-php/blob/master/tests/proxy.php#L24)\n```php\n$bitmex=new Bitmex();\n\n//You can set special needs\n$bitmex-\u003esetOptions([\n    //Set the request timeout to 60 seconds by default\n    'timeout'=\u003e10,\n    //https://github.com/guzzle/guzzle\n    'proxy'=\u003e[],\n    //https://www.php.net/manual/en/book.curl.php\n    'curl'=\u003e[],\n]);\n```\n\nBook Data [More](https://github.com/zhouaini528/bitmex-php/blob/master/tests/position.php)\n```php\n//Get market data\n//Book data may be key and secret\ntry {\n    $bitmex=new Bitmex();\n    $result=$bitmex-\u003eorderBook()-\u003eget([\n        'symbol'=\u003e'ETHUSD',\n        'depth'=\u003e20\n    ]);\n    print_r($result);\n}catch (\\Exception $e){\n    print_r($e-\u003egetMessage());\n}\n```\n\nOrder [More](https://github.com/zhouaini528/bitmex-php/blob/master/tests/order.php)\n```php\n//Test API address  default  https://www.bitmex.com\n$key='eLB_l505a_cuZL8Cmu5uo7EP';\n$secret='wG3ndMquAPl6c-jHUQNhyBQJKGBwdFenIF2QxcgNKE_g8Kz3';\n$host='https://testnet.bitmex.com';\n\n$bitmex=new Bitmex($key,$secret,$host);\n\n//bargaining transaction\ntry {\n    $result=$bitmex-\u003eorder()-\u003epost([\n        'symbol'=\u003e'XBTUSD',\n        'price'=\u003e'100',\n        'side'=\u003e'Buy',\n        'orderQty'=\u003e'1',\n        'ordType'=\u003e'Limit',\n    ]);\n    print_r($result);\n}catch (\\Exception $e){\n    print_r($e-\u003egetMessage());\n}\n\n//track the order\ntry {\n    $result=$bitmex-\u003eorder()-\u003egetOne([\n        'symbol'=\u003e'XBTUSD',\n        'orderID'=\u003e$result['orderID'],\n    ]);\n    print_r($result);\n}catch (\\Exception $e){\n    print_r($e-\u003egetMessage());\n}\n\n//update the order\ntry {\n    $result=$bitmex-\u003eorder()-\u003eput([\n        'symbol'=\u003e'XBTUSD',\n        'orderID'=\u003e$result['orderID'],\n        'price'=\u003e'200',\n        'orderQty'=\u003e'2',\n    ]);\n    print_r($result);\n}catch (\\Exception $e){\n    print_r($e-\u003egetMessage());\n}\n\n//cancellation of order\ntry {\n    $result=$bitmex-\u003eorder()-\u003edelete([\n        'symbol'=\u003e'XBTUSD',\n        'orderID'=\u003e$result['orderID'],\n    ]);\n    print_r($result);\n}catch (\\Exception $e){\n    print_r($e-\u003egetMessage());\n}\n```\n\n\nPostion [More](https://github.com/zhouaini528/bitmex-php/blob/master/tests/position.php)\n```php\n//bargaining transaction\ntry {\n    //Default return all\n    $result=$bitmex-\u003eposition()-\u003eget([\n        //'filter'=\u003e'{\"symbol\": \"XBTUSD\"}',\n        //'columns'=\u003e'markPrice',\n        //'count'=\u003e1,\n    ]);\n    print_r($result);\n}catch (\\Exception $e){\n    print_r($e-\u003egetMessage());\n}\n```\n\n[More Test](https://github.com/zhouaini528/bitmex-php/tree/master/tests)\n\n[More API](https://github.com/zhouaini528/bitmex-php/tree/master/src/Api)\n\n### Websocket\n\nWebsocket has two services, server and client. The server is responsible for dealing with the new connection of the exchange, data receiving, authentication and login. Client is responsible for obtaining and processing data.\n\nServer initialization must be started in Linux CLI mode.\n```php\nuse \\Lin\\Bitmex\\BitmexWebSocket;\nrequire __DIR__ .'./vendor/autoload.php';\n\n$bitmex=new BitmexWebSocket();\n\n$bitmex-\u003econfig([\n    //Do you want to enable local logging,default false\n    //'log'=\u003etrue,\n    //Or set the log name\n    'log'=\u003e['filename'=\u003e'bitmex'],\n\n    //Daemons address and port,default 0.0.0.0:2211\n    //'global'=\u003e'127.0.0.1:2211',\n\n    //Channel subscription monitoring time,2 seconds\n    //'listen_time'=\u003e2,\n\n    //Channel data update time,default 0.5 seconds\n    //'data_time'=\u003e0.5,\n\n    //Heartbeat time,default 30 seconds\n    //'ping_time'=\u003e30,\n\n    //Number of messages WS queue shuold hold, default 100\n    //'queue_count'=\u003e100,\n\n    //baseurl host\n    //'baseurl'=\u003e'ws://www.bitmex.com/realtime',//default\n    //'baseurl'=\u003e'ws://testnet.bitmex.com/realtime',//test\n]);\n\n$bitmex-\u003estart();\n```\n\nIf you want to test, you can \"php server.php start\" immediately outputs the log at the terminal.\n\nIf you want to deploy, you can \"php server.php start -d\" enables resident process mode, and enables \"log=\u003etrue\" to view logs.\n\n[More Test](https://github.com/zhouaini528/bitmex-php/tree/master/tests/websocket)\n\nClient side initialization.\n```php\n$bitmex=new BitmexWebSocket();\n\n$bitmex-\u003econfig([\n    //Do you want to enable local logging,default false\n    //'log'=\u003etrue,\n    //Or set the log name\n    'log'=\u003e['filename'=\u003e'bitmex'],\n\n    //Daemons address and port,default 0.0.0.0:2216\n    //'global'=\u003e'127.0.0.1:2216',\n\n    //Channel subscription monitoring time,2 seconds\n    //'listen_time'=\u003e2,\n\n    //Channel data update time,default 0.5 seconds\n    //'data_time'=\u003e0.5,\n\n    //Heartbeat time,default 30 seconds\n    //'ping_time'=\u003e30,\n\n    //Number of messages WS queue shuold hold, default 100\n    //'queue_count'=\u003e100,\n\n    //私有数据队列默认保存100条\n    //'queue_count'=\u003e100,\n\n    //baseurl host\n    //'baseurl'=\u003e'ws://www.bitmex.com/realtime',//default\n    //'baseurl'=\u003e'ws://testnet.bitmex.com/realtime',//test\n]);\n```\n\nSubscribe\n```php\n//You can only subscribe to public channels\n$bitmex-\u003esubscribe([\n    //public\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n]);\n\n//You can also subscribe to both private and public channels.If keysecret() is set, all private channels will be subscribed by default\n$bitmex-\u003ekeysecret([\n    'key'=\u003e'xxxxxxxxx',\n    'secret'=\u003e'xxxxxxxxx',\n]);\n$bitmex-\u003esubscribe([\n    //public\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n\n    //private\n    \"affiliate\",\n    \"execution\",\n    \"order\",\n    \"margin\",\n    \"position\",\n    \"privateNotifications\",\n    \"transact\",\n    \"wallet\"\n]);\n```\n\nUnsubscribe\n```php\n//Unsubscribe from public channels\n$bitmex-\u003eunsubscribe([\n    //public\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n]);\n\n//Unsubscribe from public and private channels.If keysecret() is set, private channels will be Unsubscribed by default\n$bitmex-\u003ekeysecret([\n    'key'=\u003e'xxxxxxxxx',\n    'secret'=\u003e'xxxxxxxxx',\n]);\n$bitmex-\u003eunsubscribe([\n    //public\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n\n    //private\n    \"affiliate\",\n    \"execution\",\n    \"order\",\n    \"margin\",\n    \"position\",\n    \"privateNotifications\",\n    \"transact\",\n    \"wallet\"\n]);\n```\n\nGet all channel subscription data\n```php\n//The first way\n$data=$bitmex-\u003egetSubscribe();\nprint_r(json_encode($data));\n\n//The second way callback\n$bitmex-\u003egetSubscribe(function($data){\n    print_r(json_encode($data));\n});\n\n//The third way is to guard the process\n$bitmex-\u003egetSubscribe(function($data){\n    print_r(json_encode($data));\n},true);\n```\n\nGet partial channel subscription data\n```php\n//The first way\n$data=$bitmex-\u003egetSubscribe([\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n]);\nprint_r(json_encode($data));\n\n//The second way callback\n$bitmex-\u003egetSubscribe([\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n],function($data){\n    print_r(json_encode($data));\n});\n\n//The third way is to guard the process\n$bitmex-\u003egetSubscribe([\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n],function($data){\n    print_r(json_encode($data));\n},true);\n```\n\nGet partial private channel subscription data\n```php\n//The first way\n$bitmex-\u003ekeysecret($key_secret);\n$data=$bitmex-\u003egetSubscribe();//Return all data of private channel\nprint_r(json_encode($data));\n\n//The second way callback\n$bitmex-\u003ekeysecret($key_secret);\n$bitmex-\u003egetSubscribe([//Return data private and market \n    //public\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n\n    //private\n    \"affiliate\",\n    \"execution\",\n    \"order\",\n    \"margin\",\n    \"position\",\n    \"privateNotifications\",\n    \"transact\",\n    \"wallet\"\n],function($data){\n    print_r(json_encode($data));\n});\n\n//The third way is to guard the process\n$bitmex-\u003ekeysecret($key_secret);\n$bitmex-\u003egetSubscribe([//Resident process to get data return frequency $bitmex-\u003econfig['data_time']=0.5s\n    //public\n    'orderBook10:XBTUSD',\n    'quoteBin5m:XBTUSD',\n\n    //private\n    \"affiliate\",\n    \"execution\",\n    \"order\",\n    \"margin\",\n    \"position\",\n    \"privateNotifications\",\n    \"transact\",\n    \"wallet\"\n],function($data){\n    print_r(json_encode($data));\n},true);\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhouaini528%2Fbitmex-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhouaini528%2Fbitmex-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhouaini528%2Fbitmex-php/lists"}