Table of Contents

Class MetadataClient

Namespace
DatabentoDotNet.Historical
Assembly
DatabentoDotNet.Historical.dll

The metadata.* endpoints: what a dataset holds, and what a request for it would cost.

public sealed class MetadataClient
Inheritance
MetadataClient
Inherited Members

Examples

// What exists, and over what range. Both free.
IReadOnlyList<string> datasets = await client.Metadata.ListDatasetsAsync();
DatasetRange range = await client.Metadata.GetDatasetRangeAsync("GLBX.MDP3");

var query = new MetadataQueryParams
{
    Dataset = "GLBX.MDP3",
    Symbols = Symbols.From("ESH4"),
    Schema = Schema.Trades,
    DateTimeRange = DateRange.OnDay(new LocalDate(2024, 1, 2)).ToDateTimeRange(),
};

// What it would cost, before anything moves. Also free — and GetRangeParams.ToQuery() renders
// this same type for a request you already have, so the two cannot drift apart.
ulong records = await client.Metadata.GetRecordCountAsync(query);
ulong bytes = await client.Metadata.GetBillableSizeAsync(query);
decimal usd = await client.Metadata.GetCostAsync(query);

Console.WriteLine($"{records} records, {bytes} billable bytes, ${usd}");

Remarks

Reached through Metadata rather than constructed. Port of upstream's MetadataClient (databento-rs/src/historical/metadata.rs:20-23), which borrows the outer client; here it holds a reference, since there is no borrow checker to satisfy and the lifetime is the outer client's either way.

Call GetCostAsync(MetadataQueryParams, CancellationToken) before spending anything. It is the endpoint most callers want first: it answers, in dollars and before any data moves, what a timeseries.get_range for the same parameters would cost — and MetadataQueryParams is deliberately the same type both take, so the request you priced is the request you send.

Methods

GetBillableSizeAsync(MetadataQueryParams, CancellationToken)

Gets the billable uncompressed raw binary size, in bytes, a request over the given parameters would return — for historical streaming or a batch download.

public Task<ulong> GetBillableSizeAsync(MetadataQueryParams parameters, CancellationToken cancellationToken = default)

Parameters

parameters MetadataQueryParams

The request to size.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<ulong>

The uncompressed size, in bytes, the request would return.

Remarks

Port of upstream's get_billable_size (metadata.rs:174-181).

Exceptions

ArgumentNullException

parameters is null.

GetCostAsync(MetadataQueryParams, CancellationToken)

Gets the cost, in US dollars, of a historical streaming or batch download request over the given parameters. Reflects any discount a flat-rate plan applies.

public Task<decimal> GetCostAsync(MetadataQueryParams parameters, CancellationToken cancellationToken = default)

Parameters

parameters MetadataQueryParams

The request to price.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<decimal>

The cost, in US dollars.

Remarks

Port of upstream's get_cost (metadata.rs:190-194). Returns decimal where upstream returns f64 (metadata.rs:190): upstream returns a binary float only because Rust's std has no decimal type, and a price rendered through binary floating point is a money bug waiting for a large enough range. See the class remarks for why this is the endpoint to call first.

Exceptions

ArgumentNullException

parameters is null.

GetDatasetConditionAsync(GetDatasetConditionParams, CancellationToken)

Reports data availability and quality for a dataset.

public Task<IReadOnlyList<DatasetConditionDetail>> GetDatasetConditionAsync(GetDatasetConditionParams parameters, CancellationToken cancellationToken = default)

Parameters

parameters GetDatasetConditionParams

The dataset, and an optional UTC date range to report on.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<IReadOnlyList<DatasetConditionDetail>>

One entry for every date in the requested range, including a date with no data at all — n entries for a range of n days, since DateRange keeps this library's half-open contract even though the endpoint's own end_date is inclusive. That property documents the conversion and why it is here.

Remarks

Port of upstream's get_dataset_condition (metadata.rs:121-133).

Exceptions

ArgumentNullException

parameters is null.

GetDatasetRangeAsync(string, CancellationToken)

