npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

satusehat-sdk

v0.0.2

Published

TypeScript SDK for SATUSEHAT API

Readme

SATUSEHAT SDK

TypeScript SDK for the SATUSEHAT API (Indonesian Health Data Integration).

⚠️ Peringatan: SDK ini masih dalam versi alpha dan belum direkomendasikan untuk digunakan di production. API dan fitur dapat berubah sewaktu-waktu tanpa pemberitahuan.

Features

  • OAuth 2.0 authentication with automatic token refresh
  • Type-safe FHIR resource operations
  • Support for development and production environments
  • Zero external dependencies (uses native fetch)

Installation

npm install satusehat-sdk

SDK ini sudah termasuk tipe-tipe FHIR R4 resmi dari @types/fhir, jadi tidak perlu menginstall dependency tambahan untuk type safety.

Quick Start

import { SatusehatClient } from 'satusehat-sdk';

const client = new SatusehatClient({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  environment: 'development', // or 'production'
});

// Get organization by ID
const organization = await client.organization.byId('7df3273e-8c9c-42de-b500-1bca74721111');
console.log(organization.name);

// Search organizations by name
const results = await client.organization.byName('RS Sehat');
console.log(`Found ${results.total} organizations`);

for (const entry of results.entry ?? []) {
  console.log(entry.resource.name);
}

API Reference

SatusehatClient

Main client for interacting with the SATUSEHAT API.

Constructor

new SatusehatClient(config: SatusehatConfig)

| Parameter | Type | Description | |-----------|------|-------------| | config.clientId | string | OAuth client ID from SATUSEHAT | | config.clientSecret | string | OAuth client secret from SATUSEHAT | | config.environment | 'development' \| 'production' | API environment |

Methods

| Method | Description | |--------|-------------| | getAccessToken() | Returns the current access token (auto-refreshes if expired) | | clearToken() | Clears the cached token, forcing refresh on next request |

client.organization

Organization resource operations.

| Method | Description | |--------|-------------| | byId(id: string) | Get an organization by its unique ID | | byName(name: string) | Search organizations by name (returns Bundle) |

Environments

| Environment | Auth URL | FHIR URL | |-------------|----------|----------| | development | https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1 | https://api-satusehat-stg.dto.kemkes.go.id/fhir-r4/v1 | | production | https://api-satusehat.kemkes.go.id/oauth2/v1 | https://api-satusehat.kemkes.go.id/fhir-r4/v1 |

Token Management

The SDK automatically handles OAuth token management:

  • Tokens are fetched on the first API request
  • Tokens are automatically refreshed 60 seconds before expiry
  • Use clearToken() to force a token refresh

Error Handling

SDK ini menyediakan error handling yang type-safe untuk response error dari SATUSEHAT API.

FhirOperationOutcomeError

Ketika API mengembalikan error dengan format FHIR OperationOutcome, SDK akan melempar FhirOperationOutcomeError yang memungkinkan akses type-safe ke detail error.

import { SatusehatClient, FhirOperationOutcomeError } from 'satusehat-sdk';

const client = new SatusehatClient({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  environment: 'development',
});

try {
  const patient = await client.fhir("Patient").get({ pathParams: "123" });
} catch (e) {
  if (e instanceof FhirOperationOutcomeError) {
    // Akses type-safe ke OperationOutcome
    console.log(e.operationOutcome.issue); // Detail issue dari server
    console.log(e.status); // HTTP status code (404, 400, dll)
    console.log(e.message); // Pesan error dari issue pertama
  } else {
    // Error lainnya (network error, parsing error, dll)
    console.log(e.message);
  }
}

| Property | Type | Deskripsi | |----------|------|-----------| | operationOutcome | fhir4.OperationOutcome | Object OperationOutcome lengkap dari server | | status | number | HTTP status code dari response | | message | string | Pesan error dari issue[0].diagnostics atau issue[0].details.text |

License

MIT