Skip to content

Commit 8e38b81

Browse files
committed
FIX: Use POST for metadata endpoints with symbols
1 parent 3b22eed commit 8e38b81

File tree

3 files changed

+45
-43
lines changed

3 files changed

+45
-43
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
### Enhancements
99
- Added new dataset `EQUS.MINI` and new publishers `EQUS.MINI.EQUS`, `XNYS.TRADES.EQUS`
1010

11+
### Bug fixes
12+
- Changed historical metadata methods with `symbols` parameter to use a `POST` request
13+
to allow for requesting supported maximum of 2000 symbols
14+
1115
## 0.27.0 - 2025-01-07
1216

1317
### Breaking changes

src/historical.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <cstddef> // size_t
1010
#include <cstdlib> // get_env
1111
#include <exception> // exception, exception_ptr
12-
#include <fstream> // ofstream
13-
#include <ios> // ios::binary
1412
#include <iterator> // back_inserter
1513
#include <memory> // unique_ptr
1614
#include <string>
@@ -604,7 +602,7 @@ std::uint64_t Historical::MetadataGetRecordCount(
604602
std::uint64_t Historical::MetadataGetRecordCount(
605603
const httplib::Params& params) {
606604
static const std::string kPath = ::BuildMetadataPath(".get_record_count");
607-
const nlohmann::json json = client_.GetJson(kPath, params);
605+
const nlohmann::json json = client_.PostJson(kPath, params);
608606
if (!json.is_number_unsigned()) {
609607
throw JsonResponseError::TypeMismatch("Historical::MetadataGetRecordCount",
610608
"unsigned number", json);
@@ -661,7 +659,7 @@ std::uint64_t Historical::MetadataGetBillableSize(
661659
std::uint64_t Historical::MetadataGetBillableSize(
662660
const httplib::Params& params) {
663661
static const std::string kPath = ::BuildMetadataPath(".get_billable_size");
664-
const nlohmann::json json = client_.GetJson(kPath, params);
662+
const nlohmann::json json = client_.PostJson(kPath, params);
665663
if (!json.is_number_unsigned()) {
666664
throw JsonResponseError::TypeMismatch("Historical::MetadataGetBillableSize",
667665
"unsigned number", json);
@@ -722,7 +720,7 @@ double Historical::MetadataGetCost(
722720
}
723721
double Historical::MetadataGetCost(const HttplibParams& params) {
724722
static const std::string kPath = ::BuildMetadataPath(".get_cost");
725-
const nlohmann::json json = client_.GetJson(kPath, params);
723+
const nlohmann::json json = client_.PostJson(kPath, params);
726724
if (!json.is_number()) {
727725
throw JsonResponseError::TypeMismatch("Historical::MetadataGetCost",
728726
"number", json);

tests/src/historical_tests.cpp

+38-38
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,13 @@ TEST_F(HistoricalTests, TestMetadataGetDatasetRange) {
463463

464464
TEST_F(HistoricalTests, TestMetadataGetRecordCount) {
465465
const nlohmann::json kResp = 42;
466-
mock_server_.MockGetJson("/v0/metadata.get_record_count",
467-
{{"dataset", dataset::kGlbxMdp3},
468-
{"symbols", "ESZ3,ESH4"},
469-
{"start", "2020-06-06T00:00"},
470-
{"end", "2021-03-02T00:00"},
471-
{"schema", "trades"}},
472-
kResp);
466+
mock_server_.MockPostJson("/v0/metadata.get_record_count",
467+
{{"dataset", dataset::kGlbxMdp3},
468+
{"symbols", "ESZ3,ESH4"},
469+
{"start", "2020-06-06T00:00"},
470+
{"end", "2021-03-02T00:00"},
471+
{"schema", "trades"}},
472+
kResp);
473473
const auto port = mock_server_.ListenOnThread();
474474

475475
databento::Historical target{logger_.get(), kApiKey, "localhost",
@@ -482,13 +482,13 @@ TEST_F(HistoricalTests, TestMetadataGetRecordCount) {
482482

483483
TEST_F(HistoricalTests, TestMetadataGetBillableSize_Simple) {
484484
const nlohmann::json kResp = 44688;
485-
mock_server_.MockGetJson("/v0/metadata.get_billable_size",
486-
{{"dataset", dataset::kGlbxMdp3},
487-
{"start", "2020-06-06T00:00"},
488-
{"symbols", "ALL_SYMBOLS"},
489-
{"end", "2021-03-02T00:00"},
490-
{"schema", "trades"}},
491-
kResp);
485+
mock_server_.MockPostJson("/v0/metadata.get_billable_size",
486+
{{"dataset", dataset::kGlbxMdp3},
487+
{"start", "2020-06-06T00:00"},
488+
{"symbols", "ALL_SYMBOLS"},
489+
{"end", "2021-03-02T00:00"},
490+
{"schema", "trades"}},
491+
kResp);
492492
const auto port = mock_server_.ListenOnThread();
493493

494494
databento::Historical target{logger_.get(), kApiKey, "localhost",
@@ -501,14 +501,14 @@ TEST_F(HistoricalTests, TestMetadataGetBillableSize_Simple) {
501501

502502
TEST_F(HistoricalTests, TestMetadataGetBillableSize_Full) {
503503
const nlohmann::json kResp = 55238;
504-
mock_server_.MockGetJson("/v0/metadata.get_billable_size",
505-
{{"dataset", dataset::kGlbxMdp3},
506-
{"start", "2020-06-06T00:00"},
507-
{"end", "2021-03-02T00:00"},
508-
{"symbols", "NG.FUT,LNG.FUT"},
509-
{"schema", "tbbo"},
510-
{"stype_in", "parent"}},
511-
kResp);
504+
mock_server_.MockPostJson("/v0/metadata.get_billable_size",
505+
{{"dataset", dataset::kGlbxMdp3},
506+
{"start", "2020-06-06T00:00"},
507+
{"end", "2021-03-02T00:00"},
508+
{"symbols", "NG.FUT,LNG.FUT"},
509+
{"schema", "tbbo"},
510+
{"stype_in", "parent"}},
511+
kResp);
512512
const auto port = mock_server_.ListenOnThread();
513513

514514
databento::Historical target{logger_.get(), kApiKey, "localhost",
@@ -521,13 +521,13 @@ TEST_F(HistoricalTests, TestMetadataGetBillableSize_Full) {
521521

522522
TEST_F(HistoricalTests, TestMetadataGetCost_Simple) {
523523
const nlohmann::json kResp = 0.65783;
524-
mock_server_.MockGetJson("/v0/metadata.get_cost",
525-
{{"dataset", dataset::kGlbxMdp3},
526-
{"start", "2020-06-06T00:00"},
527-
{"end", "2021-03-02T00:00"},
528-
{"symbols", "MESN1,MESQ1"},
529-
{"schema", "trades"}},
530-
kResp);
524+
mock_server_.MockPostJson("/v0/metadata.get_cost",
525+
{{"dataset", dataset::kGlbxMdp3},
526+
{"start", "2020-06-06T00:00"},
527+
{"end", "2021-03-02T00:00"},
528+
{"symbols", "MESN1,MESQ1"},
529+
{"schema", "trades"}},
530+
kResp);
531531
const auto port = mock_server_.ListenOnThread();
532532

533533
databento::Historical target{logger_.get(), kApiKey, "localhost",
@@ -540,15 +540,15 @@ TEST_F(HistoricalTests, TestMetadataGetCost_Simple) {
540540

541541
TEST_F(HistoricalTests, TestMetadataGetCost_Full) {
542542
const nlohmann::json kResp = 0.714;
543-
mock_server_.MockGetJson("/v0/metadata.get_cost",
544-
{{"dataset", dataset::kGlbxMdp3},
545-
{"start", "2020-06-06T00:00"},
546-
{"end", "2021-03-02T00:00"},
547-
{"mode", "historical-streaming"},
548-
{"symbols", "MES.OPT,EW.OPT"},
549-
{"schema", "tbbo"},
550-
{"stype_in", "parent"}},
551-
kResp);
543+
mock_server_.MockPostJson("/v0/metadata.get_cost",
544+
{{"dataset", dataset::kGlbxMdp3},
545+
{"start", "2020-06-06T00:00"},
546+
{"end", "2021-03-02T00:00"},
547+
{"mode", "historical-streaming"},
548+
{"symbols", "MES.OPT,EW.OPT"},
549+
{"schema", "tbbo"},
550+
{"stype_in", "parent"}},
551+
kResp);
552552
const auto port = mock_server_.ListenOnThread();
553553

554554
databento::Historical target{logger_.get(), kApiKey, "localhost",

0 commit comments

Comments
 (0)