Gets the available range for a dataset, given the caller's entitlements.

public Task<DatasetRange> GetDatasetRangeAsync(string dataset, CancellationToken cancellationToken = default)

Parameters

dataset string

The dataset code, for example XNAS.ITCH.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<DatasetRange>

The dataset's overall available range, and the narrower range each individual schema has data for.

Remarks

Port of upstream's get_dataset_range (metadata.rs:143-153). Unlike the other six endpoints in this file, the response is a single object rather than a list, so this calls SendJsonAsync<T>(HttpMethod, string, IEnumerable<KeyValuePair<string, string>>?, JsonTypeInfo<T>, CancellationToken) directly instead of going through GetAsync<T>(string, IEnumerable<KeyValuePair<string, string>>, JsonTypeInfo<List<T>>, CancellationToken).

Exceptions

ArgumentException

dataset is null or empty.

GetRecordCountAsync(MetadataQueryParams, CancellationToken)

Gets the record count a request over the given parameters would return.

public Task<ulong> GetRecordCountAsync(MetadataQueryParams parameters, CancellationToken cancellationToken = default)

Parameters

parameters MetadataQueryParams

The request to count records for.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<ulong>

The number of records the request would return.

Remarks

Port of upstream's get_record_count (metadata.rs:161-165).

Exceptions

ArgumentNullException

parameters is null.

ListDatasetsAsync(DateRange?, CancellationToken)

Lists every dataset code Databento currently defines.

public Task<IReadOnlyList<string>> ListDatasetsAsync(DateRange? dateRange = null, CancellationToken cancellationToken = default)

Parameters

dateRange DateRange?

The UTC date range to list datasets available within, or null to list every dataset regardless of when it became available.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<IReadOnlyList<string>>

Every matching dataset code, for example GLBX.MDP3.

Remarks

Port of upstream's list_datasets (metadata.rs:41-51). When dateRange is null, this sends no query string at all — not an empty start_date — matching upstream's own branch, which only calls add_to_query when a range was actually given (metadata.rs:45-48).

ListFieldsAsync(ListFieldsParams, CancellationToken)

Lists the record fields for a schema and encoding.

public Task<IReadOnlyList<FieldDetail>> ListFieldsAsync(ListFieldsParams parameters, CancellationToken cancellationToken = default)

Parameters

parameters ListFieldsParams

The encoding and schema to list fields for, and an optional dataset.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<IReadOnlyList<FieldDetail>>

The fields the schema and encoding carry.

Remarks

Port of upstream's list_fields (metadata.rs:79-94).

Exceptions

ArgumentNullException

parameters is null.

ListPublishersAsync(CancellationToken)

Lists every publisher, with its dataset, venue and description.

public Task<IReadOnlyList<PublisherDetail>> ListPublishersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels the request.

Returns

Task<IReadOnlyList<PublisherDetail>>

Every publisher Databento currently defines.

Remarks

Port of upstream's list_publishers (metadata.rs:30-33). Takes no parameters.

ListSchemasAsync(string, CancellationToken)

Lists every schema available for a dataset.

public Task<IReadOnlyList<Schema>> ListSchemasAsync(string dataset, CancellationToken cancellationToken = default)

Parameters

dataset string

The dataset code, for example XNAS.ITCH.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<IReadOnlyList<Schema>>

Every schema the dataset carries.

Remarks

Port of upstream's list_schemas (metadata.rs:59-66).

Exceptions

ArgumentException

dataset is null or empty.

ListUnitPricesAsync(string, CancellationToken)

Lists unit prices for each data schema and feed mode, in US dollars per gigabyte.

public Task<IReadOnlyList<UnitPricesForMode>> ListUnitPricesAsync(string dataset, CancellationToken cancellationToken = default)

Parameters

dataset string

The dataset code, for example XNAS.ITCH.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<IReadOnlyList<UnitPricesForMode>>

One entry per feed mode Databento prices separately.

Remarks

Port of upstream's list_unit_prices (metadata.rs:102-111).

Exceptions

ArgumentException

dataset is null or empty.