Skip to content

Commit 13ad9bf

Browse files
MapleMaple
authored andcommitted
code condesated, work on fluent api
1 parent 767d8f3 commit 13ad9bf

File tree

3 files changed

+197
-116
lines changed

3 files changed

+197
-116
lines changed

example.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ int main(int argc, char *argv[])
4040
string response;
4141
int errCode = 0;
4242

43-
errCode = bfxAPI.getTicker(response, "btcusd");
43+
// errCode = bfxAPI.getTicker(response, "btcusd");
4444
// errCode = bfxAPI.getStats(response, "btcusd");
4545
// errCode = bfxAPI.getFundingBook(response, "USD", 50, 50);
4646
// errCode = bfxAPI.getOrderBook(response, "btcusd", 50, 50, 1);
4747
// errCode = bfxAPI.getTrades(response, "btcusd", 0L, 50);
4848
// errCode = bfxAPI.getLends(response, "USD", 0L, 50);
49-
// errCode = bfxAPI.getSymbols(response);
49+
errCode = bfxAPI.getSymbols(response);
5050
// errCode = bfxAPI.getSymbolDetails(response);
5151

5252
cout << "Response: " << response << endl;

example2.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//////////////////////////////////////////////////////////////////////////////
2+
//
3+
// example.cpp
4+
//
5+
//
6+
// Bitfinex REST API C++ client - examples
7+
//
8+
//////////////////////////////////////////////////////////////////////////////
9+
10+
// std
11+
#include <fstream>
12+
#include <iostream>
13+
14+
// BitfinexAPI
15+
#include "BitfinexAPI.hpp"
16+
17+
18+
// namespaces
19+
using std::cout;
20+
using std::endl;
21+
using std::ifstream;
22+
using std::string;
23+
24+
25+
int main(int argc, char *argv[])
26+
{
27+
/////////////////////////////////////////////////////////////////////////
28+
// Examples
29+
// Note that default values are not mandatory. See BitfinexAPI.hpp
30+
// for details.
31+
/////////////////////////////////////////////////////////////////////////
32+
33+
/////////////////////////////////////////////////////////////////////////
34+
// GET REQUESTS - unauthenticated endpoints
35+
/////////////////////////////////////////////////////////////////////////
36+
37+
BfxAPI::BitfinexAPI bfxAPI;
38+
39+
bfxAPI.getTicker("btcusd");
40+
if (!bfxAPI.hasApiError())
41+
cout << bfxAPI.strResponse() << endl;
42+
else
43+
{
44+
// see bfxERR enum in BitfinexAPI.hpp::BitfinexAPI
45+
cout << bfxAPI.getBfxApiStatusCode() << endl;
46+
// see https://curl.haxx.se/libcurl/c/libcurl-errors.html
47+
cout << bfxAPI.getCurlStatusCode() << endl;
48+
}
49+
50+
bfxAPI.getStats("btcusd");
51+
if (!bfxAPI.hasApiError())
52+
cout << bfxAPI.strResponse() << endl;
53+
else
54+
{
55+
// see bfxERR enum in BitfinexAPI.hpp::BitfinexAPI
56+
cout << bfxAPI.getBfxApiStatusCode() << endl;
57+
// see https://curl.haxx.se/libcurl/c/libcurl-errors.html
58+
cout << bfxAPI.getCurlStatusCode() << endl;
59+
}
60+
61+
return 0;
62+
63+
}

0 commit comments

Comments
 (0)