Skip to content

MMquant/bfx-cpp-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bfx-cpp-api logo


Build status

Linux
lin-badge

Notice

Master branch contains new version of the client. For old version checkout legacy branch.

Synopsis

This header-only library contains class for interfacing Bitfinex REST API v1. Current version supports response JSON schema validation.

Dependencies

bfx-cpp-api depends on following external libraries/packages

How to Build'n'Run src/example.cpp

  1. Install dependencies (via apt, homebrew etc.).
  2. Clone or download bfx-api-cpp repository.
  3. Add key-secret file in bfx-api-cpp/app/doc directory. (or edit example.cpp so that it doesn't use key-secret file)
  4. Peek into self-documented <your_project_dir>/app/src/example.cpp.
  5. Build example binary
cd <your_project_dir>app/build && cmake .. && make
  1. Run example binary from <your_project_dir>app/bin
./example

How to Build'n'Run src/example.cpp in Docker container

  1. Clone or download bfx-api-cpp repository.
  2. Build docker image
cd <your_project_dir>
docker-compose build
  1. Start docker image
docker-compose up &
  1. Spawn bash
docker exec -it bfx-cpp-api_dev_1 /bin/sh
  1. Add key-secret file in /home/bfx-cpp-api/app/doc directory. (or edit example.cpp so that it doesn't use key-secret file)
cd /home/bfx-cpp-api/app/doc
echo <key> > key-secret
echo <secret> >> key-secret
  1. Build example
cd /home/bfx-cpp-api/app/build
cmake ..
make
  1. Run example binary
cd /home/bfx-cpp-api/app/bin
./example

Quick interface overview

// 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.

Change Log

  • 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.

Known issues

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.

Contribution

  1. Fork bfx-cpp-api repository.
  2. Commit to your develop branch.
  3. Create pull request from your develop branch to origin/develop branch.

No direct pull request to master branch accepted!

Author

Petr Javorik www.mmquant.net [email protected]