{"id":16153728,"url":"https://github.com/moneroexamples/btcmarkets-cpp","last_synced_at":"2025-04-30T05:20:48.710Z","repository":{"id":70343445,"uuid":"60442883","full_name":"moneroexamples/btcmarkets-cpp","owner":"moneroexamples","description":"C++ REST API library for BTCMarkets","archived":false,"fork":false,"pushed_at":"2016-08-15T23:57:02.000Z","size":76,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T13:01:47.709Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moneroexamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-06-05T04:18:44.000Z","updated_at":"2023-08-25T08:20:32.000Z","dependencies_parsed_at":"2023-02-22T23:45:11.047Z","dependency_job_id":null,"html_url":"https://github.com/moneroexamples/btcmarkets-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moneroexamples%2Fbtcmarkets-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moneroexamples%2Fbtcmarkets-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moneroexamples%2Fbtcmarkets-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moneroexamples%2Fbtcmarkets-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moneroexamples","download_url":"https://codeload.github.com/moneroexamples/btcmarkets-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645779,"owners_count":21620811,"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":[],"created_at":"2024-10-10T01:14:18.847Z","updated_at":"2025-04-30T05:20:48.691Z","avatar_url":"https://github.com/moneroexamples.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ REST API library for BTCMarkets.\n\n[BTCMarkets](https://btcmarkets.net) provides REST [API](https://github.com/BTCMarkets/API)\nto their service in number of programming languages, except C++. To\nrectify this problem, this library was created.\n\nThe library uses header only [json](https://github.com/nlohmann/json) library\nand [cpr](https://github.com/whoshuu/cpr) library as a wrapper for libcurl\nfor making get and post requests to the btcmakrets api service.\n\nFor most commands, public `api_key` and secret `private_key` are required \nfor authentication for your account. The keys are provided to you by btcmarkets\nin your [Account/API key](https://btcmarkets.net/account/apikey) section.\n\nBTCMarkets requires correct timestamps to be added to authentication\nrequests. This timestamp should be within +/- 30 seconds of their server timestamp.\nIn Linux this shouldn't be a problem. But just in case, the library has\nan option to specify timezone-offset, in seconds, if timestamp adjustments\nare required due to differences in your and the server timestamps.\n\n### Dependencies \n\n##### Ubuntu 15.10 and 16.04\n\n```bash\nsudo apt install git build-essential cmake libboost-program-options-dev libcurl4-openssl-dev libssl-dev\n```\n\n\n##### Arch Linux\n\n```bash\nsudo pacman -Sy git base-devel cmake boost curl openssl\n```\n\n### Compilation\n\n```bash\ngit clone --recursive https://github.com/moneroexamples/btcmarkets-cpp.git\n\ncd btcmarkets-cpp \u0026\u0026 mkdir build \u0026\u0026 cd build\n\ncmake ..\n\nmake\n```\n\nAfter successful compilation, `btcmarketsexamples` binary should be generated.\n\n### `btcmarketsexamples` options\n\n```bash\nbtcmarketexamples - example program showcasing using BtcMarkets C++11 RESTfull API:\n  -h [ --help ]                      produce help message\n  -a [ --api-key ] arg               btcmarkets api key\n  -p [ --private-key ] arg           private key provided by btcmarkets to you\n  -c [ --command ] arg (=tick)       api command to execute: tick, order_book, \n                                     order_history, trade_history, open_orders,\n                                     create_order, cancel_order, trades, \n                                     order_detail, account_balance\n  -t [ --trade-pair ] arg (=BTC/AUD) instrument/currency pair: BTC/AUD, \n                                     LTC/AUD, ETH/AUD,LTC/BTC, ETH/BTC, \n                                     DAO/BTC, DAO/ETH\n  --price arg                        price when making an order\n  --volume arg                       volume of the order\n  --side arg (=Bid)                  side of order: Bid, Ask\n  --type arg (=Limit)                type of the order: Market, Limit\n  --limit arg (=10)                  number of past orders to fetch\n  --since arg (=0)                   from when to fetch the past orders\n  --timestamp-offset arg (=0)        offset, in seconds, between your and \n                                     btcmarkerts timestamps\n  --order-id arg                     id number of an order to cancel or check \n                                     details\n```\n\n### Examples\n\n*Default execution: BTC/AUD tick (no authentication required)*\n```bash\n./btcmarketsexamples\n \n{\"bestAsk\":811.76,\"bestBid\":805.16,\"currency\":\"AUD\",\"instrument\":\"BTC\",\"lastPrice\":806.01,\"timestamp\":1465262979,\"volume24h\":265.19094}\n```\n\n*ETH/BTC tick (no authentication required)*\n\n```bash\n./btcmarketsexamples -t ETH/BTC\n\n{\"bestAsk\":0.02798897,\"bestBid\":0.02241987,\"currency\":\"BTC\",\"instrument\":\"ETH\",\"lastPrice\":0.02798999,\"timestamp\":1465263021,\"volume24h\":182.62025}\n```\n\n*DAO/ETH order book (no authentication required)*\n\n```bash\n./btcmarketsexamples -t DAO/ETH -c order_book\n\n{\"asks\":[[0.01,10000.0],[0.01,6334.1398],[0.0101,9938.0659],[0.0102,10000.0],[0.0105,8213.8165],[0.0115,1194.7316],[0.01175,500.0],[0.01199999,1500.0],[0.012,7648.2917],[0.012,1000.0],[0.012,490.2207],[0.0125,100.0],[0.013,9.15],[0.0145,100.0],[0.016345,987.0],[0.0177,600.0],[0.02,244.241],[0.02,1.12839],[0.02,325.8413],[0.051111,500.0],[0.060111,500.0],[0.07,500.0],[0.08299,500.0],[0.1,0.001],[0.101,100.0],[1.0129,99.0]],\"bids\":[[0.00943102,200.0],[0.00943101,100.0],[0.00943,110.0],[0.00930202,1000.0],[0.00930201,100.0],[0.00913128,1000.0],[0.00906,388.0],[0.009,5000.0],[0.008,4350.0],[0.006,10000.0],[0.005,2000.0],[0.001,0.001]],\"currency\":\"ETH\",\"instrument\":\"DAO\",\"timestamp\":1465263134}\n```\n\n\n*DAO/ETH order book (no authentication required)*\n\n```bash\n./btcmarketsexamples -t DAO/ETH -c order_book\n\n{\"asks\":[[0.01,10000.0],[0.01,6334.1398],[0.0101,9938.0659],[0.0102,10000.0],[0.0105,8213.8165],[0.0115,1194.7316],[0.01175,500.0],[0.01199999,1500.0],[0.012,7648.2917],[0.012,1000.0],[0.012,490.2207],[0.0125,100.0],[0.013,9.15],[0.0145,100.0],[0.016345,987.0],[0.0177,600.0],[0.02,244.241],[0.02,1.12839],[0.02,325.8413],[0.051111,500.0],[0.060111,500.0],[0.07,500.0],[0.08299,500.0],[0.1,0.001],[0.101,100.0],[1.0129,99.0]],\"bids\":[[0.00943102,200.0],[0.00943101,100.0],[0.00943,110.0],[0.00930202,1000.0],[0.00930201,100.0],[0.00913128,1000.0],[0.00906,388.0],[0.009,5000.0],[0.008,4350.0],[0.006,10000.0],[0.005,2000.0],[0.001,0.001]],\"currency\":\"ETH\",\"instrument\":\"DAO\",\"timestamp\":1465263134}\n```\n\n\n*Recent LTC/AUD trades (no authentication required)*\n\nOnly part of the result shown.\n\n```bash\n./btcmarketsexamples -t LTC/AUD -c trades\n\n[{\"amount\":83.627615,\"date\":1465265085,\"price\":6.67,\"tid\":102659907},{\"amount\":20.0,\"date\":1465265085,\"price\":6.68,\"tid\":102659896},{\"amount\":0.01485992,\"date\":1465212487,\"price\":6.66,\"tid\":102533229},{\"amount\":0.01485992,\"date\":1465212382,\"price\":6.84,\"tid\":102533038},{\"amount\":0.20175051,\"date\":1465177962,\"price\":6.66,\"tid\":102385472},{\"amount\":5.0,\"date\":1465039217,\"price\":7.0,\"tid\":101896247},{\"amount\":4.327,\"date\":1465039027,\"price\":6.99,\"tid\":101895354},{\"amount\":4.327,\"date\":1465038961,\"price\":6.6,\"tid\":101894843},{\"amount\":2.0,\"date\":1465038961,\"price\":6.6,\"tid\":101894831},{\"amount\":1.0,\"date\":1465038961,\"price\":6.61,\"tid\":101894820},{\"amount\":2.673,\"date\":1465038961,\"price\":6.71,\"tid\":101894809},{\"amount\":14.1,\"date\":1465029497,\"price\":7.0,\"tid\":101871393},{\"amount\":3.2655605,\"date\":1465027433,\"price\":7.0,\"tid\":101869010},\n```\n\nAlso can limit number of recent trends, by providing trade id to start from.\n\n```bash\n./btcmarketsexamples -c trades -t LTC/AUD --since 101894809\n\n[{\"amount\":83.627615,\"date\":1465265085,\"price\":6.67,\"tid\":102659907},{\"amount\":20.0,\"date\":1465265085,\"price\":6.68,\"tid\":102659896},{\"amount\":0.01485992,\"date\":1465212487,\"price\":6.66,\"tid\":102533229},{\"amount\":0.01485992,\"date\":1465212382,\"price\":6.84,\"tid\":102533038},{\"amount\":0.20175051,\"date\":1465177962,\"price\":6.66,\"tid\":102385472},{\"amount\":5.0,\"date\":1465039217,\"price\":7.0,\"tid\":101896247},{\"amount\":4.327,\"date\":1465039027,\"price\":6.99,\"tid\":101895354},{\"amount\":4.327,\"date\":1465038961,\"price\":6.6,\"tid\":101894843},{\"amount\":2.0,\"date\":1465038961,\"price\":6.6,\"tid\":101894831},{\"amount\":1.0,\"date\":1465038961,\"price\":6.61,\"tid\":101894820}]\n```\n\n*Account balance (authentication required)*\n\nValues in the example output were replaced with dummy values for privacy reasons.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c account_balance\n\n[{\"balance\":1224253326293,\"currency\":\"AUD\",\"pendingFunds\":66969936000},{\"balance\":0,\"currency\":\"USD\",\"pendingFunds\":0},{\"balance\":7652697853,\"currency\":\"BTC\",\"pendingFunds\":1378776555},{\"balance\":146034433752,\"currency\":\"LTC\",\"pendingFunds\":3354855481197},{\"balance\":943372,\"currency\":\"ETH\",\"pendingFunds\":4543243520},{\"balance\":0,\"currency\":\"FCT\",\"pendingFunds\":0},{\"balance\":0,\"currency\":\"MAID\",\"pendingFunds\":0},{\"balance\":1736535933,\"currency\":\"DAO\",\"pendingFunds\":2066000000}]\n```\n\n*Create order (authentication required)*\n\nA Bid(default) and Limit (default) order to buy 1 ETH for 18.17 AUD.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c create_order -t ETH/AUD --price 19.17 --volume 1\n\n{\"clientRequestId\":\"1\",\"errorCode\":null,\"errorMessage\":null,\"id\":102661890,\"success\":true}\n```\n\nAn Ask and Limit (default) order to sell 1.5 ETH for 20.01 AUD.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c create_order -t ETH/AUD --price 20.01 --volume 1.5 --side Ask\n\n{\"clientRequestId\":\"1\",\"errorCode\":null,\"errorMessage\":null,\"id\":102662870,\"success\":true}\n```\n\nAn Ask and Market order to sell 10 DAO using ETH.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c create_order -t DAO/ETH --volume 10.0 --side Ask --type Market\n\n{\"clientRequestId\":\"1\",\"errorCode\":null,\"errorMessage\":null,\"id\":102668298,\"success\":true}\n```\n\n*Cancel order (authentication required)*\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c cancel_order --order-id 102662870\n\n{\"errorCode\":null,\"errorMessage\":null,\"responses\":[{\"errorCode\":null,\"errorMessage\":null,\"id\":102662870,\"success\":true}],\"success\":true}\n```\n\n*Order details (authentication required)*\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c order_detail --order-id 102510625\n\n{\"errorCode\":null,\"errorMessage\":null,\"orders\":[{\"clientRequestId\":null,\"creationTime\":1465206394338,\"currency\":\"BTC\",\"errorMessage\":null,\"id\":102510625,\"instrument\":\"ETH\",\"openVolume\":100000000,\"orderSide\":\"Bid\",\"ordertype\":\"Limit\",\"price\":2241987,\"status\":\"Placed\",\"trades\":[],\"volume\":100000000}],\"success\":true}\n```\n\n\n\n*Order history (authentication required)*\n\nShow last two orders of to buy ETH using AUD.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c order_history -t ETH/AUD --limit 2 \n\n{\"errorCode\":null,\"errorMessage\":null,\"orders\":[{\"clientRequestId\":null,\"creationTime\":1465287752319,\"currency\":\"AUD\",\"errorMessage\":null,\"id\":102800357,\"instrument\":\"ETH\",\"openVolume\":60000000,\"orderSide\":\"Bid\",\"ordertype\":\"Limit\",\"price\":1925000000,\"status\":\"Cancelled\",\"trades\":[],\"volume\":60000000},{\"clientRequestId\":null,\"creationTime\":1465287783251,\"currency\":\"AUD\",\"errorMessage\":null,\"id\":102800414,\"instrument\":\"ETH\",\"openVolume\":200000000,\"orderSide\":\"Bid\",\"ordertype\":\"Limit\",\"price\":1926000000,\"status\":\"Cancelled\",\"trades\":[],\"volume\":200000000}],\"success\":true}\n\n```\n\n\n*Open orders (authentication required)*\n\nShow last open orders of to buy ETH using BTC.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c order_history -t ETH/BTC --limit 1 \n\n{\"errorCode\":null,\"errorMessage\":null,\"orders\":[{\"clientRequestId\":null,\"creationTime\":1465289102761,\"currency\":\"BTC\",\"errorMessage\":null,\"id\":102803735,\"instrument\":\"ETH\",\"openVolume\":100000000,\"orderSide\":\"Bid\",\"ordertype\":\"Limit\",\"price\":2245882,\"status\":\"Placed\",\"trades\":[],\"volume\":100000000}],\"success\":true}\n```\n\n\n*Trades history (authentication required)*\n\nShow last trade to buy DAO using ETH.\n\n```bash\n./btcmarketsexamples -a public_api_key -p secret_private_key -c trade_history -t DAO/ETH --limit 1 \n\n{\"errorCode\":null,\"errorMessage\":null,\"success\":true,\"trades\":[{\"creationTime\":1465266880437,\"description\":null,\"fee\":2200000,\"id\":102669490,\"price\":1000000,\"side\":\"Bid\",\"volume\":1000000000}]}[\n```\n\n\n\n## How can you help?\n\nConstructive criticism, code and website edits are always good. They can be made through github.\n\nSome Monero are also welcome:\n```\n48daf1rG3hE1Txapcsxh6WXNe9MLNKtu7W7tKTivtSoVLHErYzvdcpea2nSTgGkz66RFP4GKVAsTV14v6G3oddBTHfxP6tU\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoneroexamples%2Fbtcmarkets-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoneroexamples%2Fbtcmarkets-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoneroexamples%2Fbtcmarkets-cpp/lists"}