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

@digitalmedika/bpjs-apotek

v1.0.5

Published

Unofficial BPJS Apotek Online Bridging Library

Readme

BPJS Apotek Online Bridging API (Unofficial)

Library TypeScript/Bun untuk melakukan bridging dengan layanan Apotek Online (Apon) dari BPJS Kesehatan. Library ini menangani seluruh proses otentikasi (Signature), enkripsi/dekripsi data, dan kompresi (LZ-String) secara otomatis.

Fitur Utama

  • Otentikasi Otomatis: Generate X-cons-id, X-timestamp, X-signature secara otomatis.
  • Auto Decryption: Respon terenkripsi dari BPJS langsung didekripsi (AES + LZ-String) sehingga siap pakai.
  • Type-Safe: Menggunakan TypeScript dengan interface yang didefinisikan untuk response API.
  • Modular: Terbagi berdasarkan modul fungsi (Referensi, Resep, SEP, dll).
  • Tests Included: Dilengkapi dengan Integration Test menggunakan Bun Test Runner.

Prasyarat

  • Bun runtime environment.

Instalasi

Install package dari npm registry:

bun add @digitalmedika/bpjs-apotek

Konfigurasi

Buat file .env pada root project Anda dan isi dengan kredensial bridging Apotek Online:

APOTEK_CONS_ID=no_cons_id_anda
APOTEK_SECRET_KEY=secret_key_anda
APOTEK_USER_KEY=user_key_anda
APOTEK_BASE_URL=https://apijkn-dev.bpjs-kesehatan.go.id/apotek-rest-dev
APOTEK_KDPPK=kode_ppk_anda

Cara Penggunaan

Library ini dirancang agar mudah digunakan tanpa perlu memikirkan proses enkripsi/dekripsi.

Inisialisasi

import { ApotekOnline } from "@digitalmedika/bpjs-apotek";

// Opsi 1: Otomatis load dari .env
const apotek = new ApotekOnline();

// Opsi 2: Manual Configuration
const apotek = new ApotekOnline({
    consId: "12345",
    secretKey: "secret",
    userKey: "userkey",
    baseUrl: "https://api.bpjs...",
    kdppk: "0112A017",
});

Contoh Request

Setiap method mengembalikan Promise yang berisi object response BPJS yang sudah didekripsi.

// 1. Cek Referensi Poli
const response = await apotek.referensi.poli("ICU");

if (response.metaData.code === "200") {
    console.log("Daftar Poli:", response.response.list);
} else {
    console.error("Error:", response.metaData.message);
}

// 2. Cek Referensi DPHO
const dpho = await apotek.referensi.dpho();

// 3. Cari SEP
const sep = await apotek.sep.cari("1234567890123456789");

Daftar Modul API

Library ini mencakup modul-modul berikut sesuai dokumentasi BPJS Apotek Online:

1. Referensi (apotek.referensi)

  • dpho(): Ambil daftar obat DPHO.
  • poli(keyword): Cari poli.
  • faskes(jenis, nama): Cari Faskes 1 atau RS.
  • settingApotek(kodeApotek): Baca setting PPK.
  • spesialistik(): Referensi spesialistik.
  • obat(jenis, tanggal, filter): Cari referensi obat (Jadi/Racikan).

2. Resep (apotek.resep)

  • simpan(data: ResepSimpanRequest): Bridging simpan resep.
  • hapus(data: ResepHapusRequest): Hapus resep (DELETE, Content-Type: application/x-www-form-urlencoded).
  • daftar(data: ResepDaftarRequest): Lihat daftar resep.

Contoh simpan resep:

const response = await apotek.resep.simpan({
    TGLSJP: "2021-08-05 18:13:11",
    REFASALSJP: "1202R0010318V000092",
    POLIRSP: "IPD",
    KDJNSOBAT: "2",
    NORESEP: "12346",
    IDUSERSJP: "USR-01",
    TGLRSP: "2021-08-05 00:00:00",
    TGLPELRSP: "2021-08-05 00:00:00",
    KdDokter: "0",
    iterasi: "0",
});

Contoh hapus resep:

const response = await apotek.resep.hapus({
    nosjp: "1202A00201210000032",
    refasalsjp: "1202R0010121V000325",
    noresep: "0SI44",
});

3. Obat (apotek.obat)

  • simpanNonRacikan(data: ObatNonRacikanSimpanRequest): Simpan obat non racikan.
  • simpanRacikan(data: ObatRacikanSimpanRequest): Simpan obat racikan.
  • updateStok(data: ObatUpdateStokRequest): Update stok obat.

4. Pelayanan Obat (apotek.pelayananObat)

  • daftar(nomorSep): Daftar pelayanan obat by SEP.
  • hapus(data: PelayananObatHapusRequest): Hapus pelayanan obat.
  • riwayat(awal, akhir, noKartu): Riwayat obat pasien.

5. SEP (apotek.sep)

  • cari(nomorSep): Cari data SEP, mengembalikan BpjsResponse<SepData>.

6. Monitoring (apotek.monitoring)

  • dataKlaim(bulan, tahun, jenisObat, status): Monitoring data klaim.

7. PRB (apotek.prb)

  • rekapPeserta(tahun, bulan): Rekap Peserta PRB yang baru dilakukan PRB oleh RS.

Testing

Project ini menggunakan library testing bawaan Bun.

Pastikan dependencies sudah terpasang dan file .env terisi dengan kredensial Development (Dev) yang valid sebelum menjalankan test.

bun install
bun test

Struktur Project

├── src/
│   ├── core/           # Logic utama (Signature, HTTP Client, Decryption)
│   ├── features/       # Modul API individual (Referensi, Resep, dll)
│   ├── types/          # TypeScript Interfaces
│   └── ApotekOnline.ts # Class utama (Main entry point)
├── tests/              # Integration tests
├── .env                # File konfigurasi (credential)
└── README.md           # Dokumentasi