Available languages: [Python](https://databento.com/docs/api-historical/helpers/dbn-store-next-record.python.md) · [C++](https://databento.com/docs/api-historical/helpers/dbn-store-next-record.cpp.md) · [Rust](https://databento.com/docs/api-historical/helpers/dbn-store-next-record.rust.md) · [HTTP](https://databento.com/docs/api-historical/helpers/dbn-store-next-record.http.md)

Source: https://databento.com/docs/api-historical/helpers/dbn-store-next-record



### DbnStore::NextRecord

Returns the next record from the data source.

#### API method

```cpp
const Record* NextRecord();
```

#### Returns

`const Record*`

The next record.
The particular record type will depend on the `schema` in the metadata.

> **Warning**
>
> The returned reference or pointer is only valid until the next call to `NextRecord`.
> Copy the record or relevant fields to persist data across calls to `NextRecord`.

Returns `nullptr` when all records have been decoded.

#### Example usage

```cpp
#include <databento/historical.hpp>
#include <databento/record.hpp>
#include <iostream>

using namespace databento;

auto client =
    Historical::Builder().SetKey("$YOUR_API_KEY").Build();
DbnStore dbn_store = client.TimeseriesGetRangeToFile(
    "XNAS.ITCH", {"2024-06-24", "2024-06-29"}, {"META"},
    Schema::Trades, "META_20240624-20240629.dbn.zst");
while (const Record* record = dbn_store.NextRecord()) {
  const auto& trade_msg = record->Get<TradeMsg>();
  if (trade_msg.size > 100) {
    std::cout << trade_msg << '\n';
  }
}
```
#### Example response

```plaintext
TradeMsg {
    hd = RecordHeader { length = 12, rtype = mbp-0, publisher_id = 2, instrument_id = 10451, ts_event = 2024-06-24T08:01:59.771923047Z },
    price = 498.380000000,
    size = 228,
    action = Trade,
    side = Ask,
    flags = LAST | PUBLISHER_SPECIFIC (130),
    depth = 0,
    ts_recv = 2024-06-24T08:01:59.772093551Z,
    ts_in_delta = 170504,
    sequence = 383997
}
TradeMsg {
    hd = RecordHeader { length = 12, rtype = mbp-0, publisher_id = 2, instrument_id = 10451, ts_event = 2024-06-24T08:02:10.254849369Z },
    price = 498.380000000,
    size = 120,
    action = Trade,
    side = Ask,
    flags = LAST (128),
    depth = 0,
    ts_recv = 2024-06-24T08:02:10.255020595Z,
    ts_in_delta = 171226,
    sequence = 397630
}
...
```
