Available languages: [Python](https://databento.com/docs/api-live/client/live-blocking-subscribe.python.md) · [C++](https://databento.com/docs/api-live/client/live-blocking-subscribe.cpp.md) · [Rust](https://databento.com/docs/api-live/client/live-blocking-subscribe.rust.md) · [Raw](https://databento.com/docs/api-live/client/live-blocking-subscribe.raw.md)

Source: https://databento.com/docs/api-live/client/live-blocking-subscribe


### LiveBlocking::Subscribe

Add a new subscription to the session.

Supports multiple subscriptions for different schemas, which enables rich data streams containing mixed record types.

Specify an optional `start` time for [intraday replay](https://databento.com/docs/api-live/basics/intraday-replay.md) with subscriptions made before starting the session.

Subscriptions end when the client disconnects in its destructor, by calling [LiveBlocking::Stop](https://databento.com/docs/api-live/client/live-blocking-stop.md), or when their symbols are removed with [LiveBlocking::Unsubscribe](https://databento.com/docs/api-live/client/live-blocking-unsubscribe.md).

#### API method

```cpp
void Subscribe(const std::vector<std::string>& symbols,
    Schema schema, SType stype_in);
void Subscribe(const std::vector<std::string>& symbols,
    Schema schema, SType stype_in, UnixNanos start);
void Subscribe(const std::vector<std::string>& symbols,
    Schema schema, SType stype_in, const std::string& start);
```

#### Parameters

| Parameter | Type | Description |
| `symbols` | std::vector\ | The product symbols to subscribe to. Takes up to 2,000 symbols per request. |
| `schema` | databento::Schema | The data record [schema](https://databento.com/docs/schemas/whats-a-schema.md). Must be one of the values from [MetadataListSchemas](https://databento.com/docs/api-historical/metadata/metadata-list-schemas.md). |
| `stype_in` | databento::SType | The [symbology type](https://databento.com/docs/api-live/basics/symbology.md) of input `symbols`. |
| `start` | databento::UnixNanos or std::string | The inclusive start of subscription replay. Filters on `ts_event` except for the CBBO and BBO schemas, which filter on `ts_recv`. Takes an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) string or a [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) in nanoseconds. Must be within the last 24 hours. Pass `UnixNanos{}` to request all available data. Cannot be specified after the [session](https://databento.com/docs/api-live/basics/sessions.md) is [started](https://databento.com/docs/api-live/client/live-blocking-start.md). |

#### Example usage

```cpp
#include <databento/live.hpp>

using namespace databento;

auto client = LiveBlocking::Builder()
                  .SetKey("$YOUR_API_KEY")
                  .SetDataset("GLBX.MDP3")
                  .BuildBlocking();
client.Subscribe({"ES.v.0"}, Schema::Trades, SType::Continuous);
client.Subscribe({"ES.v.0"}, Schema::Definition,
                 SType::Continuous);
```
