#include #include #include #include // libcurl hands the body over in pieces: append each one to a string static size_t append(char* data, size_t size, size_t n, void* body) { static_cast(body)->append(data, size * n); return size * n; } int main() { // Read NVDA's file (one GET, no key), naming your own project std::string body; CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, "https://tickerinside.com/api/v1/sec/nvda.json"); curl_easy_setopt(curl, CURLOPT_USERAGENT, "MyProject/1.0 (+https://example.com)"); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, append); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &body); CURLcode rc = curl_easy_perform(curl); curl_easy_cleanup(curl); if (rc != CURLE_OK) { std::cerr << curl_easy_strerror(rc) << "\n"; return 1; } auto stock = nlohmann::json::parse(body); // How many funds hold it: in their issuers' own files, and in SEC filings std::cout << "NVDA held_by " << stock["held_by"].get() << " (issuer files), held_by_sec_nport " << stock["held_by_sec_nport"].get() << " (SEC filings)\n"; // holders is sorted, largest weight first: [fund, weight %, file date] for (auto& h : stock["holders"]) { std::cout << h[0].get() << " " << h[1].get() << " " << h[2].get() << "\n"; } // The line to print under any figure you quote std::cout << stock["cite_as"].get() << "\n"; }