UNPKG

strava-api-client

Version:

Another implementation of the Strava API 3.0.0

708 lines (707 loc) 33.8 kB
import { IOAuthConfiguration } from "../interfaces/oauth-configuration.interface"; import { IOAuthResponse } from "../interfaces/oauth-response.interface"; import { ActivityStream } from "../enums/activity-stream.enum"; import { ActivityType } from "../enums/activity-type.enum"; import { SegmentStream } from "../enums/segment-stream.enum"; import { SportType } from "../enums/sport-type.enum"; export declare class Strava { private configuration; private static API_URL; private static readonly OAUTH_URL; private client; private authentication?; private authenticate; constructor(configuration: IOAuthConfiguration); private OAuth; oauth: { authorize: () => string; token: (code: string) => Promise<IOAuthResponse>; deauthorize: () => Promise<Response>; set: (token: string) => Promise<void>; }; athlete: { me: () => Promise<{ id?: number; } & { resource_state?: number; firstname?: string; lastname?: string; profile_medium?: string; profile?: string; city?: string; state?: string; country?: string; sex?: "M" | "F"; premium?: boolean; summit?: boolean; created_at?: string; updated_at?: string; } & { follower_count?: number; friend_count?: number; measurement_preference?: "feet" | "meters"; ftp?: number; weight?: number; clubs?: import("../../openapi/specification").components["schemas"]["SummaryClub"][]; bikes?: import("../../openapi/specification").components["schemas"]["SummaryGear"][]; shoes?: import("../../openapi/specification").components["schemas"]["SummaryGear"][]; }>; activities: (before?: number, after?: number, page?: number, per_page?: number) => Promise<({ id?: number; } & { external_id?: string; upload_id?: number; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; name?: string; distance?: number; moving_time?: number; elapsed_time?: number; total_elevation_gain?: number; elev_high?: number; elev_low?: number; type?: import("../../openapi/specification").components["schemas"]["ActivityType"]; sport_type?: import("../../openapi/specification").components["schemas"]["SportType"]; start_date?: string; start_date_local?: string; timezone?: string; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; achievement_count?: number; kudos_count?: number; comment_count?: number; athlete_count?: number; photo_count?: number; total_photo_count?: number; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; trainer?: boolean; commute?: boolean; manual?: boolean; private?: boolean; flagged?: boolean; workout_type?: number; upload_id_str?: string; average_speed?: number; max_speed?: number; has_kudoed?: boolean; hide_from_home?: boolean; gear_id?: string; kilojoules?: number; average_watts?: number; device_watts?: boolean; max_watts?: number; weighted_average_watts?: number; })[]>; clubs: (page?: number, per_page?: number) => Promise<({ id?: number; resource_state?: number; name?: string; } & { profile_medium?: string; cover_photo?: string; cover_photo_small?: string; sport_type?: "cycling" | "running" | "triathlon" | "other"; activity_types?: import("../../openapi/specification").components["schemas"]["ActivityType"][]; city?: string; state?: string; country?: string; private?: boolean; member_count?: number; featured?: boolean; verified?: boolean; url?: string; })[]>; zones: () => Promise<{ heart_rate?: import("../../openapi/specification").components["schemas"]["HeartRateZoneRanges"]; power?: import("../../openapi/specification").components["schemas"]["PowerZoneRanges"]; }>; routes: (page?: number, per_page?: number) => Promise<{ athlete?: import("../../openapi/specification").components["schemas"]["SummaryAthlete"]; description?: string; distance?: number; elevation_gain?: number; id?: number; id_str?: string; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; name?: string; private?: boolean; starred?: boolean; timestamp?: number; type?: number; sub_type?: number; created_at?: string; updated_at?: string; estimated_moving_time?: number; segments?: import("../../openapi/specification").components["schemas"]["SummarySegment"][]; waypoints?: import("../../openapi/specification").components["schemas"]["Waypoint"][]; }[]>; stats: (id: number) => Promise<{ biggest_ride_distance?: number; biggest_climb_elevation_gain?: number; recent_ride_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; recent_run_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; recent_swim_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; ytd_ride_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; ytd_run_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; ytd_swim_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; all_ride_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; all_run_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; all_swim_totals?: import("../../openapi/specification").components["schemas"]["ActivityTotal"]; }>; update: (weight: number) => Promise<{ id?: number; } & { resource_state?: number; firstname?: string; lastname?: string; profile_medium?: string; profile?: string; city?: string; state?: string; country?: string; sex?: "M" | "F"; premium?: boolean; summit?: boolean; created_at?: string; updated_at?: string; } & { follower_count?: number; friend_count?: number; measurement_preference?: "feet" | "meters"; ftp?: number; weight?: number; clubs?: import("../../openapi/specification").components["schemas"]["SummaryClub"][]; bikes?: import("../../openapi/specification").components["schemas"]["SummaryGear"][]; shoes?: import("../../openapi/specification").components["schemas"]["SummaryGear"][]; }>; }; segment: { get: (id: number) => Promise<{ id?: number; name?: string; activity_type?: "Ride" | "Run"; distance?: number; average_grade?: number; maximum_grade?: number; elevation_high?: number; elevation_low?: number; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; climb_category?: number; city?: string; state?: string; country?: string; private?: boolean; athlete_pr_effort?: import("../../openapi/specification").components["schemas"]["SummaryPRSegmentEffort"]; athlete_segment_stats?: import("../../openapi/specification").components["schemas"]["SummarySegmentEffort"]; } & { created_at?: string; updated_at?: string; total_elevation_gain?: number; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; effort_count?: number; athlete_count?: number; hazardous?: boolean; star_count?: number; }>; starred: (page?: number, per_page?: number) => Promise<{ id?: number; name?: string; activity_type?: "Ride" | "Run"; distance?: number; average_grade?: number; maximum_grade?: number; elevation_high?: number; elevation_low?: number; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; climb_category?: number; city?: string; state?: string; country?: string; private?: boolean; athlete_pr_effort?: import("../../openapi/specification").components["schemas"]["SummaryPRSegmentEffort"]; athlete_segment_stats?: import("../../openapi/specification").components["schemas"]["SummarySegmentEffort"]; }[]>; star: (id: number, starred: boolean) => Promise<{ id?: number; name?: string; activity_type?: "Ride" | "Run"; distance?: number; average_grade?: number; maximum_grade?: number; elevation_high?: number; elevation_low?: number; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; climb_category?: number; city?: string; state?: string; country?: string; private?: boolean; athlete_pr_effort?: import("../../openapi/specification").components["schemas"]["SummaryPRSegmentEffort"]; athlete_segment_stats?: import("../../openapi/specification").components["schemas"]["SummarySegmentEffort"]; } & { created_at?: string; updated_at?: string; total_elevation_gain?: number; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; effort_count?: number; athlete_count?: number; hazardous?: boolean; star_count?: number; }>; explore: (bounds: number[], activity_type?: "running" | "riding", min_cat?: number, max_cat?: number) => Promise<{ segments?: import("../../openapi/specification").components["schemas"]["ExplorerSegment"][]; }>; effort: { list: (segment_id: number, start_date_local?: string, end_date_local?: string, per_page?: number) => Promise<({ id?: number; activity_id?: number; elapsed_time?: number; start_date?: string; start_date_local?: string; distance?: number; is_kom?: boolean; } & { name?: string; activity?: import("../../openapi/specification").components["schemas"]["MetaActivity"]; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; moving_time?: number; start_index?: number; end_index?: number; average_cadence?: number; average_watts?: number; device_watts?: boolean; average_heartrate?: number; max_heartrate?: number; segment?: import("../../openapi/specification").components["schemas"]["SummarySegment"]; kom_rank?: number; pr_rank?: number; hidden?: boolean; })[]>; get: (id: number) => Promise<{ id?: number; activity_id?: number; elapsed_time?: number; start_date?: string; start_date_local?: string; distance?: number; is_kom?: boolean; } & { name?: string; activity?: import("../../openapi/specification").components["schemas"]["MetaActivity"]; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; moving_time?: number; start_index?: number; end_index?: number; average_cadence?: number; average_watts?: number; device_watts?: boolean; average_heartrate?: number; max_heartrate?: number; segment?: import("../../openapi/specification").components["schemas"]["SummarySegment"]; kom_rank?: number; pr_rank?: number; hidden?: boolean; }>; stream: (id: number, keys: SegmentStream[], key_by_type?: boolean) => Promise<{ time?: import("../../openapi/specification").components["schemas"]["TimeStream"]; distance?: import("../../openapi/specification").components["schemas"]["DistanceStream"]; latlng?: import("../../openapi/specification").components["schemas"]["LatLngStream"]; altitude?: import("../../openapi/specification").components["schemas"]["AltitudeStream"]; velocity_smooth?: import("../../openapi/specification").components["schemas"]["SmoothVelocityStream"]; heartrate?: import("../../openapi/specification").components["schemas"]["HeartrateStream"]; cadence?: import("../../openapi/specification").components["schemas"]["CadenceStream"]; watts?: import("../../openapi/specification").components["schemas"]["PowerStream"]; temp?: import("../../openapi/specification").components["schemas"]["TemperatureStream"]; moving?: import("../../openapi/specification").components["schemas"]["MovingStream"]; grade_smooth?: import("../../openapi/specification").components["schemas"]["SmoothGradeStream"]; }>; }; stream: (id: number, keys: SegmentStream[], key_by_type?: boolean) => Promise<{ time?: import("../../openapi/specification").components["schemas"]["TimeStream"]; distance?: import("../../openapi/specification").components["schemas"]["DistanceStream"]; latlng?: import("../../openapi/specification").components["schemas"]["LatLngStream"]; altitude?: import("../../openapi/specification").components["schemas"]["AltitudeStream"]; velocity_smooth?: import("../../openapi/specification").components["schemas"]["SmoothVelocityStream"]; heartrate?: import("../../openapi/specification").components["schemas"]["HeartrateStream"]; cadence?: import("../../openapi/specification").components["schemas"]["CadenceStream"]; watts?: import("../../openapi/specification").components["schemas"]["PowerStream"]; temp?: import("../../openapi/specification").components["schemas"]["TemperatureStream"]; moving?: import("../../openapi/specification").components["schemas"]["MovingStream"]; grade_smooth?: import("../../openapi/specification").components["schemas"]["SmoothGradeStream"]; }>; }; activity: { create: (name: string, sport_type: SportType, start_date_local: string, elapsed_time: number, type?: ActivityType, description?: string, distance?: number, trainer?: boolean, commute?: boolean, confidential?: boolean, flagged?: boolean, gear_id?: string) => Promise<{ id?: number; } & { external_id?: string; upload_id?: number; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; name?: string; distance?: number; moving_time?: number; elapsed_time?: number; total_elevation_gain?: number; elev_high?: number; elev_low?: number; type?: import("../../openapi/specification").components["schemas"]["ActivityType"]; sport_type?: import("../../openapi/specification").components["schemas"]["SportType"]; start_date?: string; start_date_local?: string; timezone?: string; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; achievement_count?: number; kudos_count?: number; comment_count?: number; athlete_count?: number; photo_count?: number; total_photo_count?: number; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; trainer?: boolean; commute?: boolean; manual?: boolean; private?: boolean; flagged?: boolean; workout_type?: number; upload_id_str?: string; average_speed?: number; max_speed?: number; has_kudoed?: boolean; hide_from_home?: boolean; gear_id?: string; kilojoules?: number; average_watts?: number; device_watts?: boolean; max_watts?: number; weighted_average_watts?: number; } & { description?: string; photos?: import("../../openapi/specification").components["schemas"]["PhotosSummary"]; gear?: import("../../openapi/specification").components["schemas"]["SummaryGear"]; calories?: number; segment_efforts?: import("../../openapi/specification").components["schemas"]["DetailedSegmentEffort"][]; device_name?: string; embed_token?: string; splits_metric?: import("../../openapi/specification").components["schemas"]["Split"][]; splits_standard?: import("../../openapi/specification").components["schemas"]["Split"][]; laps?: import("../../openapi/specification").components["schemas"]["Lap"][]; best_efforts?: import("../../openapi/specification").components["schemas"]["DetailedSegmentEffort"][]; }>; get: (id: number, include_all_efforts?: boolean) => Promise<{ id?: number; } & { external_id?: string; upload_id?: number; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; name?: string; distance?: number; moving_time?: number; elapsed_time?: number; total_elevation_gain?: number; elev_high?: number; elev_low?: number; type?: import("../../openapi/specification").components["schemas"]["ActivityType"]; sport_type?: import("../../openapi/specification").components["schemas"]["SportType"]; start_date?: string; start_date_local?: string; timezone?: string; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; achievement_count?: number; kudos_count?: number; comment_count?: number; athlete_count?: number; photo_count?: number; total_photo_count?: number; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; trainer?: boolean; commute?: boolean; manual?: boolean; private?: boolean; flagged?: boolean; workout_type?: number; upload_id_str?: string; average_speed?: number; max_speed?: number; has_kudoed?: boolean; hide_from_home?: boolean; gear_id?: string; kilojoules?: number; average_watts?: number; device_watts?: boolean; max_watts?: number; weighted_average_watts?: number; } & { description?: string; photos?: import("../../openapi/specification").components["schemas"]["PhotosSummary"]; gear?: import("../../openapi/specification").components["schemas"]["SummaryGear"]; calories?: number; segment_efforts?: import("../../openapi/specification").components["schemas"]["DetailedSegmentEffort"][]; device_name?: string; embed_token?: string; splits_metric?: import("../../openapi/specification").components["schemas"]["Split"][]; splits_standard?: import("../../openapi/specification").components["schemas"]["Split"][]; laps?: import("../../openapi/specification").components["schemas"]["Lap"][]; best_efforts?: import("../../openapi/specification").components["schemas"]["DetailedSegmentEffort"][]; }>; update: (id: number, name?: string, type?: ActivityType, sport_type?: SportType, start_date_local?: string, elapsed_time?: number, description?: string, distance?: number, trainer?: boolean, commute?: boolean, confidential?: boolean, flagged?: boolean, gear_id?: string) => Promise<{ id?: number; } & { external_id?: string; upload_id?: number; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; name?: string; distance?: number; moving_time?: number; elapsed_time?: number; total_elevation_gain?: number; elev_high?: number; elev_low?: number; type?: import("../../openapi/specification").components["schemas"]["ActivityType"]; sport_type?: import("../../openapi/specification").components["schemas"]["SportType"]; start_date?: string; start_date_local?: string; timezone?: string; start_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; end_latlng?: import("../../openapi/specification").components["schemas"]["LatLng"]; achievement_count?: number; kudos_count?: number; comment_count?: number; athlete_count?: number; photo_count?: number; total_photo_count?: number; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; trainer?: boolean; commute?: boolean; manual?: boolean; private?: boolean; flagged?: boolean; workout_type?: number; upload_id_str?: string; average_speed?: number; max_speed?: number; has_kudoed?: boolean; hide_from_home?: boolean; gear_id?: string; kilojoules?: number; average_watts?: number; device_watts?: boolean; max_watts?: number; weighted_average_watts?: number; } & { description?: string; photos?: import("../../openapi/specification").components["schemas"]["PhotosSummary"]; gear?: import("../../openapi/specification").components["schemas"]["SummaryGear"]; calories?: number; segment_efforts?: import("../../openapi/specification").components["schemas"]["DetailedSegmentEffort"][]; device_name?: string; embed_token?: string; splits_metric?: import("../../openapi/specification").components["schemas"]["Split"][]; splits_standard?: import("../../openapi/specification").components["schemas"]["Split"][]; laps?: import("../../openapi/specification").components["schemas"]["Lap"][]; best_efforts?: import("../../openapi/specification").components["schemas"]["DetailedSegmentEffort"][]; }>; laps: (id: number) => Promise<{ id?: number; activity?: import("../../openapi/specification").components["schemas"]["MetaActivity"]; athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; average_cadence?: number; average_speed?: number; distance?: number; elapsed_time?: number; start_index?: number; end_index?: number; lap_index?: number; max_speed?: number; moving_time?: number; name?: string; pace_zone?: number; split?: number; start_date?: string; start_date_local?: string; total_elevation_gain?: number; }[]>; zones: (id: number) => Promise<{ score?: number; distribution_buckets?: import("../../openapi/specification").components["schemas"]["TimedZoneDistribution"]; type?: "heartrate" | "power"; sensor_based?: boolean; points?: number; custom_zones?: boolean; max?: number; }[]>; comments: (id: number, page?: number, per_page?: number) => Promise<{ id?: number; activity_id?: number; text?: string; athlete?: import("../../openapi/specification").components["schemas"]["SummaryAthlete"]; created_at?: string; }[]>; kudos: (id: number, page?: number, per_page?: number) => Promise<({ id?: number; } & { resource_state?: number; firstname?: string; lastname?: string; profile_medium?: string; profile?: string; city?: string; state?: string; country?: string; sex?: "M" | "F"; premium?: boolean; summit?: boolean; created_at?: string; updated_at?: string; })[]>; stream: (id: number, keys: ActivityStream[], key_by_type?: boolean) => Promise<{ time?: import("../../openapi/specification").components["schemas"]["TimeStream"]; distance?: import("../../openapi/specification").components["schemas"]["DistanceStream"]; latlng?: import("../../openapi/specification").components["schemas"]["LatLngStream"]; altitude?: import("../../openapi/specification").components["schemas"]["AltitudeStream"]; velocity_smooth?: import("../../openapi/specification").components["schemas"]["SmoothVelocityStream"]; heartrate?: import("../../openapi/specification").components["schemas"]["HeartrateStream"]; cadence?: import("../../openapi/specification").components["schemas"]["CadenceStream"]; watts?: import("../../openapi/specification").components["schemas"]["PowerStream"]; temp?: import("../../openapi/specification").components["schemas"]["TemperatureStream"]; moving?: import("../../openapi/specification").components["schemas"]["MovingStream"]; grade_smooth?: import("../../openapi/specification").components["schemas"]["SmoothGradeStream"]; }>; }; club: { get: (id: number) => Promise<{ id?: number; resource_state?: number; name?: string; } & { profile_medium?: string; cover_photo?: string; cover_photo_small?: string; sport_type?: "cycling" | "running" | "triathlon" | "other"; activity_types?: import("../../openapi/specification").components["schemas"]["ActivityType"][]; city?: string; state?: string; country?: string; private?: boolean; member_count?: number; featured?: boolean; verified?: boolean; url?: string; } & { membership?: "member" | "pending"; admin?: boolean; owner?: boolean; following_count?: number; }>; activities: (id: number, page?: number, per_page?: number) => Promise<{ athlete?: import("../../openapi/specification").components["schemas"]["MetaAthlete"]; name?: string; distance?: number; moving_time?: number; elapsed_time?: number; total_elevation_gain?: number; type?: import("../../openapi/specification").components["schemas"]["ActivityType"]; sport_type?: import("../../openapi/specification").components["schemas"]["SportType"]; workout_type?: number; }[]>; members: (id: number, page?: number, per_page?: number) => Promise<{ resource_state?: number; firstname?: string; lastname?: string; member?: string; admin?: boolean; owner?: boolean; }[]>; admins: (id: number, page?: number, per_page?: number) => Promise<({ id?: number; } & { resource_state?: number; firstname?: string; lastname?: string; profile_medium?: string; profile?: string; city?: string; state?: string; country?: string; sex?: "M" | "F"; premium?: boolean; summit?: boolean; created_at?: string; updated_at?: string; })[]>; }; gear: { get: (id: string) => Promise<{ id?: string; resource_state?: number; primary?: boolean; name?: string; distance?: number; } & { brand_name?: string; model_name?: string; frame_type?: number; description?: string; }>; }; route: { get: (id: number) => Promise<{ athlete?: import("../../openapi/specification").components["schemas"]["SummaryAthlete"]; description?: string; distance?: number; elevation_gain?: number; id?: number; id_str?: string; map?: import("../../openapi/specification").components["schemas"]["PolylineMap"]; name?: string; private?: boolean; starred?: boolean; timestamp?: number; type?: number; sub_type?: number; created_at?: string; updated_at?: string; estimated_moving_time?: number; segments?: import("../../openapi/specification").components["schemas"]["SummarySegment"][]; waypoints?: import("../../openapi/specification").components["schemas"]["Waypoint"][]; }>; export: { GPX: (id: number) => Promise<string>; TCX: (id: number) => Promise<string>; }; stream: (id: number) => Promise<{ time?: import("../../openapi/specification").components["schemas"]["TimeStream"]; distance?: import("../../openapi/specification").components["schemas"]["DistanceStream"]; latlng?: import("../../openapi/specification").components["schemas"]["LatLngStream"]; altitude?: import("../../openapi/specification").components["schemas"]["AltitudeStream"]; velocity_smooth?: import("../../openapi/specification").components["schemas"]["SmoothVelocityStream"]; heartrate?: import("../../openapi/specification").components["schemas"]["HeartrateStream"]; cadence?: import("../../openapi/specification").components["schemas"]["CadenceStream"]; watts?: import("../../openapi/specification").components["schemas"]["PowerStream"]; temp?: import("../../openapi/specification").components["schemas"]["TemperatureStream"]; moving?: import("../../openapi/specification").components["schemas"]["MovingStream"]; grade_smooth?: import("../../openapi/specification").components["schemas"]["SmoothGradeStream"]; }>; }; upload: { get: (uploadId: number) => Promise<{ id?: number; id_str?: string; external_id?: string; error?: string; status?: string; activity_id?: number; }>; put: (file: Blob, name?: string, description?: string, trainer?: boolean, commute?: boolean, data_type?: "fit" | "fit.gz" | "tcx" | "tcx.gz" | "gpx" | "gpx.gz") => Promise<{ id?: number; id_str?: string; external_id?: string; error?: string; status?: string; activity_id?: number; }>; }; }