Documentation resources for the library and CoinGecko's API.
CoinGecko's source code follows an object.memberObject.memberObjectMethod()
code structure (with the exception of ping) like below:
#include "parentClass.h"
int main() {
parentClass object;
object.memberObject1.memberObjectMethod();
object.memberObject2.memberObjectMethod();
return 0;
}
#include "childClass1.h"
#include "childClass2.h"
class parentClass {
public:
childClass1 memberObject1;
childClass2 memberObject2;
};
All functions (except ping) return a gecko::web::response
struct upon completion. You can find the struct and its members below:
typedef struct response {
std::string text;
std::string response_code;
std::string url;
cpr::Response cURL_Object;
};
Below you can find a few quick examples using CoinGecko. For documentation regarding individual functions, refer to the appropriate folder above.
#include "gecko.h"
int main() {
// CoinGecko main class object
gecko::api coinGecko;
// check if CoinGecko API is online
if (coinGecko.ping()) {
// if online, get Bitcoin's most recent price in USD and print the JSON response
std::cout << coinGecko.simple.getPrice("bitcoin", "usd").text << std::endl;
} else {
// if offline, print offline.
std::cout << "CoinGecko offline!" << std::endl;
}
return 0;
}
#include "gecko.h"
int main() {
gecko::api coinGecko;
if (coinGecko.ping()) {
std::cout << coinGecko.events.getEvents("US", "Meetups").text << std::endl;
} else {
std::cout << "CoinGecko offline!" << std::endl;
}
return 0;
}
#include "gecko.h"
int main() {
gecko::api coinGecko;
if (coinGecko.ping()) {
std::cout << coinGecko.contract.getContractMarketHistory("ethereum", "0x4363e1485764d206b01ddc9ca121030585259f6f", "usd", "1").text << std::endl;
} else {
std::cout << "CoinGecko offline!" << std::endl;
}
return 0;
}