This package provides a Go client for interacting with the Oura API (v2). It allows you to easily retrieve data from your Oura ring, including sleep and readiness information.
To use this package in your Go project, you can install it using go get
:
go get github.com/jjenkins/ouraring
Replace yourusername
with your actual GitHub username or organization name.
Here's a basic example of how to use the Oura API Go client:
package main
import (
"fmt"
"log"
"time"
"github.com/jjenkins/ouraring"
)
func main() {
// Create a new client with your Oura API token
client := ouraring.NewClient("your-api-token")
// Set the date range for which you want to retrieve data
startDate := time.Now().AddDate(0, 0, -7) // 7 days ago
endDate := time.Now()
// Get sleep data
sleepData, err := client.GetSleep(startDate, endDate)
if err != nil {
log.Fatalf("Error getting sleep data: %v", err)
}
// Print sleep data
for _, sleep := range sleepData {
fmt.Printf("Sleep on %s: %d minutes\n", sleep.Day, sleep.TotalSleepDuration/60)
}
// Get readiness data
readinessData, err := client.GetReadiness(startDate, endDate)
if err != nil {
log.Fatalf("Error getting readiness data: %v", err)
}
// Print readiness data
for _, readiness := range readinessData {
fmt.Printf("Readiness on %s: Score %d\n", readiness.Day, readiness.Score)
}
}
- Retrieve sleep data from the Oura API
- Retrieve readiness data from the Oura API
- Easy-to-use client with simple method calls
- Error handling for API requests
For full details on the Oura API, please refer to the official Oura API documentation.
Contributions to this package are welcome! Here are some ways you can contribute:
- Report bugs or request features by opening an issue
- Fix bugs or implement new features by submitting a pull request
- Improve documentation or add examples
Please ensure that your code adheres to the existing style and that all tests pass before submitting a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
This is an unofficial Oura API client and is not affiliated with or endorsed by Oura.
If you have any questions or feedback, please open an issue on the GitHub repository.