import requests


def get_activities_json(access_token, limit=None, page=None):
  """Get a list of activity summary dicts.

  https://developers.strava.com/docs/reference/#api-Activities-getLoggedInAthleteActivities

  `stravalib` implementation for comparison:
  `acts = client.get_activities(limit=10)`

  Args:
    access_token (str): Fresh access token for the Strava API.
    limit (int): Maximum number of activities to be returned in the summary.
      Default None, which will allow Strava API to set the default
      (30 as of this writing).

  Returns:
    list: dicts with summary data for the requested number of the
      activities associated with the athlete whose access_token is used.

  """
  # Get the most recent activities for the athlete.
  # curl -X GET `https://www.strava.com/api/v3/athlete/activities`  \
  #              (?before=&after=&page=&per_page=)
  #      -H "Authorization: Bearer [[token]]"
  # before, after, page, per_page
  data = dict()
  if limit is not None:
    data['per_page'] = limit
  
  if page is not None:
    data['page'] = page

  resp = requests.get(
    'https://www.strava.com/api/v3/athlete/activities',
    data=data,
    headers={'Authorization': f'Bearer {access_token}'}
  )

  return resp.json()