Module: Strava::Api::Endpoints::Streams

Included in:
Client
Defined in:
lib/strava/api/endpoints/streams.rb

Overview

API endpoints for Strava streams.

Streams represent the raw data of uploaded activities. They can be thought of as a collection of time series data, where each data point is sampled at a specific time or distance. Available stream types include altitude, cadence, distance, heartrate, latlng, moving, power, temp, time, and velocity.

Instance Method Summary collapse

Instance Method Details

#activity_streams(id_or_options, options = {}) ⇒ Object

Returns the given activity's streams.

Parameters:

  • id_or_options (String, Integer, Hash)

    Either an activity ID or a hash of options including :id

  • options (Hash) (defaults to: {})

    Additional options (if first parameter is an ID)

Options Hash (options):

  • :keys (Array<String>)

    Desired stream types (e.g., ['time', 'latlng', 'distance', 'altitude'])

  • :key_by_type (Boolean)

    Must be true



25
26
27
28
29
30
31
# File 'lib/strava/api/endpoints/streams.rb', line 25

def activity_streams(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  query = options.dup
  query[:key_by_type] = true unless options.key?(:key_by_type)
  query[:keys] = options[:keys].join(',') if options[:keys].is_a?(Array)
  Strava::Models::StreamSet.new(get("activities/#{id}/streams", query))
end

#segment_effort_streams(id_or_options, options = {}) ⇒ Object

Returns a set of streams for a segment effort completed by the authenticated athlete.

Parameters:

  • id_or_options (String, Integer, Hash)

    Either a segment effort ID or a hash of options including :id

  • options (Hash) (defaults to: {})

    Additional options (if first parameter is an ID)

Options Hash (options):

  • :keys (Array<String>)

    The types of streams to return

  • :key_by_type (Boolean)

    Must be true



41
42
43
44
45
46
47
# File 'lib/strava/api/endpoints/streams.rb', line 41

def segment_effort_streams(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  query = options.dup
  query[:key_by_type] = true unless options.key?(:key_by_type)
  query[:keys] = options[:keys].join(',') if options[:keys].is_a?(Array)
  Strava::Models::StreamSet.new(get("segment_efforts/#{id}/streams", query))
end

#segment_streams(id_or_options, options = {}) ⇒ Object

Returns the given segment's streams.

Parameters:

  • id_or_options (String, Integer, Hash)

    Either a segment ID or a hash of options including :id

  • options (Hash) (defaults to: {})

    Additional options (if first parameter is an ID)

Options Hash (options):

  • :keys (Array<String>)

    The types of streams to return

  • :key_by_type (Boolean)

    Must be true



57
58
59
60
61
62
63
# File 'lib/strava/api/endpoints/streams.rb', line 57

def segment_streams(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  query = options.dup
  query[:key_by_type] = true unless options.key?(:key_by_type)
  query[:keys] = options[:keys].join(',') if options[:keys].is_a?(Array)
  Strava::Models::StreamSet.new(get("segments/#{id}/streams", query))
end