Huckleberry API
Python API client for the Huckleberry baby tracking app using Firebase Firestore.
Overview
This is a reverse-engineered API client that connects directly to Huckleberry's Firebase backend using the official Google Cloud Firestore SDK. It provides programmatic access to baby tracking features including sleep, feeding, diaper changes, and growth measurements.
Features
- 🔐 Firebase Authentication: Secure email/password authentication with automatic token refresh
- 💤 Sleep Tracking: Start, pause, resume, cancel, and complete sleep sessions
- 🍼 Feeding Tracking: Track breastfeeding with left/right side switching
- 🤱 Pumping Tracking: Log pumping sessions and fetch latest/history
- 🧷 Diaper Changes: Log pee, poo, both, or dry checks with color/consistency
- 📏 Growth Measurements: Record weight, height, and head circumference
- 🔄 Real-time Updates: Firebase snapshot listeners for instant synchronization
- 👶 Child Management: Support for multiple children profiles
Installation
uv add huckleberry-api
# or
pip install huckleberry-api
Quick Start
import asyncio
from datetime import datetime, timedelta
import aiohttp
from huckleberry_api import HuckleberryAPI
async def main() -> None:
async with aiohttp.ClientSession() as websession:
api = HuckleberryAPI(
email="your-email@example.com",
password="your-password",
timezone="Europe/London",
websession=websession,
)
await api.authenticate()
user_doc = await api.get_user()
child_uid = user_doc.childList[0].cid
await api.start_sleep(child_uid)
await api.complete_sleep(child_uid)
await api.log_sleep(
child_uid,
start_time=datetime.now() - timedelta(hours=3),
end_time=datetime.now() - timedelta(hours=2),
)
await api.start_nursing(child_uid, side="left")
await api.switch_nursing_side(child_uid)
await api.complete_nursing(child_uid)
await api.log_nursing(
child_uid,
start_time=datetime.now() - timedelta(hours=4),
end_time=datetime.now() - timedelta(hours=3, minutes=30),
side="right",
)
await api.log_bottle(
child_uid,
start_time=datetime.now() - timedelta(hours=1),
amount=120.0,
bottle_type="Formula",
units="ml",
)
await api.log_pump(
child_uid,
start_time=datetime.now(),
total_amount=120.0,
duration=900,
units="ml",
)
await api.log_diaper(
child_uid,
start_time=datetime.now() - timedelta(minutes=45),
mode="both",
pee_amount="medium",
poo_amount="medium",
color="yellow",
consistency="solid",
)
await api.log_growth(
child_uid,
start_time=datetime.now() - timedelta(days=1),
weight=5.2,
height=52.0,
head=35.0,
units="metric",
)
await api.log_temperature(
child_uid,
start_time=datetime.now(),
amount=37.2,
units="C",
)
asyncio.run(main())
Real-time Listeners
Set up real-time listeners for instant updates:
import aiohttp
def on_sleep_update(data):
timer = data.get("timer", {})
print(f"Sleep active: {timer.get('active')}")
print(f"Sleep paused: {timer.get('paused')}")
async def main() -> None:
async with aiohttp.ClientSession() as websession:
api = HuckleberryAPI(
email="your-email@example.com",
password="your-password",
timezone="Europe/London",
websession=websession,
)
await api.authenticate()
user_doc = await api.get_user()
child_uid = user_doc.childList[0].cid
await api.setup_sleep_listener(child_uid, on_sleep_update)
await api.stop_all_listeners()
API Methods
Authentication
await authenticate()- Authenticate with Firebaseawait ensure_session()- Ensure valid auth/session stateawait refresh_session_token()- Refresh expired token
Children
await get_user()- Get fullusers/{uid}documentawait get_child(child_uid)- Get a single child profile by id
Sleep Tracking
await get_sleep(child_uid)- Get the typed sleep document and current timer stateawait start_sleep(child_uid)- Start sleep sessionawait pause_sleep(child_uid)- Pause active sessionawait resume_sleep(child_uid)- Resume paused sessionawait cancel_sleep(child_uid)- Cancel without savingawait complete_sleep(child_uid)- Complete and save to historyawait log_sleep(child_uid, start_time=..., end_time=..., details=None)- Log a completed sleep interval with explicit timestamps
Feeding Tracking
await get_nursing(child_uid)- Get the typed feeding document and current nursing timer stateawait start_nursing(child_uid, side)- Start breastfeeding sessionawait pause_nursing(child_uid)- Pause active sessionawait resume_nursing(child_uid, side)- Resume paused sessionawait switch_nursing_side(child_uid)- Switch left/rightawait cancel_nursing(child_uid)- Cancel without savingawait complete_nursing(child_uid)- Complete and save to historyawait log_nursing(child_uid, start_time=..., end_time=..., side="left")- Log a completed breastfeeding interval with explicit timestampsawait log_bottle(child_uid, start_time=..., amount=..., bottle_type=..., units=...)- Log bottle feeding with an explicit event timestampbottle_type: "Breast Milk", "Formula", "Cow Milk", "Soy Milk", etc.amount: Volume fed (e.g., 120.0)units: "ml" or "oz"
Pumping Tracking
await log_pump(child_uid, start_time=..., total_amount=..., duration=..., units=...)- Log pumping entry; total entries are stored split evenly acrossleftAmountandrightAmountawait list_pump_intervals(child_uid, start_time, end_time)- List pump history for a range usingdatetimeobjects
Solids Tracking
await list_solids_curated_foods()- List curated solids food catalogawait list_solids_custom_foods(child_uid, include_archived=False)- List custom solids foodsawait create_solids_custom_food(child_uid, name, image="")- Create custom solids foodawait log_solids(child_uid, start_time=..., foods=..., notes="", reaction=None, food_note_image=None)- Log solids meal with an explicit event timestamp
Diaper Tracking
await log_diaper(child_uid, start_time=..., mode=..., pee_amount=..., poo_amount=..., color=..., consistency=...)- Log diaper change with an explicit event timestampawait log_potty(child_uid, start_time=..., mode=..., how_it_happened=..., pee_amount=..., poo_amount=..., color=..., consistency=...)- Log potty event with an explicit event timestampmode: "pee", "poo", "both", or "dry"color: "yellow", "green", "brown", "black", "red"consistency: "runny", "soft", "solid", "hard"
Growth Tracking
await log_growth(child_uid, start_time=..., weight=..., height=..., head=..., units=...)- Log measurements with an explicit event timestampunits: "metric" (kg/cm) or "imperial" (lbs/inches)
await get_latest_growth(child_uid)- Get latest measurements
Temperature Tracking
await log_temperature(child_uid, start_time=..., amount=..., units=..., notes=None)- Log a body-temperature measurementunits:"C"for Celsius or"F"for Fahrenheit
Real-time Listeners
await setup_sleep_listener(child_uid, callback)- Listen to sleep updatesawait setup_feed_listener(child_uid, callback)- Listen to feeding updatesawait setup_health_listener(child_uid, callback)- Listen to health updatesawait setup_pump_listener(child_uid, callback)- Listen to pump updatesawait stop_all_listeners()- Stop all active listeners
Type Definitions
The package includes Pydantic models for type safety.
Canonical Firebase schema definitions are in src/huckleberry_api/firebase_types.py.
FirebaseChildDocument- Child profile informationFirebaseSleepDocumentData/FirebaseSleepTimerData- Sleep tracking dataFirebaseFeedDocumentData/FirebaseFeedTimerData- Feeding tracking dataFirebaseHealthDocumentData- Health tracking dataFirebaseGrowthData- Growth measurements
Architecture
This library uses:
- Firebase Firestore Python SDK - Official Google Cloud SDK (not REST API)
- gRPC over HTTP/2 - Real-time communication protocol
- Protocol Buffers - Efficient data encoding
- Firebase Authentication - Secure token-based auth
Why Not REST API?
Huckleberry's Firebase Security Rules block non-SDK requests. Direct REST API calls return 403 Forbidden. This library uses the official Firebase SDK which uses gRPC, the same protocol as the Huckleberry mobile app.
Requirements
- Python 3.14+
google-cloud-firestore>=2.11.0aiohttp>=3.10.0pydantic>=2.10.0
Development
Running Tests
Integration tests require Huckleberry account credentials:
# Set environment variables
$env:HUCKLEBERRY_EMAIL = "test@example.com"
$env:HUCKLEBERRY_PASSWORD = "test-password"
# Run tests
.\run-tests.ps1
Linting, Formatting, and Type Checking
# Lint
uv run ruff check .
# Format
uv run ruff format .
# Type check
uv run ty check --python-version 3.14 --ignore unknown-argument
# Add release notes about your feature
uv run towncrier create
# Build release notes from fragments when cutting a release
uv run towncrier build --yes --version <version>
See tests/README.md for detailed testing documentation.
CI/CD
- PR Validation runs on pull requests and pushes to
mainand checks Ruff linting/formatting and Ty type checking. - Integration tests run on GitHub Actions and require Huckleberry credentials.
License
MIT License
Disclaimer
This is an unofficial, reverse-engineered API client. It is not affiliated with, endorsed by, or connected to Huckleberry Labs Inc. Use at your own risk.
Related Projects
- Huckleberry Home Assistant Integration - Home automation integration using this library
Metadata
Release files for huckleberry-api 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| huckleberry_api-0.4.4.tar.gz | 26.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| huckleberry_api-0.4.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.8 kB
Release files / huckleberry_api-0.4.4.tar.gz
| Download URL | huckleberry_api-0.4.4.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5726ef86ac7c217c29611e6c4a7b2c17363154977dbe5009bf8415ac64d121c5
|
|
BLAKE2b-256 checksum How to use checksums |
7ef95fbcc252195517a8c04dc5b182aa842640454ab0a2727209fa0c1159e3e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / huckleberry_api-0.4.4-py3-none-any.whl
| Download URL | huckleberry_api-0.4.4-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c096f0504e86989fc72e54a41e24ce979736af72b96de5a91e79a471948f284
|
|
BLAKE2b-256 checksum How to use checksums |
dcbe16a4c7418e438ba5e295720cfd956e10263d0701637cacf12825cc0ac58a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency log