Operations: How to Get Time Series


Get a single time series' entries using GetTimeSeriesOperation.
Get multiple time series' entries using GetMultipleTimeSeriesOperation.


GetTimeSeriesOperation

Use GetTimeSeriesOperation to retrieve entries from a single time series.


Syntax

  • Definition

    public GetTimeSeriesOperation(string docId, string timeseries, DateTime? @from = null, 
        DateTime? to = null, int start = 0, int pageSize = int.MaxValue)
  • Parameters

    Parameters Type Description
    docId string Document ID
    timeseries string Time series name
    from (optional) DateTime? Range start
    Default: DateTime.Min
    to (optional) DateTime? Range end
    Default: DateTime.Max
    start int Start of first Page
    pageSize int Size of each page
  • Return Value: TimeSeriesRangeResult

    public class TimeSeriesRangeResult
    {
        public DateTime From, To;
        public TimeSeriesEntry[] Entries;
        public long? TotalResults;
    
        //..
    }
    • Requesting a time series that doesn't exist will return null.
    • Requesting an entries range that doesn't exist will return a TimeSeriesRangeResult object with an empty Entries property.
  • Exceptions
    Exceptions are not generated.


Usage Flow

  • Pass GetTimeSeriesOperation -
    Document ID, Time Series Name, Range Start, Range End.
  • Call store.Operations.Send to execute the operation.
  • Entries are returned into a dictionary ofTimeSeriesRangeResult` classes.

Usage Sample

  • In this sample, we retrieve all the entries of a time series.
    // Get all values of a single time-series
    TimeSeriesRangeResult singleTimeSeriesDetails = store.Operations.Send(
        new GetTimeSeriesOperation(documentId, "HeartRates", DateTime.MinValue, DateTime.MaxValue));

GetMultipleTimeSeriesOperation

Use GetMultipleTimeSeriesOperation to retrieve data from multiple time series.


Syntax

  • Definition

    public GetMultipleTimeSeriesOperation(string docId, 
        IEnumerable<TimeSeriesRange> ranges, int start = 0, int pageSize = int.MaxValue)
  • Parameters

    Parameters Type Description
    docId string Document ID
    ranges IEnumerable<TimeSeriesRange> Ranges of Time Series Entries
    start (optional) int Start of first Page
    Default: 0
    pageSize (optional) int Size of each page
    Default: int.MaxValue

    Pass GetMultipleTimeSeriesOperation a TimeSeriesRange instance For each entries range you want it to retrieve.

    public class TimeSeriesRange
    {
        public string Name;
        public DateTime From, To;
    }
  • Return Value: TimeSeriesRangeResult

    public class TimeSeriesDetails
    {
        public string Id { get; set; }
        public Dictionary<string, List<TimeSeriesRangeResult>> Values { get; set; }
    }
    public class TimeSeriesRangeResult
    {
        public DateTime From, To;
        public TimeSeriesEntry[] Entries;
        public long? TotalResults;
    
        //..
    }
    • When a time series or an entries range that do not exist are requested, the return value for the erroneous range is a TimeSeriesRangeResult object with an empty Entries property.
  • Exceptions
    Exceptions are not generated.


Usage Flow

  • Pass GetMultipleTimeSeriesOperation -
    • The time series parent-Document ID
    • A TimeSeriesRange instance for each entries range you want it to retrieve.
  • Populate each TimeSeriesRange instance with a time Series name, a range start timestamp (From), and a range end timestamp (To).
  • Call store.Operations.Send to execute the operation.

Usage Sample

  • In this sample, we retrieve chosen entries from two time series.
    // Get value ranges from two time-series using GetMultipleTimeSeriesOperation
    TimeSeriesDetails multipleTimesSeriesDetails = store.Operations.Send(
            new GetMultipleTimeSeriesOperation(documentId, new List<TimeSeriesRange>
                {
                    new TimeSeriesRange
                    {
                        Name = "ExerciseHeartRate",
                        From = baseTime.AddHours(1),
                        To = baseTime.AddHours(10)
                    },
    
                    new TimeSeriesRange
                    {
                        Name = "RestHeartRate",
                        From = baseTime.AddHours(11),
                        To = baseTime.AddHours(20)
                    }
                }));