{"id":16690721,"url":"https://github.com/nixman/binapi","last_synced_at":"2025-05-16T06:07:56.239Z","repository":{"id":49113859,"uuid":"231896687","full_name":"niXman/binapi","owner":"niXman","description":"Binance API C++ implementation","archived":false,"fork":false,"pushed_at":"2025-01-01T11:47:54.000Z","size":697,"stargazers_count":289,"open_issues_count":10,"forks_count":97,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-08T16:06:34.812Z","etag":null,"topics":["binance","binance-api","cplusplus","cplusplus-14"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niXman.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":"2020-01-05T09:47:10.000Z","updated_at":"2025-04-07T07:27:48.000Z","dependencies_parsed_at":"2023-02-09T16:30:15.704Z","dependency_job_id":"981b87c0-c4c5-43b0-91df-9911b13c663d","html_url":"https://github.com/niXman/binapi","commit_stats":{"total_commits":87,"total_committers":6,"mean_commits":14.5,"dds":0.2068965517241379,"last_synced_commit":"38be7e4130adcbefd36012d02d52251610c95f30"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Fbinapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Fbinapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Fbinapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Fbinapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niXman","download_url":"https://codeload.github.com/niXman/binapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478193,"owners_count":22077676,"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":["binance","binance-api","cplusplus","cplusplus-14"],"created_at":"2024-10-12T16:05:05.868Z","updated_at":"2025-05-16T06:07:51.225Z","avatar_url":"https://github.com/niXman.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# binapi\nBinance API implemented in C++ for both synchronous and asynchronous way.\n\n# Donate\nBTC: 3BJKvx6LyKB2J5KgRBqst415KKmwQE5eQX\n\n# Motivation\nThis implementation has been developed as a consequence of the lack of suitable alternatives as part of my multiuser trading platform project.\n\n# REST API\n- [Test connectivity](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#test-connectivity) -\u003e `api::ping()`\n- [Check server time](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#check-server-time) -\u003e `api::time()`\n- [Exchange information](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#exchange-information) -\u003e `api::exchange_info()`\n- [Account information](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#account-information-user_data) -\u003e `api::account_info()`\n- [Order book](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book) -\u003e `api::depth()`\n- [Recent trades list](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#recent-trades-list) -\u003e `api::trades()`\n- [Aggregate trades list](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list) -\u003e `api::agg_trades()`\n- [24hr ticker price change statistics](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics) -\u003e `api::_24hrs_ticker()`\n- [Symbol price ticker](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#symbol-price-ticker) -\u003e `api::price()`\n- [New order](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade) -\u003e `api::new_order()`\n- [Query order](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#query-order-user_data) -\u003e `api::order_info()`\n- [Test new order](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#test-new-order-trade) -\u003e `api::new_test_order()`\n- [Cancel order](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#cancel-order-trade) -\u003e `api::cancel_order()`\n- [Current open orders](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#current-open-orders-user_data) -\u003e `api::open_orders()`\n- [All orders](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#all-orders-user_data) -\u003e `api::all_orders()`\n- [Account trade list](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#account-trade-list-user_data) -\u003e `api::my_trades()`\n- [Start user data stream](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#start-user-data-stream-user_stream) -\u003e `api::start_user_data_stream()`\n- [Keepalive user data stream](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#keepalive-user-data-stream-user_stream) -\u003e `api::ping_user_data_stream()`\n- [Close user data stream](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#close-user-data-stream-user_stream) -\u003e `api::close_user_data_stream()`\n\n# WebSocket API\n- [Partial Book Depth Streams](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#partial-book-depth-streams) -\u003e `websockets::part_depth()`\n- [Diff. Depth Stream](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#diff-depth-stream) -\u003e `websockets::diff_depth()`\n- [Kline/Candlestick Streams](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams) -\u003e `websockets::klines()`\n- [Trade Streams](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#trade-streams) -\u003e `websockets::trade()`\n- [Aggregate Trade Streams](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#aggregate-trade-streams) -\u003e `websockets::agg_trade()`\n- [Individual Symbol Mini Ticker Stream](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#individual-symbol-mini-ticker-stream) -\u003e `websockets::mini_ticker()`\n- [All Market Mini Tickers Stream](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#all-market-mini-tickers-stream) -\u003e `websockets::mini_tickers()`\n- [Individual Symbol Ticker Streams](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#individual-symbol-ticker-streams) -\u003e `websockets::market()`\n- [All Market Tickers Stream](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#all-market-tickers-stream) -\u003e `websockets::markets()`\n- [Individual Symbol Book Ticker Streams](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#individual-symbol-book-ticker-streams) -\u003e `websockets::book()`\n- [All Book Tickers Stream](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#all-book-tickers-stream) -\u003e `websockets::books()`\n- [User Data Streams](https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md) -\u003e `websockets::userdata()`\n\n# Implementation details\nThe project is written using C++14 and [boost](https://www.boost.org/) (at least version 1.70). [boost.beast](https://www.boost.org/doc/libs/1_73_0/libs/beast/index.html) is used to interact with the network.\n\n# Synchronous example\n```cpp\n#include \"binapi/api.hpp\"\n\n#include \u003cboost/asio/io_context.hpp\u003e\n\n#include \u003ciostream\u003e\n\nint main() {\n    const std::string pk = \"...\";\n    const std::string sk = \"...\";\n\n    boost::asio::io_context ioctx;\n    binapi::rest::api api(\n        ioctx\n        ,\"api.binance.com\"\n        ,\"443\"\n        ,pk\n        ,sk\n        ,10000 // recvWindow\n    );\n\n    auto account = api.account_info();\n    if ( !account ) {\n        std::cerr \u003c\u003c \"account info error: \" \u003c\u003c account.errmsg \u003c\u003c std::endl;\n        return EXIT_FAILURE;\n    }\n\n    std::cout \u003c\u003c \"account info: \" \u003c\u003c account.v \u003c\u003c std::endl \u003c\u003c std::endl;\n\n    return EXIT_SUCCESS;\n}\n\n```\n\n# Asynchronous example\n```cpp\n#include \"binapi/api.hpp\"\n\n#include \u003cboost/asio/io_context.hpp\u003e\n\n#include \u003ciostream\u003e\n\nint main() {\n    const std::string pk = \"...\";\n    const std::string sk = \"...\";\n\n    boost::asio::io_context ioctx;\n    binapi::rest::api api(\n        ioctx\n        ,\"api.binance.com\"\n        ,\"443\"\n        ,pk\n        ,sk\n        ,10000 // recvWindow\n    );\n\n    api.account_info([](const char *fl, int ec, std::string errmsg, binapi::rest::account_info_t res) {\n        if ( ec ) {\n            std::cerr \u003c\u003c \"account info error: fl=\" \u003c\u003c fl \u003c\u003c \", ec=\" \u003c\u003c ec \u003c\u003c \", emsg=\" \u003c\u003c errmsg \u003c\u003c std::endl;\n            return false;\n        }\n\n        std::cout \u003c\u003c \"account info: \" \u003c\u003c res \u003c\u003c std::endl;\n\n        return true;\n    });\n\n    ioctx.run();\n\n    return EXIT_SUCCESS;\n}\n```\n\n# WebSocket example\n```cpp\n#include \u003cbinapi/api.hpp\u003e\n#include \u003cbinapi/websocket.hpp\u003e\n\n#include \u003cboost/asio/io_context.hpp\u003e\n\n#include \u003ciostream\u003e\n\nint main() {\n    boost::asio::io_context ioctx;\n\n    binapi::ws::websockets ws{\n         ioctx\n        ,\"stream.binance.com\"\n        ,\"9443\"\n    };\n\n    ws.part_depth(\"BTCUSDT\",\n        [](const char *fl, int ec, std::string emsg, auto depths) {\n            if ( ec ) {\n                std::cerr \u003c\u003c \"subscribe depth error: fl=\" \u003c\u003c fl \u003c\u003c \", ec=\" \u003c\u003c ec \u003c\u003c \", emsg=\" \u003c\u003c emsg \u003c\u003c std::endl;\n\n                return false;\n            }\n\n            std::cout \u003c\u003c \"depths: \" \u003c\u003c depths \u003c\u003c std::endl;\n\n            return true;\n        }\n    );\n\n    ws.trade(\"BTCUSDT\",\n        [](const char *fl, int ec, std::string emsg, auto trades) {\n            if ( ec ) {\n                std::cerr \u003c\u003c \"subscribe trades error: fl=\" \u003c\u003c fl \u003c\u003c \", ec=\" \u003c\u003c ec \u003c\u003c \", emsg=\" \u003c\u003c emsg \u003c\u003c std::endl;\n\n                return false;\n            }\n\n            std::cout \u003c\u003c \"trades: \" \u003c\u003c trades \u003c\u003c std::endl;\n\n            return true;\n        }\n    );\n\n    ioctx.run();\n\n    return EXIT_SUCCESS;\n}\n```\n\n# Tools (will write later...)\n- filters\n- report generators\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixman%2Fbinapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnixman%2Fbinapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixman%2Fbinapi/lists"}