openstride 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ .pytest_cache/
5
+ .coverage
6
+ dist/
7
+ build/
8
+ *.egg-info/
9
+ .env
10
+ data/
11
+ auth_state.json
12
+ coverage.xml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 choonyongchan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.5
2
+ Name: openstride
3
+ Version: 0.1.0
4
+ Summary: Compatible with Strava: club activities, members and admins for Python, plus stravalib's full API client. Unofficial.
5
+ Project-URL: Source, https://github.com/choonyongchan/OpenStride
6
+ Author: choonyongchan
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: club,cycling,fitness,running,strava,stravalib
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Typing :: Typed
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: playwright>=1.45
18
+ Requires-Dist: pydantic<3,>=2.0
19
+ Requires-Dist: stravalib<3,>=2.6
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest-cov>=5; extra == 'test'
22
+ Requires-Dist: pytest>=8; extra == 'test'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # OpenStride
26
+
27
+ **OpenStride: compatible with Strava. A Python library for club activities, members and admins, plus a self-hosted club dashboard.**
28
+
29
+ On 1 September 2026 Strava removed three API endpoints:
30
+ `GET /clubs/{id}/activities`, `GET /clubs/{id}/members` and `GET /clubs/{id}/admins`.
31
+ OpenStride provides these three methods again, with the same arguments and return types,
32
+ using your own logged-in Strava session. Everything else in the official API is served by
33
+ [stravalib](https://github.com/stravalib/stravalib), which OpenStride builds on.
34
+
35
+ > **Unofficial. For educational purposes only.**
36
+ > OpenStride is not affiliated with, endorsed by or sponsored by Strava, Inc. "Strava" is a
37
+ > trademark of Strava, Inc. Review Strava's Terms of Service before use: using OpenStride
38
+ > may get the account you log in with restricted or banned. You are responsible for how you
39
+ > use OpenStride and for the club members' data it returns. Only use it with clubs you
40
+ > belong to, keep the request rate low, and respect members' privacy choices.
41
+
42
+ This repository has three parts:
43
+
44
+ | Part | What it is | Where |
45
+ |---|---|---|
46
+ | **Library** | `pip install openstride`: `ClubScraper`, and `Client` (a drop-in `stravalib.Client`) | `src/` |
47
+ | **Dashboard** | FastAPI backend + static frontend: leaderboard, awards, history, trend, and Strava-shaped `/api/v3/clubs/...` endpoints | `dashboard/` |
48
+ | **Docker image** | the dashboard with Chromium, one command to run | `Dockerfile`, `docker-compose.yml` |
49
+
50
+ ---
51
+
52
+ ## 1. The library
53
+
54
+ ```bash
55
+ pip install openstride
56
+ python -m playwright install chromium
57
+ openstride login # log in to Strava in the window that opens; saves auth_state.json
58
+ ```
59
+
60
+ ### Drop-in for stravalib
61
+
62
+ ```python
63
+ from openstride import Client
64
+
65
+ with Client(access_token="...", session_file="auth_state.json") as client:
66
+ me = client.get_athlete() # official API, via stravalib
67
+ for a in client.get_club_activities(123456): # removed endpoint, restored
68
+ print(a.athlete.firstname, a.sport_type, a.distance, a.moving_time)
69
+ members = client.get_club_members(123456)
70
+ admins = client.get_club_admins(123456)
71
+ ```
72
+
73
+ `Client` subclasses `stravalib.Client`, so every other method is stravalib's. The three
74
+ club methods take the same arguments (`club_id`, `limit`) and return the same model types
75
+ (`isinstance(a, stravalib.model.ClubActivity)` holds), as lists instead of lazy iterators.
76
+ `access_token` is optional if you only use the club methods.
77
+
78
+ ### Without an API token
79
+
80
+ ```python
81
+ from datetime import date
82
+ from openstride import ClubScraper
83
+
84
+ with ClubScraper("auth_state.json", timezone="Asia/Singapore") as s:
85
+ activities = s.get_club_activities(123456) # about the last 26 hours, newest first
86
+ roster = s.get_club_roster(123456) # .member_count, .members, .complete
87
+ admins = s.get_club_admins(123456)
88
+ count = s.get_club_member_count(123456)
89
+ board = s.get_club_leaderboard(123456, "last") # Strava's weekly club leaderboard, ~top 100
90
+ many = s.get_athlete_weeks([(987654, date(2026, 9, 14)), ...]) # stops cleanly at HTTP 429
91
+ ```
92
+
93
+ From the command line: `openstride activities 123456`, `openstride members 123456`,
94
+ `openstride admins 123456`, `openstride count 123456` (JSON on stdout).
95
+
96
+ ### What you get, compared with the old endpoints
97
+
98
+ | Removed endpoint | Old API returned | OpenStride returns |
99
+ |---|---|---|
100
+ | `get_club_activities` | athlete first name + last initial, name, distance, moving/elapsed time, elevation, type, sport_type, workout_type. **No activity id, date or athlete id.** | all of those, plus `id`, `athlete_id`, full name, `start_date`, `start_date_local`, device, kudos, comments, description, location, visibility, steps, pace. `raw_type` keeps sports stravalib doesn't know yet. |
101
+ | `get_club_members` | first name, last initial, member/admin/owner flags. **No athlete id.** | `id`, full `name`, `firstname`, `lastname`, `admin`, `member="accepted"`. `owner` is always `None` (Strava doesn't expose it). |
102
+ | `get_club_admins` | summary athletes | `id`, full `name`, `firstname`, `lastname` |
103
+
104
+ ### Accuracy: read this before relying on the numbers
105
+
106
+ - **Numbers match what Strava displays**, so they are rounded the way Strava
107
+ rounds them on screen: distance to 0.01 km or 0.01 mi (about 10 m), elevation to 1 m or 1 ft,
108
+ and durations over an hour shown without seconds lose them. Imperial accounts are
109
+ supported and converted to metres.
110
+ - **The account's Strava language must be English.** Labels and number formats are
111
+ localised; a non-English account raises `UnsupportedLocale` rather than returning wrong
112
+ numbers. Change it at strava.com/settings/display.
113
+ - **The club feed keeps limited entries.** Poll frequently (hourly), or use the profile weeks
114
+ (`get_athlete_weeks`) to backfill. Strava rate-limits those; the call stops at the first
115
+ HTTP 429 and tells you what it didn't fetch.
116
+ - **You see what the logged-in account sees.** Private activities and private profiles are
117
+ invisible; the full member list needs an account that may view the club's members.
118
+ - **Strava can change its service at any time.** OpenStride raises `MarkupChanged` instead of
119
+ returning wrong data. All errors subclass `OpenStrideError`:
120
+ `SessionExpired` (run `openstride login` again), `RateLimited`, `MarkupChanged`, `UnsupportedLocale`.
121
+
122
+ One `ClubScraper` drives one Chromium and is not thread-safe; use one per thread.
123
+
124
+ ---
125
+
126
+ ## 2. The dashboard
127
+
128
+ A club challenge dashboard: totals, awards, a sortable leaderboard (every member, active
129
+ or not), history by day and trend charts. It syncs on a schedule and keeps its data as
130
+ CSV files you can open in any spreadsheet.
131
+
132
+ ```bash
133
+ git clone <this repo> && cd OpenStride
134
+ python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
135
+ pip install -e . -r requirements-dashboard.txt
136
+ python -m playwright install chromium
137
+ cp .env.example .env # set OPENSTRIDE_CLUB_ID and OPENSTRIDE_CHALLENGE_START
138
+ set -a; . ./.env; set +a # or export the variables your own way
139
+ python -m dashboard login # saves data/auth_state.json
140
+ python -m dashboard serve # http://localhost:8000
141
+ ```
142
+
143
+ | Command | Does |
144
+ |---|---|
145
+ | `python -m dashboard serve` | API + dashboard; syncs every `OPENSTRIDE_SYNC_MINUTES`, profile scan at `OPENSTRIDE_SCAN_HOUR` |
146
+ | `python -m dashboard sync` | one light sync now (members, feed, leaderboard) |
147
+ | `python -m dashboard sync --scan` | ...plus the profile scan (fills gaps the feed missed) |
148
+ | `python -m dashboard sync --setup` | rescan every week since the start, for everyone |
149
+ | `python -m dashboard login` | log in again when the session expires |
150
+
151
+ ### Where the numbers come from
152
+
153
+ Each sync reads the roster (and the headline member count), the club feed and the weekly
154
+ leaderboard; the nightly scan reads every current member's last two profile weeks (every
155
+ week since the start for newcomers). Per athlete and day, `statistics.csv` keeps cumulative
156
+ totals from the best source available: Strava's leaderboard figure, else the profile week,
157
+ else the feed. Set `OPENSTRIDE_SPORTS` to the club's sport so the three agree; the default is
158
+ foot sports (Run, TrailRun, VirtualRun, Walk, Hike).
159
+
160
+ | File in `data/` | Holds |
161
+ |---|---|
162
+ | `activities.csv` | every activity seen, any sport, one row each, never rewritten |
163
+ | `members.csv` | everyone ever on the roster, with `admin`, `ingest_at`, `left_at` |
164
+ | `member_count.csv` | the headline member count at each sync |
165
+ | `statistics.csv` | cumulative totals per athlete per day, with `source` |
166
+ | `status.json` | the last sync's outcome (shown on the dashboard when it failed) |
167
+ | `auth_state.json` | the Strava session. **Secret: never commit or share it.** |
168
+
169
+ ### API
170
+
171
+ | Endpoint | |
172
+ |---|---|
173
+ | `GET /api/club` | name, settings, last sync |
174
+ | `GET /api/report?date=YYYY-MM-DD` | totals, awards, leaderboard as of a day |
175
+ | `GET /api/dates`, `GET /api/trend` | days with history; cumulative totals per day |
176
+ | `GET /api/v3/clubs/{id}/activities` | **the removed endpoints, same paths and JSON**, from the synced data (all history, not just 26 h), `?page=&per_page=` (max 200) |
177
+ | `GET /api/v3/clubs/{id}/members` | |
178
+ | `GET /api/v3/clubs/{id}/admins` | |
179
+ | `POST /api/sync?scan=&setup=` | run a sync now |
180
+
181
+ `/api/v3/*` and `POST /api/sync` need `Authorization: Bearer $OPENSTRIDE_API_TOKEN`; they are
182
+ off until you set the token. They expose more than the dashboard does (descriptions,
183
+ locations), so keep the token private.
184
+
185
+ ```bash
186
+ curl -H "Authorization: Bearer $OPENSTRIDE_API_TOKEN" localhost:8000/api/v3/clubs/123456/activities?per_page=5
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 3. Docker
192
+
193
+ ```bash
194
+ cp .env.example .env # fill in OPENSTRIDE_CLUB_ID, OPENSTRIDE_CHALLENGE_START, ...
195
+ mkdir -p data
196
+ # Log in once on a machine with a screen (the container has none), then copy the session in:
197
+ pip install openstride && python -m playwright install chromium && openstride login --session-file data/auth_state.json
198
+ docker compose up -d # http://localhost:8000
199
+ docker compose run --rm dashboard python -m dashboard sync --setup # optional: backfill since the start
200
+ ```
201
+
202
+ The image runs as an unprivileged user with everything in the `/data` volume. When the
203
+ dashboard shows "SessionExpired", run `openstride login --session-file data/auth_state.json`
204
+ again; nothing else needs restarting.
205
+
206
+ ---
207
+
208
+ ## Development
209
+
210
+ Tests come in three layers, each run and coverage-gated in CI: `tests/library` (unit), `tests/dashboard`
211
+ (integration), and `tests/e2e` (headless Chromium against a local fake site).
212
+
213
+ ```bash
214
+ pip install -e ".[test]" -r requirements-dashboard.txt httpx
215
+ python -m playwright install chromium
216
+ python -m pytest -q --cov # unit + integration + e2e, offline: never contacts Strava
217
+ OPENSTRIDE_TEST_CLUB_ID=123456 python -m pytest tests/live --live # vs live Strava: roster tallies, profile weeks = leaderboard
218
+ python -m build && twine check dist/* # the PyPI package (library only)
219
+ ```
220
+
221
+ The library lives in `src/` (`_parse.py` is pure functions, unit-tested). The dashboard
222
+ calls the library. To publish: bump `version` in `pyproject.toml` and `__version__`, then
223
+ `twine upload dist/*`.
224
+
225
+ ## Licence
226
+
227
+ MIT. Builds on [stravalib](https://github.com/stravalib/stravalib) (Apache-2.0) and
228
+ [Playwright](https://playwright.dev/). Dashboard originally based on
229
+ [DatabenderSK/strava-club-dashboard](https://github.com/DatabenderSK/strava-club-dashboard).
@@ -0,0 +1,205 @@
1
+ # OpenStride
2
+
3
+ **OpenStride: compatible with Strava. A Python library for club activities, members and admins, plus a self-hosted club dashboard.**
4
+
5
+ On 1 September 2026 Strava removed three API endpoints:
6
+ `GET /clubs/{id}/activities`, `GET /clubs/{id}/members` and `GET /clubs/{id}/admins`.
7
+ OpenStride provides these three methods again, with the same arguments and return types,
8
+ using your own logged-in Strava session. Everything else in the official API is served by
9
+ [stravalib](https://github.com/stravalib/stravalib), which OpenStride builds on.
10
+
11
+ > **Unofficial. For educational purposes only.**
12
+ > OpenStride is not affiliated with, endorsed by or sponsored by Strava, Inc. "Strava" is a
13
+ > trademark of Strava, Inc. Review Strava's Terms of Service before use: using OpenStride
14
+ > may get the account you log in with restricted or banned. You are responsible for how you
15
+ > use OpenStride and for the club members' data it returns. Only use it with clubs you
16
+ > belong to, keep the request rate low, and respect members' privacy choices.
17
+
18
+ This repository has three parts:
19
+
20
+ | Part | What it is | Where |
21
+ |---|---|---|
22
+ | **Library** | `pip install openstride`: `ClubScraper`, and `Client` (a drop-in `stravalib.Client`) | `src/` |
23
+ | **Dashboard** | FastAPI backend + static frontend: leaderboard, awards, history, trend, and Strava-shaped `/api/v3/clubs/...` endpoints | `dashboard/` |
24
+ | **Docker image** | the dashboard with Chromium, one command to run | `Dockerfile`, `docker-compose.yml` |
25
+
26
+ ---
27
+
28
+ ## 1. The library
29
+
30
+ ```bash
31
+ pip install openstride
32
+ python -m playwright install chromium
33
+ openstride login # log in to Strava in the window that opens; saves auth_state.json
34
+ ```
35
+
36
+ ### Drop-in for stravalib
37
+
38
+ ```python
39
+ from openstride import Client
40
+
41
+ with Client(access_token="...", session_file="auth_state.json") as client:
42
+ me = client.get_athlete() # official API, via stravalib
43
+ for a in client.get_club_activities(123456): # removed endpoint, restored
44
+ print(a.athlete.firstname, a.sport_type, a.distance, a.moving_time)
45
+ members = client.get_club_members(123456)
46
+ admins = client.get_club_admins(123456)
47
+ ```
48
+
49
+ `Client` subclasses `stravalib.Client`, so every other method is stravalib's. The three
50
+ club methods take the same arguments (`club_id`, `limit`) and return the same model types
51
+ (`isinstance(a, stravalib.model.ClubActivity)` holds), as lists instead of lazy iterators.
52
+ `access_token` is optional if you only use the club methods.
53
+
54
+ ### Without an API token
55
+
56
+ ```python
57
+ from datetime import date
58
+ from openstride import ClubScraper
59
+
60
+ with ClubScraper("auth_state.json", timezone="Asia/Singapore") as s:
61
+ activities = s.get_club_activities(123456) # about the last 26 hours, newest first
62
+ roster = s.get_club_roster(123456) # .member_count, .members, .complete
63
+ admins = s.get_club_admins(123456)
64
+ count = s.get_club_member_count(123456)
65
+ board = s.get_club_leaderboard(123456, "last") # Strava's weekly club leaderboard, ~top 100
66
+ many = s.get_athlete_weeks([(987654, date(2026, 9, 14)), ...]) # stops cleanly at HTTP 429
67
+ ```
68
+
69
+ From the command line: `openstride activities 123456`, `openstride members 123456`,
70
+ `openstride admins 123456`, `openstride count 123456` (JSON on stdout).
71
+
72
+ ### What you get, compared with the old endpoints
73
+
74
+ | Removed endpoint | Old API returned | OpenStride returns |
75
+ |---|---|---|
76
+ | `get_club_activities` | athlete first name + last initial, name, distance, moving/elapsed time, elevation, type, sport_type, workout_type. **No activity id, date or athlete id.** | all of those, plus `id`, `athlete_id`, full name, `start_date`, `start_date_local`, device, kudos, comments, description, location, visibility, steps, pace. `raw_type` keeps sports stravalib doesn't know yet. |
77
+ | `get_club_members` | first name, last initial, member/admin/owner flags. **No athlete id.** | `id`, full `name`, `firstname`, `lastname`, `admin`, `member="accepted"`. `owner` is always `None` (Strava doesn't expose it). |
78
+ | `get_club_admins` | summary athletes | `id`, full `name`, `firstname`, `lastname` |
79
+
80
+ ### Accuracy: read this before relying on the numbers
81
+
82
+ - **Numbers match what Strava displays**, so they are rounded the way Strava
83
+ rounds them on screen: distance to 0.01 km or 0.01 mi (about 10 m), elevation to 1 m or 1 ft,
84
+ and durations over an hour shown without seconds lose them. Imperial accounts are
85
+ supported and converted to metres.
86
+ - **The account's Strava language must be English.** Labels and number formats are
87
+ localised; a non-English account raises `UnsupportedLocale` rather than returning wrong
88
+ numbers. Change it at strava.com/settings/display.
89
+ - **The club feed keeps limited entries.** Poll frequently (hourly), or use the profile weeks
90
+ (`get_athlete_weeks`) to backfill. Strava rate-limits those; the call stops at the first
91
+ HTTP 429 and tells you what it didn't fetch.
92
+ - **You see what the logged-in account sees.** Private activities and private profiles are
93
+ invisible; the full member list needs an account that may view the club's members.
94
+ - **Strava can change its service at any time.** OpenStride raises `MarkupChanged` instead of
95
+ returning wrong data. All errors subclass `OpenStrideError`:
96
+ `SessionExpired` (run `openstride login` again), `RateLimited`, `MarkupChanged`, `UnsupportedLocale`.
97
+
98
+ One `ClubScraper` drives one Chromium and is not thread-safe; use one per thread.
99
+
100
+ ---
101
+
102
+ ## 2. The dashboard
103
+
104
+ A club challenge dashboard: totals, awards, a sortable leaderboard (every member, active
105
+ or not), history by day and trend charts. It syncs on a schedule and keeps its data as
106
+ CSV files you can open in any spreadsheet.
107
+
108
+ ```bash
109
+ git clone <this repo> && cd OpenStride
110
+ python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
111
+ pip install -e . -r requirements-dashboard.txt
112
+ python -m playwright install chromium
113
+ cp .env.example .env # set OPENSTRIDE_CLUB_ID and OPENSTRIDE_CHALLENGE_START
114
+ set -a; . ./.env; set +a # or export the variables your own way
115
+ python -m dashboard login # saves data/auth_state.json
116
+ python -m dashboard serve # http://localhost:8000
117
+ ```
118
+
119
+ | Command | Does |
120
+ |---|---|
121
+ | `python -m dashboard serve` | API + dashboard; syncs every `OPENSTRIDE_SYNC_MINUTES`, profile scan at `OPENSTRIDE_SCAN_HOUR` |
122
+ | `python -m dashboard sync` | one light sync now (members, feed, leaderboard) |
123
+ | `python -m dashboard sync --scan` | ...plus the profile scan (fills gaps the feed missed) |
124
+ | `python -m dashboard sync --setup` | rescan every week since the start, for everyone |
125
+ | `python -m dashboard login` | log in again when the session expires |
126
+
127
+ ### Where the numbers come from
128
+
129
+ Each sync reads the roster (and the headline member count), the club feed and the weekly
130
+ leaderboard; the nightly scan reads every current member's last two profile weeks (every
131
+ week since the start for newcomers). Per athlete and day, `statistics.csv` keeps cumulative
132
+ totals from the best source available: Strava's leaderboard figure, else the profile week,
133
+ else the feed. Set `OPENSTRIDE_SPORTS` to the club's sport so the three agree; the default is
134
+ foot sports (Run, TrailRun, VirtualRun, Walk, Hike).
135
+
136
+ | File in `data/` | Holds |
137
+ |---|---|
138
+ | `activities.csv` | every activity seen, any sport, one row each, never rewritten |
139
+ | `members.csv` | everyone ever on the roster, with `admin`, `ingest_at`, `left_at` |
140
+ | `member_count.csv` | the headline member count at each sync |
141
+ | `statistics.csv` | cumulative totals per athlete per day, with `source` |
142
+ | `status.json` | the last sync's outcome (shown on the dashboard when it failed) |
143
+ | `auth_state.json` | the Strava session. **Secret: never commit or share it.** |
144
+
145
+ ### API
146
+
147
+ | Endpoint | |
148
+ |---|---|
149
+ | `GET /api/club` | name, settings, last sync |
150
+ | `GET /api/report?date=YYYY-MM-DD` | totals, awards, leaderboard as of a day |
151
+ | `GET /api/dates`, `GET /api/trend` | days with history; cumulative totals per day |
152
+ | `GET /api/v3/clubs/{id}/activities` | **the removed endpoints, same paths and JSON**, from the synced data (all history, not just 26 h), `?page=&per_page=` (max 200) |
153
+ | `GET /api/v3/clubs/{id}/members` | |
154
+ | `GET /api/v3/clubs/{id}/admins` | |
155
+ | `POST /api/sync?scan=&setup=` | run a sync now |
156
+
157
+ `/api/v3/*` and `POST /api/sync` need `Authorization: Bearer $OPENSTRIDE_API_TOKEN`; they are
158
+ off until you set the token. They expose more than the dashboard does (descriptions,
159
+ locations), so keep the token private.
160
+
161
+ ```bash
162
+ curl -H "Authorization: Bearer $OPENSTRIDE_API_TOKEN" localhost:8000/api/v3/clubs/123456/activities?per_page=5
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 3. Docker
168
+
169
+ ```bash
170
+ cp .env.example .env # fill in OPENSTRIDE_CLUB_ID, OPENSTRIDE_CHALLENGE_START, ...
171
+ mkdir -p data
172
+ # Log in once on a machine with a screen (the container has none), then copy the session in:
173
+ pip install openstride && python -m playwright install chromium && openstride login --session-file data/auth_state.json
174
+ docker compose up -d # http://localhost:8000
175
+ docker compose run --rm dashboard python -m dashboard sync --setup # optional: backfill since the start
176
+ ```
177
+
178
+ The image runs as an unprivileged user with everything in the `/data` volume. When the
179
+ dashboard shows "SessionExpired", run `openstride login --session-file data/auth_state.json`
180
+ again; nothing else needs restarting.
181
+
182
+ ---
183
+
184
+ ## Development
185
+
186
+ Tests come in three layers, each run and coverage-gated in CI: `tests/library` (unit), `tests/dashboard`
187
+ (integration), and `tests/e2e` (headless Chromium against a local fake site).
188
+
189
+ ```bash
190
+ pip install -e ".[test]" -r requirements-dashboard.txt httpx
191
+ python -m playwright install chromium
192
+ python -m pytest -q --cov # unit + integration + e2e, offline: never contacts Strava
193
+ OPENSTRIDE_TEST_CLUB_ID=123456 python -m pytest tests/live --live # vs live Strava: roster tallies, profile weeks = leaderboard
194
+ python -m build && twine check dist/* # the PyPI package (library only)
195
+ ```
196
+
197
+ The library lives in `src/` (`_parse.py` is pure functions, unit-tested). The dashboard
198
+ calls the library. To publish: bump `version` in `pyproject.toml` and `__version__`, then
199
+ `twine upload dist/*`.
200
+
201
+ ## Licence
202
+
203
+ MIT. Builds on [stravalib](https://github.com/stravalib/stravalib) (Apache-2.0) and
204
+ [Playwright](https://playwright.dev/). Dashboard originally based on
205
+ [DatabenderSK/strava-club-dashboard](https://github.com/DatabenderSK/strava-club-dashboard).
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.24"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "openstride"
7
+ version = "0.1.0"
8
+ description = "Compatible with Strava: club activities, members and admins for Python, plus stravalib's full API client. Unofficial."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+ authors = [{ name = "choonyongchan" }]
14
+ keywords = ["strava", "club", "running", "cycling", "fitness", "stravalib"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Typing :: Typed",
22
+ ]
23
+ dependencies = [
24
+ "stravalib>=2.6,<3",
25
+ "pydantic>=2.0,<3",
26
+ "playwright>=1.45",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ test = ["pytest>=8", "pytest-cov>=5"]
31
+
32
+ [project.scripts]
33
+ openstride = "openstride.cli:main"
34
+
35
+ [project.urls]
36
+ Source = "https://github.com/choonyongchan/OpenStride"
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+
40
+ [tool.hatch.build.targets.wheel.force-include]
41
+ # src/ is the openstride package itself
42
+ "src" = "openstride"
43
+
44
+ [tool.hatch.build.targets.sdist]
45
+ include = ["src", "tests/library", "README.md", "LICENSE"]
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
49
+ markers = [
50
+ "live: hits strava.com with a saved session (opt in with --live)",
51
+ "e2e: real headless Chromium against a local fake site (needs `playwright install chromium`)",
52
+ ]
53
+
54
+ [tool.coverage.run]
55
+ source = ["openstride", "dashboard"]
56
+ omit = ["tests/*"]
57
+
58
+ [tool.coverage.paths]
59
+ openstride = ["src", "*/site-packages/openstride"]
60
+
61
+ [tool.coverage.report]
62
+ show_missing = true
63
+ skip_covered = true
@@ -0,0 +1,20 @@
1
+ """openstride: Strava's removed club endpoints (club activities, members, admins), read from the club web pages,
2
+ plus stravalib's full API client.
3
+
4
+ Unofficial. Not affiliated with, endorsed or sponsored by Strava, Inc. For educational purposes only: using it
5
+ may breach Strava's Terms of Service, and you are responsible for how you use it.
6
+ """
7
+ from ._browser import login
8
+ from .client import Client
9
+ from .errors import MarkupChanged, RateLimited, SessionExpired, OpenStrideError, UnsupportedLocale
10
+ from .models import AthleteWeek, ClubActivity, ClubAdmin, ClubAthlete, ClubRoster, LeaderboardEntry
11
+ from .scraper import AthleteWeeks, ClubScraper, monday_of, week_id
12
+
13
+ __version__ = "0.1.0"
14
+
15
+ __all__ = [
16
+ "Client", "ClubScraper", "login",
17
+ "ClubActivity", "ClubAthlete", "ClubAdmin", "ClubRoster", "LeaderboardEntry", "AthleteWeek", "AthleteWeeks",
18
+ "OpenStrideError", "SessionExpired", "RateLimited", "MarkupChanged", "UnsupportedLocale",
19
+ "monday_of", "week_id", "__version__",
20
+ ]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())