tai-sho/oura-api-php

A PHP client library for the Oura Ring API

v1.0.1 2024-06-09 06:59 UTC

This package is auto-updated.

Last update: 2024-11-06 20:37:23 UTC


README

Latest Stable Version Build Status Coverage Status PHP Version License Twitter Follow

A PHP client library for the Oura Ring API.

Requirements

  • PHP 7.4 or higher
  • Composer
  • Oura Personal Access Token (see below for more information)

Installation

You can install the library via Composer. Run the following command:

$ composer require tai-sho/oura-api-php

Usage

Personal Access Token

This library requires a personal access token to authenticate with the Oura API. You can obtain a personal access token from the Oura page: Oura API Doc

Initialization

First, you need to initialize the client with your API access token.

require 'vendor/autoload.php';

use OuraApiPhp\Client;

$accessToken = 'your-access-token';
$client = new Client($accessToken);

Examples

Get Heart Rate Data

$params = ['start_date' => '2024-01-01', 'end_date' => '2024-01-07'];
$response = $client->getHeartRate($params);
$data = json_decode($response->getBody()->getContents(), true);
print_r($data);

Get Personal Info

$response = $client->getPersonalInfo();
$data = json_decode($response->getBody()->getContents(), true);
print_r($data);

Get Workout Data

$params = ['start_date' => '2024-01-01', 'end_date' => '2024-01-07'];
$response = $client->getWorkout($params);
$data = json_decode($response->getBody()->getContents(), true);
print_r($data);

Get All Heart Rate Data (Handling Pagination)

$params = ['start_date' => '2024-01-01', 'end_date' => '2024-01-07'];
$responses = $client->getAllHeartRateData($params);
foreach ($responses as $response) {
    $data = json_decode($response->getBody()->getContents(), true);
    print_r($data);
}

Available Endpoints

The client supports the following endpoints:

  • getHeartRate(array $params = [])
  • getPersonalInfo(array $params = [])
  • getTag(array $params = [])
  • getEnhancedTag(array $params = [])
  • getWorkout(array $params = [])
  • getSession(array $params = [])
  • getDailyActivity(array $params = [])
  • getDailySleep(array $params = [])
  • getDailySpo2(array $params = [])
  • getDailyReadiness(array $params = [])
  • getSleep(array $params = [])
  • getSleepTime(array $params = [])
  • getRestModePeriod(array $params = [])
  • getRingConfiguration(array $params = [])
  • getDailyStress(array $params = [])
  • getTagById(string $documentId, array $params = [])
  • getEnhancedTagById(string $documentId, array $params = [])
  • getWorkoutById(string $documentId, array $params = [])
  • getSessionById(string $documentId, array $params = [])
  • getDailyActivityById(string $documentId, array $params = [])
  • getDailySleepById(string $documentId, array $params = [])
  • getDailySpo2ById(string $documentId, array $params = [])
  • getDailyReadinessById(string $documentId, array $params = [])
  • getSleepById(string $documentId, array $params = [])
  • getSleepTimeById(string $documentId, array $params = [])
  • getRestModePeriodById(string $documentId, array $params = [])
  • getRingConfigurationById(string $documentId, array $params = [])
  • getDailyStressById(string $documentId, array $params = [])

Get All Data Functions (Handling Pagination)

  • getAllHeartRateData(array $params = [])
  • getAllWorkoutData(array $params = [])
  • getAllTagData(array $params = [])
  • getAllEnhancedTagData(array $params = [])
  • getAllSessionData(array $params = [])
  • getAllDailyActivityData(array $params = [])
  • getAllDailySleepData(array $params = [])
  • getAllDailySpo2Data(array $params = [])
  • getAllDailyReadinessData(array $params = [])
  • getAllSleepData(array $params = [])
  • getAllSleepTimeData(array $params = [])
  • getAllRestModePeriodData(array $params = [])
  • getAllRingConfigurationData(array $params = [])
  • getAllDailyStressData(array $params = [])

Contributing

Welcome contributions! Please submit a pull request or open an issue to discuss changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.