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

Source: https://databento.com/docs/api-historical/helpers/dbn-store-from-bytes


### DBNStore.from_bytes

Read data from a DBN byte stream.

#### API method

```python
DBNStore.from_bytes(
    data: BytesIO | bytes | IO[bytes],
) -> DBNStore
```

#### Parameters

| Parameter | Type | Required | Description |
| `data` | BytesIO or bytes or IO[bytes] | required | The bytes to read from. |

#### Returns

A [DBNStore](https://databento.com/docs/api-historical/helpers/dbn-store.md) object.

#### Example usage

```python
import databento as db

client = db.Historical("$YOUR_API_KEY")

data = client.timeseries.get_range(
    dataset="GLBX.MDP3",
    symbols=["ESM2"],
    schema="trades",
    start="2022-06-06",
)

# Save streamed data to .dbn.zst
path = "GLBX-ESM2-20220606.trades.dbn.zst"
data.to_file(path)

# Open saved data as a byte stream.
with open(path, "rb") as saved:
    stored_data = db.DBNStore.from_bytes(saved)

# Convert to dataframe
df = stored_data.to_df()
print(df.head())
```
#### Example response

```plaintext
                                                               ts_event  rtype  publisher_id  instrument_id action  ... size  flags  ts_in_delta  sequence  symbol
ts_recv                                                                                                             ...
2022-06-06 00:00:00.070314216+00:00 2022-06-06 00:00:00.070033767+00:00      0             1           3403      T  ...    1      0        18681    157862    ESM2
2022-06-06 00:00:00.090544076+00:00 2022-06-06 00:00:00.089830441+00:00      0             1           3403      T  ...    1      0        18604    157922    ESM2
2022-06-06 00:00:00.807324169+00:00 2022-06-06 00:00:00.807018955+00:00      0             1           3403      T  ...    4      0        18396    158072    ESM2
2022-06-06 00:00:01.317722490+00:00 2022-06-06 00:00:01.317385867+00:00      0             1           3403      T  ...    1      0        22043    158111    ESM2
2022-06-06 00:00:01.317736158+00:00 2022-06-06 00:00:01.317385867+00:00      0             1           3403      T  ...    7      0        17280    158112    ESM2

[5 rows x 13 columns]
```
