Client¶
- class myfitnesspal.Client(cookiejar: Optional[CookieJar] = None, unit_aware: bool = False)¶
Provides access to MyFitnessPal APIs
- property user_id: Optional[str]¶
The user_id of the logged-in account.
- property user_metadata: UserMetadata¶
Metadata about of the logged-in account.
- property access_token: Optional[str]¶
The access token for the logged-in account.
- property effective_username: str¶
One’s actual username may be different from the one used for login
This method will return the actual username if it is available, but will fall back to the one provided if it is not.
- get_date(year: int, month: int, day: int) Day ¶
- get_date(date: date) Day
Returns your meal diary for a particular date
- get_measurements(measurement='Weight', lower_bound: Optional[date] = None, upper_bound: Optional[date] = None) Dict[date, float] ¶
Returns measurements of a given name between two dates.
- set_measurements(measurement='Weight', value: Optional[float] = None, date: Optional[date] = None) None ¶
Sets measurement for today’s date.
- get_report(report_name: str = 'Net Calories', report_category: str = 'Nutrition', lower_bound: Optional[date] = None, upper_bound: Optional[date] = None) Dict[date, float] ¶
Returns report data of a given name and category between two dates.
- set_new_food(brand: str, description: str, calories: int, fat: float, carbs: float, protein: float, sodium: Optional[float] = None, potassium: Optional[float] = None, saturated_fat: Optional[float] = None, polyunsaturated_fat: Optional[float] = None, fiber: Optional[float] = None, monounsaturated_fat: Optional[float] = None, sugar: Optional[float] = None, trans_fat: Optional[float] = None, cholesterol: Optional[float] = None, vitamin_a: Optional[float] = None, calcium: Optional[float] = None, vitamin_c: Optional[float] = None, iron: Optional[float] = None, serving_size: str = '1 Serving', servingspercontainer: float = 1.0, sharepublic: bool = False) None ¶
Function to submit new foods / groceries to the MyFitnessPal database. Function will return True if successful.
- set_new_goal(energy: float, energy_unit: str = 'calories', carbohydrates: Optional[float] = None, protein: Optional[float] = None, fat: Optional[float] = None, percent_carbohydrates: Optional[float] = None, percent_protein: Optional[float] = None, percent_fat: Optional[float] = None) None ¶
Updates your nutrition goals.
This Function will update your nutrition goals and is able to deal with multiple situations based on the passed arguments. First matching situation will be applied and used to update the nutrition goals.
Passed arguments - Hints: energy and all absolute macro values - Energy value will be adjusted/calculated if energy from macro values is higher than provided energy value. energy and all percentage macro values - Energy will be adjusted and split into macros by provided percentage. energy - Energy will be adjusted and split into macros by percentage as before.
Optional arguments: energy_unit - Function is able to deal with calories and kilojoules. If not provided user preferences will be used.
Additional hints: Values will be adjusted and rounded by MFP if no premium subscription is applied!
- get_recipes() Dict[int, str] ¶
Returns a dictionary with all saved recipes.
Recipe ID will be used as dictionary key, recipe title as dictionary value.
- get_recipe(recipeid: int) Recipe ¶
Returns recipe details in a dictionary.
See https://schema.org/Recipe for details regarding this schema.
- get_meals() Dict[int, str] ¶
Returns a dictionary with all saved meals.
Key: Meal ID Value: Meal Name
- get_meal(meal_id: int, meal_title: str) Recipe ¶
Returns meal details.
See https://schema.org/Recipe for details regarding this schema.