Skip to content

Commit 106ca75

Browse files
committed
I forgot...
1 parent e173f88 commit 106ca75

File tree

3 files changed

+293
-0
lines changed

3 files changed

+293
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# Hide my files
132+
admin.py
133+
*.csv
134+
*.png

GetStravaSegmentData.ipynb

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"# imports\n",
10+
"import admin\n",
11+
"import pandas as pd\n",
12+
"import requests\n",
13+
"import urllib3\n",
14+
"urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": null,
20+
"metadata": {},
21+
"outputs": [],
22+
"source": [
23+
"# Strava API call\n",
24+
"auth_url = \"https://www.strava.com/oauth/token\"\n",
25+
"segments_url = \"https://www.strava.com/api/v3/segment_efforts\"\n",
26+
"\n",
27+
"payload = {\n",
28+
" 'client_id': admin.ClientID,\n",
29+
" 'client_secret': admin.ClientSecret,\n",
30+
" 'refresh_token': admin.RefreshToken,\n",
31+
" 'grant_type': \"refresh_token\",\n",
32+
" 'f': 'json'\n",
33+
"}\n",
34+
"\n",
35+
"# Get updated access token\n",
36+
"print(\"Requesting Token...\\n\")\n",
37+
"res = requests.post(auth_url, data=payload, verify=False)\n",
38+
"access_token = res.json()['access_token']\n",
39+
"print(\"Access Token = {}\\n\".format(access_token))\n",
40+
"\n",
41+
"# Pull strava segement data (segment ID is the segment of interest)\n",
42+
"header = {'Authorization': 'Bearer ' + access_token}\n",
43+
"param = {\"segment_id\": 609371, 'per_page': 100}\n",
44+
"strava_data = requests.get(segments_url, headers=header, params=param).json()\n"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"# Convert json to dataframe and save\n",
54+
"strava_df = pd.DataFrame(strava_data)\n",
55+
"\n",
56+
"strava_df.to_csv(\"lookout_data.csv\")"
57+
]
58+
}
59+
],
60+
"metadata": {
61+
"interpreter": {
62+
"hash": "5de041f34af249fe95230f6bdf66b9e329d7a6068ec7388d2c2808284787eaca"
63+
},
64+
"kernelspec": {
65+
"display_name": "Python 3.9.13 ('base')",
66+
"language": "python",
67+
"name": "python3"
68+
},
69+
"language_info": {
70+
"codemirror_mode": {
71+
"name": "ipython",
72+
"version": 3
73+
},
74+
"file_extension": ".py",
75+
"mimetype": "text/x-python",
76+
"name": "python",
77+
"nbconvert_exporter": "python",
78+
"pygments_lexer": "ipython3",
79+
"version": "3.9.13"
80+
},
81+
"orig_nbformat": 4
82+
},
83+
"nbformat": 4,
84+
"nbformat_minor": 2
85+
}

LookoutAnalysis.ipynb

+203
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)