Skip to main content

Async Python Client library for HelloFresh API

Project description

pyhellofresh

Async Python client library for accessing HelloFresh APIs. Designed to be completely standalone, fully typed, and ready for integration into Python applications or Home Assistant integrations.

Features

  • 100% Asynchronous: Built on top of aiohttp for non-blocking HTTP requests.
  • Session Injection: Supports injecting custom aiohttp.ClientSession or auto-managing internal sessions.
  • Authentication: Supports direct Bearer JWT token initialization, token refreshing (refresh_access_token), and passwordless magic link login (start_passwordless_login & finish_passwordless_login).
  • Data Endpoints:
    • Customer Profile & Dietary Exclusions (get_profile)
    • Account Credit Balance (get_balance)
    • Weekly Delivery Schedule & Past Deliveries (get_past_deliveries)
    • Weekly Menus & Selected Meals (get_menu)
    • Full Recipe Details, Ingredients, Nutrition & Step Instructions (get_recipe)
    • Cart Price Calculations (get_cart_price)
  • Strictly Typed: Dataclass models for all API resources.

Installation

pip install pyhellofresh

Quickstart Example

import asyncio
from pyhellofresh import HelloFreshClient

async def main():
    # Initialize client with existing Bearer token
    client = HelloFreshClient(access_token="YOUR_ACCESS_TOKEN", country="GB", locale="en-GB")
    
    # Fetch profile
    profile = await client.get_profile()
    print(f"Adults: {profile.adults}, Exclusions: {profile.exclusions}")
    
    # Fetch weekly menu for 2026-W32
    menu = await client.get_menu(week="2026-W32")
    print(f"Week: {menu.week}, Total meals available: {len(menu.meals)}")
    
    # Close session
    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Passwordless Login Flow

import asyncio
from pyhellofresh import HelloFreshClient

async def login():
    async with await HelloFreshClient.with_session() as client:
        # Step 1: Trigger magic link email
        public_id = await client.start_passwordless_login("user@example.com")
        print(f"Magic link sent. Public ID: {public_id}")
        
        # Step 2: Extract code from link clicked in email and complete login
        token_resp = await client.finish_passwordless_login(
            code="CODE_FROM_EMAIL_LINK",
            email="user@example.com",
            public_id=public_id,
        )
        print(f"Access Token: {token_resp.access_token}")
        print(f"Refresh Token: {token_resp.refresh_token}")

Token Refreshing

async def refresh(client: HelloFreshClient):
    new_tokens = await client.refresh_access_token()
    print(f"Updated Access Token: {new_tokens.access_token}")

Testing with the Test Script

A ready-to-use CLI test script example_test.py is provided to quickly test API connectivity and models:

# Test with an existing Bearer JWT token:
python3 example_test.py --token "YOUR_ACCESS_TOKEN"

# Test passwordless magic link flow:
python3 example_test.py --email "user@example.com"

# Test token refresh:
python3 example_test.py --refresh-token "YOUR_REFRESH_TOKEN"

Development

python3 -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'

# Run tests & coverage
pytest --cov=pyhellofresh

License

MIT

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

pyhellofresh-0.1.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

pyhellofresh-0.1.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file pyhellofresh-0.1.1.tar.gz.

File metadata

  • Download URL: pyhellofresh-0.1.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyhellofresh-0.1.1.tar.gz
Algorithm Hash digest
SHA256 469437fc1728780f0f3a9cd22d34bdb69df7c7e77c9d467fce93689e3ca56869
MD5 d65f00924272cea152a9aeea585e9092
BLAKE2b-256 5365e48e448cdd31c5d2ba33fe645fd2c560e6ccd4b03b2b4ecb18fe3e2d82cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhellofresh-0.1.1.tar.gz:

Publisher: release.yml on pantherale0/pyhellofresh

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

File details

Details for the file pyhellofresh-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyhellofresh-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyhellofresh-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81dc6d907b7c3328eaea108d716606486e7eec9c4f0d1d6c07fe6dd833097975
MD5 88529f23465a9c4b730e5b43acf940a3
BLAKE2b-256 90cdf225f9da3147681ea167daa1bc03bd4506f9384de0faa977f2f5e74e2b79

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhellofresh-0.1.1-py3-none-any.whl:

Publisher: release.yml on pantherale0/pyhellofresh

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