@healthhero/sdk
v0.1.0
Published
HealthHero Standard API Client
Readme
HealthHero SDK TypeScript
JavaScript/TypeScript client for the HealthHero API
Usage
Install with your package manager of choice:
npm install @healthhero/sdkInitialise a client:
import { Client } from "@healthhero/sdk";
const client = new Client({
auth: {
clientId: "auth_client_id",
clientSecret: "auth_client_secret",
scope: "MSAPI_api",
},
baseURL: "https://api.healthhero.com",
clientId: "client_id",
});Authenticate:
await client.auth.token({ grantType: "client_credentials" });Fetch data from HealthHero API:
const bookings = await client.bookings.listByUserId("user_id");Authentication
There are various ways to authenticate with Standard API. Which one you use will depend on how your application is used.
If your response includes a refresh token (i.e. your scope included offline_access), then the client will attempt to automatically refresh your access token when it expires.
If the refresh token has expired, however, then the client will not be able to generate a new access token automatically, and you will need to make a request to generate a new access token.
client_credentials
The client_credentials grant type uses your client ID and secret to generate an access token.
password
The password grant type uses a username and password combination to generate an access token.
This strategy is commonly used when generating an access token on behalf of a user of your application.
refresh_token
The refresh_token grant type generates an access token from a refresh token.
When using this client, you typically will not need to use this grant type, as the client will attempt to automatically manage access and refresh tokens for you.
urn:ms:oauth:sso
The urn:ms:oauth:sso grant type generates an access token for an SSO user. If your application uses Single Sign-On, you will use this grant type.
Development
The following are prerequisites for developing this package:
- Node.js
- pnpm
Testing
Tests can be run with the pnpm run test command.
Building
The library can be built with the pnpm run build command.
