Skip to main content

ActivityType

Comprehensive enum of Strava activity types with categorization and matching logic.

Enum Cases

Foot Sports

run
String
Raw value: “Run”
trailRun
String
Raw value: “TrailRun”
walk
String
Raw value: “Walk”
hike
String
Raw value: “Hike”
wheelchair
String
Raw value: “Wheelchair”
virtualRun
String
Raw value: “VirtualRun”

Cycling

ride
String
Raw value: “Ride”
mountainBikeRide
String
Raw value: “MountainBikeRide”
gravelRide
String
Raw value: “GravelRide”
eBikeRide
String
Raw value: “EBikeRide”
eMountainBikeRide
String
Raw value: “EMountainBikeRide”
velomobile
String
Raw value: “Velomobile”
handcycle
String
Raw value: “Handcycle”
virtualRide
String
Raw value: “VirtualRide”

Water Sports

swim
String
Raw value: “Swim”
rowing
String
Raw value: “Rowing”
kayaking
String
Raw value: “Kayaking”
canoeing
String
Raw value: “Canoeing”
standUpPaddling
String
Raw value: “StandUpPaddling”
surfing
String
Raw value: “Surfing”
kitesurf
String
Raw value: “Kitesurf”
windsurf
String
Raw value: “Windsurf”
sail
String
Raw value: “Sail”

Winter Sports

alpineSki
String
Raw value: “AlpineSki”
backcountrySki
String
Raw value: “BackcountrySki”
nordicSki
String
Raw value: “NordicSki”
snowboard
String
Raw value: “Snowboard”
snowshoe
String
Raw value: “Snowshoe”
iceSkate
String
Raw value: “IceSkate”

Other Sports

inlineSkate
String
Raw value: “InlineSkate”
rollerSki
String
Raw value: “RollerSki”
skateboard
String
Raw value: “Skateboard”
soccer
String
Raw value: “Soccer”
tennis
String
Raw value: “Tennis”
padel
String
Raw value: “Padel”
racquetball
String
Raw value: “Racquetball”
squash
String
Raw value: “Squash”
badminton
String
Raw value: “Badminton”
pickleball
String
Raw value: “Pickleball”
tableTennis
String
Raw value: “TableTennis”
basketball
String
Raw value: “Basketball”
volleyball
String
Raw value: “Volleyball”
cricket
String
Raw value: “Cricket”
dance
String
Raw value: “Dance”
golf
String
Raw value: “Golf”
elliptical
String
Raw value: “Elliptical”

Properties

defaultSelected

public static let defaultSelected: Set<ActivityType> = [
    .run, .ride, .walk, .trailRun, .hike, .wheelchair
]
Default set of activity types selected for filtering.

displayName

var displayName: String { get }
Human-readable display name for the activity type.
ActivityType.run.displayName // "Run"
ActivityType.mountainBikeRide.displayName // "Mountain Bike Ride"
ActivityType.standUpPaddling.displayName // "Stand Up Paddling"

matchingValues

var matchingValues: Set<String> { get }
Set of normalized Strava API values that match this activity type. Values are lowercased with underscores removed.
ActivityType.run.matchingValues // ["run"]
ActivityType.rowing.matchingValues // ["rowing", "virtualrow"]

category

var category: Category { get }
The sport category this activity type belongs to.
ActivityType.run.category // .foot
ActivityType.mountainBikeRide.category // .cycle
ActivityType.swim.category // .water

Methods

matches(type:sportType:)

public func matches(type: String, sportType: String) -> Bool
Matches against a Strava activity’s type and sportType fields. Prefers sportType (more specific) when available, falls back to type.
let activityType = ActivityType.run
activityType.matches(type: "Run", sportType: "Trail_Run") // false

let trailRun = ActivityType.trailRun
trailRun.matches(type: "Run", sportType: "Trail_Run") // true

defaultsValue(for:)

public static func defaultsValue(for selection: [ActivityType]) -> [String]
Converts a selection to raw string values for storage. Returns defaultSelected if selection is empty.
let values = ActivityType.defaultsValue(for: [.run, .ride])
// ["Run", "Ride"]

let defaultValues = ActivityType.defaultsValue(for: [])
// ["Run", "Ride", "Walk", "TrailRun", "Hike", "Wheelchair"]

grouped()

public static func grouped() -> [(category: Category, types: [ActivityType])]
Returns all activity types grouped by category.
let grouped = ActivityType.grouped()
for (category, types) in grouped {
    print("\(category.rawValue): \(types.count) types")
}

Category

Nested enum representing sport categories.

Cases

foot
String
Raw value: “Foot Sports”Icon: “figure.run”
cycle
String
Raw value: “Cycling”Icon: “figure.outdoor.cycle”
water
String
Raw value: “Water Sports”Icon: “figure.pool.swim”
winter
String
Raw value: “Winter Sports”Icon: “snowflake”
other
String
Raw value: “Other Sports”Icon: “sportscourt”

Example Usage

// Filter activities by type
let activities: [StravaActivity] = loadActivities()
let runningActivities = activities.filter { activity in
    ActivityType.run.matches(
        type: activity.type,
        sportType: activity.sportType
    )
}

// Display grouped activity types
let grouped = ActivityType.grouped()
for (category, types) in grouped {
    print(category.icon, category.rawValue)
    for type in types {
        print("  - \(type.displayName)")
    }
}

// Check if activity matches any foot sport
let footTypes: [ActivityType] = ActivityType.allCases.filter { $0.category == .foot }
let isFootSport = footTypes.contains { type in
    type.matches(type: activity.type, sportType: activity.sportType)
}

Conformances

  • String raw value
  • CaseIterable
  • Codable
  • Hashable
  • Sendable

Build docs developers (and LLMs) love