New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

oura_api

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oura_api

ŌURA Cloud API. Interact with v2 of the Oura API using Personal Access Tokens, OAuth2, or the Sandbox environment. Includes support for the Webhook subscriptions.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
105
decreased by-17.32%
Maintainers
0
Weekly downloads
 
Created
Source

OURA_API

Interact with v2 of the Oura API using Personal Access Tokens, OAuth2, or the Sandbox environment.

Available as:

  • ESM module: JSR
  • CommonJS module: NPM

⚡️ Quickstart

Installation

# Deno
deno add @pinta365/oura-api

# Bun
bunx jsr add @pinta365/oura-api

# Node.js
npx jsr add @pinta365/oura-api

# NPM (CommonJS)
npm install oura_api --save

Basic Usage (ESM)

import { Oura } from "@pinta365/oura-api";

const accessToken = "YOUR_PERSONAL_ACCESS_TOKEN";
const oura = new Oura(accessToken);

const personalInfo = await oura.getPersonalInfo();
console.log(personalInfo);

Basic Usage (CommonJS)

const { Oura } = require("oura_api");
// ... (same as above)

See the examples folder for more detailed implementations.

🧪 Sandbox Environment (Testing)

The Oura API's sandbox environment (Docs) is perfect for development. It provides sample data so you don't need a real Oura account to test your application.

const ouraSandboxClient = new Oura({ useSandbox: true });
// ...Make API calls with `ouraSandboxClient`

🔑 OAuth2 Support

Our library simplifies OAuth2 authentication with these functions:

  • generateAuthUrl(scopes: string[], state?: string): string

    • Generates the authorization URL for the user.
  • async exchangeCodeForToken(code: string): Promise<OAuth2TokenResponse>

    • Exchanges the received authorization code for access and refresh tokens.
  • async refreshAccessToken(suppliedRefreshToken: string): Promise<OAuth2TokenResponse>

    • Refreshes an expired access token.
  • async revokeAccessToken(accessToken: string): Promise<boolean>

    • Revokes the specified access token.

Example Usage (Simplified) See the examples folder for a basic implementation using Hono.

import { OuraOAuth } from "@pinta365/oura-api";

const oura = new OuraOAuth({
    clientId: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET",
    redirectUri: "http://localhost:8000/callback",
});

// 1. Generate the authorization URL
const authUrl = oura.generateAuthUrl(["personal"]);

// 2. Redirect the user to `authUrl`
// ... (Implementation in your web application)

// 3. In your callback route, exchange the code for tokens
app.get("/callback", async (c) => {
    const code = c.req.query("code");
    const tokens = await oura.exchangeCodeForToken(code);

    // ... Store tokens securely and use the access_token for API calls
});

📑 Documentation

Included data scopes for v2 of the API.

Endpoint/ScopeStatus
Oura Base docs
Daily ActivityImplemented
Daily Cardiovascular AgeImplemented
Daily ReadinessImplemented
Daily ResilienceImplemented
Daily SleepImplemented
Daily Spo2Implemented
Daily StressImplemented
Enhanced TagImplemented
Heart RateImplemented
Personal InfoImplemented
Rest Mode PeriodImplemented
Ring ConfigurationImplemented
SessionImplemented
SleepImplemented
Sleep TimeImplemented
TagDEPRECATED
Vo2 MaxImplemented
WorkoutImplemented
Webhook Subscription docs
List subscriptionImplemented
Create subscriptionImplemented
Update subscriptionImplemented
Delete subscriptionImplemented
Renew subscriptionImplemented

Additional info concerning the webhook API

Webhooks enable near real-time Oura data updates and are recommended for getting the latest information. The subscription workflow is implemented in this library – see the Webhook docs for details.

⚠️ I have not been able to fully verify this yet but the subscription workflow has been implemented.

🐞 Issues

Please report any issues or questions on the GitHub repository.

📄 License

MIT License - see the LICENSE file.

Keywords

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc