# Get MyFitnessPal build id to then determine friends list URL
response = requests.get("https://www.myfitnesspal.com")
response_text_json_extract = re.search('<script id="__NEXT_DATA__" type="application/json">(.+?)</script>', response.text).group(1)
mfp_build_id = json.loads(response_text_json_extract)["buildId"]
self_friends_json = json.loads(client._get_content_for_url("https://www.myfitnesspal.com/_next/data/" + mfp_build_id + "/en/friends.json?sort_order=oldest&limit=120"))
# Get friends
self_friends_list = []
for item in self_friends_json['pageProps']['dehydratedState']['queries']:
if "total_friends" in item['state']['data']:
for friend in item['state']['data']['friends']:
self_friends_list.append(friend['username'])
There are a number of new MFP APIs being released, which would simplify and enhance this SDK
New diary report
https://www.myfitnesspal.com/reports/printable-diary?from=2023-02-22&to=2023-04-22
https://www.myfitnesspal.com/reports/printable-diary/friend_username?from=2023-02-22&to=2023-04-22
New friends list
https://www.myfitnesspal.com/friends