apple_health
apple_health
¶
Apple Health connector -- reads HealthKit SQLite DB or iPhone Health export XML.
Two data sources are tried in order:
1. HealthKit SQLite DB at ~/Library/Health/healthdb_secure.sqlite (macOS
with HealthKit sync enabled).
2. Health Export XML placed by the user at
~/.diapason/connectors/apple_health_export/export.xml.
Both are local-only; no API keys are needed.
Classes¶
AppleHealthConnector
¶
AppleHealthConnector(
*,
export_path: str = _DEFAULT_EXPORT_PATH,
healthkit_db_path: str = _DEFAULT_HEALTHKIT_DB_PATH,
)
Bases: BaseConnector
Sync health data from Apple Health (local files only).
Source code in src/diapason/connectors/apple_health.py
Methods:¶
is_connected
¶
Readable HealthKit database, or an export file we can open.
exists() on the HealthKit store is True under macOS TCC even when
every read is refused, so it could not distinguish "connected" from
"visible and forbidden". The export path is an ordinary file the user
placed themselves, so existence is the right question for it.
Source code in src/diapason/connectors/apple_health.py
sync
¶
sync(
*,
since: Optional[datetime] = None,
cursor: Optional[str] = None,
) -> Iterator[Document]
Yield health Documents, preferring HealthKit DB over export XML.