Skip to main content

SDK for writing FasterFoods recommendation algorithms

Project description

fasterfoodsstack (Python)

SDK for writing FasterFoods recommendation algorithms in Python.

Install

pip install fasterfoodsstack

Or from source:

cd python/
pip install -e .

Quickstart

import fasterfoodsstack as ffs
from fasterfoodsstack import run_local

# Set your dev API key once (or use the FASTERFOODS_API_KEY env var)
ffs.configure(api_key="ffs-dev-...")

# Write your recommendation algorithm
def get_meal_recommendation(user):
    remaining = user.goals.calories - (user.meals.last.calories if user.meals.last else 0)

    if user.goals.goal_type == "gain_muscle":
        return ffs.recommend.meal(
            name="Grilled Chicken Bowl",
            reason=f"{remaining} kcal remaining — prioritising protein for muscle gain",
            calories=720,
            protein_g=60.0,
            tags=["high-protein", "meal-prep"],
        )

    return ffs.recommend.meal(
        name="Tuna & Quinoa Salad",
        reason=f"{remaining} kcal remaining today",
        calories=480,
        protein_g=42.0,
        tags=["high-protein", "low-carb"],
    )

# Fetch a pre-seeded test profile from the dev environment and run locally
ctx = ffs.dummy.athlete()
result = run_local(get_meal_recommendation, ctx)
# -> prints timing, validates return type, prints result fields

# Available profiles: athlete(), weight_loss(), starter(), family()
ctx = ffs.dummy.weight_loss()
result = run_local(get_meal_recommendation, ctx)

API reference

ffs.user (runtime, injected by platform)

Attribute Type Description
ffs.user.profile.dietary_flags list[str] e.g. ["vegetarian", "gluten-free"]
ffs.user.meals.last Meal | None Most recently logged meal
ffs.user.meals.history(days=7) list[Meal] Meals in the last N days
ffs.user.meals.favorites list[Meal] User's favourite meals
ffs.user.goals.calories int Daily calorie target
ffs.user.goals.protein_g float Daily protein target (grams)
ffs.user.goals.carbs_g float Daily carbs target (grams)
ffs.user.goals.fat_g float Daily fat target (grams)
ffs.user.goals.goal_type str "lose_weight" | "maintain" | "gain_muscle"

ffs.recommend

ffs.recommend.meal(
    name: str,
    reason: str,
    calories: int,
    protein_g: float,
    tags: list[str] = [],
) -> MealRecommendation

ffs.recommend.workout(
    type: str,          # "strength" | "cardio" | "flexibility" | "rest"
    duration_minutes: int,
    reason: str,
) -> WorkoutRecommendation

ffs.dummy

Fetches pre-seeded test user contexts from the FasterFoods dev environment. Each call makes an authenticated API request and returns a user context with the same shape as the runtime user namespace.

ctx = ffs.dummy.athlete()      # high-calorie, gain_muscle
ctx = ffs.dummy.weight_loss()  # caloric deficit, gluten-free
ctx = ffs.dummy.starter()      # balanced beginner, maintain
ctx = ffs.dummy.family()       # vegetarian, maintain

ffs.configure(api_key, base_url=None)

Sets the API key for all SDK calls. Call once at startup, or set FASTERFOODS_API_KEY in your environment instead.

run_local(fn, context)

Runs your function with a fetched user context, prints timing and the result, validates the return type.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasterfoodsstack-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasterfoodsstack-0.1.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file fasterfoodsstack-0.1.0.tar.gz.

File metadata

  • Download URL: fasterfoodsstack-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fasterfoodsstack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f893180830491ce0a98e504a01033d7b9229333975089e3a102f20efcc52718e
MD5 0cb74e979688c06f6501365481d22ac0
BLAKE2b-256 8a8132b9e0d1f483d1c3b52a04bd8ea873bc37df102aa0fde002cd0d2601fadc

See more details on using hashes here.

Provenance

The following attestation bundles were made for fasterfoodsstack-0.1.0.tar.gz:

Publisher: publish-python.yml on RitvikJoshi97/fasterfoodsstack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fasterfoodsstack-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fasterfoodsstack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c87df21d7849de082ba8d552cd21e31a3638bd10887b852d1d97cf3df3c52677
MD5 86db47c250485aa9f8fd679bccc1bd52
BLAKE2b-256 d2f2e27606ab286243c5305b340c6c993b711836eafea412c31e19b48331b811

See more details on using hashes here.

Provenance

The following attestation bundles were made for fasterfoodsstack-0.1.0-py3-none-any.whl:

Publisher: publish-python.yml on RitvikJoshi97/fasterfoodsstack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page