Skip to main content

Get Time Series Operation

Get entries - from single time series

Example

In this example, we retrieve all entries from a single time series.

// Define the get operation
var getTimeSeriesOp = new GetTimeSeriesOperation(
"employees/1-A", // The document ID
"HeartRates", // The time series name
DateTime.MinValue, // Entries range start
DateTime.MaxValue); // Entries range end

// Execute the operation by passing it to 'Operations.Send'
TimeSeriesRangeResult timeSeriesEntries = store.Operations.Send(getTimeSeriesOp);

// Access entries
var firstEntryReturned = timeSeriesEntries.Entries[0];

Syntax

public GetTimeSeriesOperation(
string docId,
string timeseries,
DateTime? from = null,
DateTime? to = null,
int start = 0,
int pageSize = int.MaxValue,
bool returnFullResults = false)
ParameterTypeDescription
docIdstringDocument ID
timeseriesstringTime series name
fromDateTime?Get time series entries starting from this timestamp (inclusive).
Default: DateTime.MinValue
toDateTime?Get time series entries ending at this timestamp (inclusive).
Default: DateTime.MaxValue
startintThe position of the first result to retrieve (for paging)
Default: 0
pageSizeintNumber of results per page to retrieve (for paging)
Default: int.MaxValue
returnFullResultsboolThis param is only relevant when getting incremental time series data

Return Value:

public class TimeSeriesRangeResult
{
// Timestamp of first entry returned
public DateTime From;

// Timestamp of last entry returned
public DateTime To;

// The resulting entries
// Will be empty if requesting an entries range that does Not exist
public TimeSeriesEntry[] Entries;

// The number of entries returned
// Will be undefined if not all entries of this time series were returned
public long? TotalResults;
}
  • Details of class TimeSeriesEntry are listed in this syntax section.
  • If the requested time series does Not exist, the returned object will be null.
  • No exceptions are generated.

Get entries - from multiple time series

Example

In this example, we retrieve entries from the specified ranges of two time series.

// Define the get operation
var getMultipleTimeSeriesOp = new GetMultipleTimeSeriesOperation("employees/1-A",
new List<TimeSeriesRange>
{
new TimeSeriesRange
{
Name = "ExerciseHeartRates", From = baseTime.AddHours(1), To = baseTime.AddHours(10)
},
new TimeSeriesRange
{
Name = "RestHeartRates", From = baseTime.AddHours(11), To = baseTime.AddHours(20)
}
});

// Execute the operation by passing it to 'Operations.Send'
TimeSeriesDetails timesSeriesEntries = store.Operations.Send(getMultipleTimeSeriesOp);

// Access entries
var timeSeriesEntry = timesSeriesEntries.Values["ExerciseHeartRates"][0].Entries[0];

Syntax

public GetMultipleTimeSeriesOperation(
string docId,
IEnumerable<TimeSeriesRange> ranges,
int start = 0,
int pageSize = int.MaxValue,
bool returnFullResults = false)
ParameterTypeDescription
docIdstringDocument ID
rangesIEnumerable<TimeSeriesRange>Provide a TimeSeriesRange object for each time series from which you want to retrieve data
startintThe position of the first result to retrieve (for paging)
Default: 0
pageSizeintNumber of results per page to retrieve (for paging)
Default: int.MaxValue
returnFullResultsboolThis param is only relevant when getting incremental time series data
public class TimeSeriesRange
{
public string Name; // Name of time series
public DateTime From; // Get time series entries starting from this timestamp (inclusive).
public DateTime To; // Get time series entries ending at this timestamp (inclusive).
}

Return Value:

public class TimeSeriesDetails
{
// The document ID
public string Id { get; set; }

// Dictionary of time series name to the time series results
public Dictionary<string, List<TimeSeriesRangeResult>> Values { get; set; }
}
public class TimeSeriesRangeResult
{
// Timestamp of first entry returned
public DateTime From;

// Timestamp of last entry returned
public DateTime To;

// The resulting entries
// Will be empty if requesting an entries range that does Not exist
public TimeSeriesEntry[] Entries;

// The number of entries returned
// Will be undefined if not all entries of this time series were returned
public long? TotalResults;
}
  • If any of the requested time series do not exist, the returned object will be null.

  • When an entries range that does not exist are requested,
    the return value for the that range is a TimeSeriesRangeResult object with an empty Entries property.

  • No exceptions are generated.