import requests


def get_activity_streams_json(activity_id, access_token, types=None):
  """Get streams (time series) for a particular activity.

  https://developers.strava.com/docs/reference/#api-Streams-getActivityStreams

  `stravalib` implementation for reference:
  `streams = client.get_activity_streams(id)`

  Args:
    activity_id (int): Strava ID for an activity. The requested activity
      must correspond to the athlete associated with the access_token.
    access_token (str): Fresh access token for the Strava API.
    types (list(str)): `type`s of the requested activity streams.
      Default None, which will return all available streams.
  
  Returns:
    list: dicts of stream data. `stream['type']` is the field name, and
      `stream['data']` is the time series. Also includes `series_type`,
      `original_size` and `resolution`.

  """

  if types is None:
    types = ['time', 'latlng', 'distance', 'altitude', 'velocity_smooth',
             'heartrate', 'cadence', 'watts', 'temp', 'moving',
             'grade_smooth']
  fields = ','.join(types)

  # curl -X GET  \
  # "https://www.strava.com/api/v3/activities/${id}/streams/${fields}"  \
  #      -H "Authorization: Bearer ${access_token}"
  resp = requests.get(
    f'https://www.strava.com/api/v3/activities/{activity_id}/streams/{fields}',
    headers={'Authorization': f'Bearer {access_token}'}
  )

  return resp.json()