Linux |
---|
Master branch contains new version of the client. For old version checkout legacy branch.
This header-only library contains class for interfacing Bitfinex REST API v1. Current version supports response JSON schema validation.
bfx-cpp-api depends on following external libraries/packages
- cmake - https://cmake.org/download/
- libcrypto++ - https://www.cryptopp.com/
- libcrypto++-dev - https://www.cryptopp.com/
- curl - https://curl.haxx.se/download.html
- libcurl4-gnutls-dev or libcurl4-openssl-dev - https://curl.haxx.se/download.html
- gcc > 7.2 or C++14 compatible clang
- Install dependencies (via apt, homebrew etc.).
- Clone or download bfx-api-cpp repository.
- Add
key-secret
file inbfx-api-cpp/app/doc
directory. (or editexample.cpp
so that it doesn't usekey-secret
file) - Peek into self-documented
<your_project_dir>/app/src/example.cpp
. - Build
example
binary
cd <your_project_dir>app/build && cmake .. && make
- Run
example
binary from<your_project_dir>app/bin
./example
- Clone or download bfx-api-cpp repository.
- Build docker image
cd <your_project_dir>
docker-compose build
- Start docker image
docker-compose up &
- Spawn bash
docker exec -it bfx-cpp-api_dev_1 /bin/sh
- Add
key-secret
file in/home/bfx-cpp-api/app/doc
directory. (or editexample.cpp
so that it doesn't usekey-secret
file)
cd /home/bfx-cpp-api/app/doc
echo <key> > key-secret
echo <secret> >> key-secret
- Build example
cd /home/bfx-cpp-api/app/build
cmake ..
make
- Run
example
binary
cd /home/bfx-cpp-api/app/bin
./example
// Create API client for both authenticated and unauthenticated requests
BfxAPI::BitfinexAPI bfxAPI("accessKey", "secretKey");
// Create API client for just unauthenticated requests
BfxAPI::BitfinexAPI bfxAPI();
// Fetch data
bfxAPI.getTicker("btcusd");
// Check for errors
if (!bfxAPI.hasApiError())
{
// Get response in string
cout << bfxAPI.strResponse() << endl;
}
else
{
// Inspect errors
cout << bfxAPI.getBfxApiStatusCode() << endl;
cout << bfxAPI.getCurlStatusCode() << endl;
}
See self-explanatory src/example.cpp
for general usage and more requests.
- 2018-09-26 Using the small Docker image Alpine instead of Debian.
- 2018-09-26 Using docker-compose to build/up/down the image.
- 2018-09-26 Grouping project files inside the app folder.
- 2018-08-01 Dockerfile added. CircleCI added.
- 2018-07-24 CMakeLists.txt added. Installation instructions changed.
- 2018-07-11 Schema validation logic complete. Client currently validates public requests only.
You will not be able to compile bfx-cpp-api with GCC<7.2 due to this bug. You can use CLANG to avoid GCC bug.
- Fork
bfx-cpp-api
repository. - Commit to your develop branch.
- Create pull request from your develop branch to origin/develop branch.
No direct pull request to master branch accepted!
Petr Javorik www.mmquant.net [email protected]