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.0.tar.gz (20.2 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.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyhellofresh-0.1.0.tar.gz
  • Upload date:
  • Size: 20.2 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.0.tar.gz
Algorithm Hash digest
SHA256 229a55a6824730a9de84509f0af6c481592b2a80025d929a90e73de7b529d010
MD5 303fe3b61c741e30e44e49aa375ef49c
BLAKE2b-256 5f69bfef3feaefaf0484385097b5ccb34ac7133d6a1dd60ec0d8c3da628aa75d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhellofresh-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: pyhellofresh-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f59c74cd547578c9da8256b1ba0bb8d048b425d5dffeae64ac9e98a6138417d6
MD5 c3681654a8573a207d078ee46707a294
BLAKE2b-256 17a92c3f2ec571a514327d315bc957fa83f8559022372840ae74c2b1e98232b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhellofresh-0.1.0-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