spezihealthkit
HealthKit module of the Stanford Spezi framework
Science Score: 77.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
2 of 7 committers (28.6%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
HealthKit module of the Stanford Spezi framework
Basic Info
- Host: GitHub
- Owner: StanfordSpezi
- License: mit
- Language: Swift
- Default Branch: main
- Homepage: https://swiftpackageindex.com/StanfordSpezi/SpeziHealthKit/documentation/
- Size: 974 KB
Statistics
- Stars: 30
- Watchers: 10
- Forks: 8
- Open Issues: 13
- Releases: 27
Topics
Metadata Files
README.md
Spezi HealthKit
Access Health data in your Spezi app.
Overview
The Spezi HealthKit module enables apps to integrate with Apple's HealthKit system, fetch data, set up long-lived background data collection, and visualize Health-related data.
Setup
You need to add the Spezi HealthKit Swift package to your app in Xcode or Swift package.
[!IMPORTANT]
If your application is not yet configured to use Spezi, follow the Spezi setup article to set up the core Spezi infrastructure.
Health Data Collection
Before you configure the HealthKit module, make sure your Standard in your Spezi Application conforms to the HealthKitConstraint protocol to receive HealthKit data.
The HealthKitConstraint/handleNewSamples(_:ofType:) function is called once for every batch of newly collected HealthKit samples, and the HealthKitConstraint/handleDeletedObjects(_:ofType:) function is called once for every batch of deleted HealthKit objects.
```swift
actor ExampleStandard: Standard, HealthKitConstraint {
// Add the newly collected HealthKit samples to your application.
func handleNewSamples
// Remove the deleted HealthKit objects from your application.
func handleDeletedObjects<Sample>(
_ deletedObjects: some Collection<HKDeletedObject>,
ofType sampleType: SampleType<Sample>
) async {
// ...
}
} ```
Then, you can configure the HealthKit module in the configuration section of your SpeziAppDelegate.
You can, e.g., use CollectSample to collect a wide variety of HealthKit data types:
swift
class ExampleAppDelegate: SpeziAppDelegate {
override var configuration: Configuration {
Configuration(standard: ExampleStandard()) {
HealthKit {
CollectSample(.activeEnergyBurned)
CollectSample(.stepCount, start: .manual)
CollectSample(.pushCount, start: .manual)
CollectSample(.heartRate, continueInBackground: true)
CollectSample(.electrocardiogram, start: .manual)
RequestReadAccess(quantity: [.bloodOxygen])
}
}
}
}
[!TIP] See
SampleTypefor a complete list of supported sample types.
Querying Health Data in SwiftUI
You can use SpeziHealthKitUI's HealthKitQuery and HealthKitStatisticsQuery property wrappers to access the Health database in a View:
```swift
struct ExampleView: View {
@HealthKitQuery(.heartRate, timeRange: .today)
private var heartRateSamples
var body: some View {
ForEach(heartRateSamples) { sample in
// ...
}
}
} ```
Additionally, you can use SpeziHealthKitUI's HealthChart to visualise query results:
```swift
struct ExampleView: View {
@HealthKitQuery(.heartRate, timeRange: .today)
private var heartRateSamples
var body: some View {
HealthChart {
HealthChartEntry($heartRateSamples, drawingConfig: .init(mode: .line, color: .red))
}
}
} ```
For more information, please refer to the API documentation.
The Spezi Template Application
The Spezi Template Application provides a great starting point and example using the SpeziHealthKit module.
Contributing
Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.
License
This project is licensed under the MIT License. See Licenses for more information.

Owner
- Name: Stanford Spezi
- Login: StanfordSpezi
- Kind: organization
- Repositories: 1
- Profile: https://github.com/StanfordSpezi
Citation (CITATION.cff)
# # This source file is part of the Stanford Spezi open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT # cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Schmiedmayer" given-names: "Paul" orcid: "https://orcid.org/0000-0002-8607-9148" - family-names: "Bauer" given-names: "Andreas" orcid: "https://orcid.org/0000-0002-1680-237X" - family-names: "Zagar" given-names: "Philipp" orcid: "https://orcid.org/0009-0001-5934-2078" - family-names: "Kehoe" given-names: "Niall" - family-names: "Sun" given-names: "Yuren" - family-names: "Ravi" given-names: "Vishnu" orcid: "https://orcid.org/0000-0003-0359-1275" - family-names: "Aalami" given-names: "Oliver" orcid: "https://orcid.org/0000-0002-7799-2429" title: "SpeziHealthKit" doi: 10.5281/zenodo.7824636 url: "https://github.com/StanfordSpezi/SpeziHealthKit"
GitHub Events
Total
- Create event: 34
- Release event: 11
- Issues event: 21
- Watch event: 10
- Delete event: 17
- Issue comment event: 54
- Push event: 269
- Pull request review comment event: 156
- Pull request review event: 132
- Pull request event: 46
- Fork event: 5
Last Year
- Create event: 34
- Release event: 11
- Issues event: 21
- Watch event: 10
- Delete event: 17
- Issue comment event: 54
- Push event: 269
- Pull request review comment event: 156
- Pull request review event: 132
- Pull request event: 46
- Fork event: 5
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Lukas Kollmer | h****y@l****e | 16 |
| Paul Schmiedmayer | P****r | 12 |
| Andreas Bauer | a****r@s****u | 3 |
| Philipp, Zagar | p****r@g****m | 2 |
| max-rosenblattl | m****l@g****m | 1 |
| Niall Kehoe | n****s@g****m | 1 |
| YurenSUN | y****n@s****u | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 16
- Total pull requests: 70
- Average time to close issues: 4 months
- Average time to close pull requests: 7 days
- Total issue authors: 4
- Total pull request authors: 12
- Average comments per issue: 0.38
- Average comments per pull request: 1.69
- Merged pull requests: 52
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 10
- Pull requests: 50
- Average time to close issues: 6 days
- Average time to close pull requests: 9 days
- Issue authors: 3
- Pull request authors: 9
- Average comments per issue: 0.1
- Average comments per pull request: 1.7
- Merged pull requests: 36
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- PSchmiedmayer (10)
- lukaskollmer (4)
- mjoerke (1)
- philippzagar (1)
Pull Request Authors
- lukaskollmer (36)
- PSchmiedmayer (12)
- Supereg (5)
- mjoerke (4)
- max-rosenblattl (4)
- philippzagar (3)
- nriedman (1)
- NIkhil-cmd-cmd (1)
- YurenSUN (1)
- niallkehoe (1)
- phnagy (1)
- vishnuravi (1)