Skip to content

Installation

Ivan William Harsono edited this page Nov 17, 2026 · 3 revisions

Installation

Bahasa / Language: English · Bahasa Indonesia


English

Requirements

  • Python 3.10+ (requires-python = ">=3.10")
  • Runtime dependencies — requests>=2.31, pydantic>=2.0. Both are installed automatically; nothing else is needed and no extra is required for the SDK itself.
  • A SATUSEHAT developer account with OAuth2 client credentials (developer portal)
  • Outbound HTTPS to the SATUSEHAT host of the environment you target

Install

pip install satusehat-integration
poetry add satusehat-integration
uv add satusehat-integration

Verify the import before anything else

python -c "import satusehat_integration; print(satusehat_integration.__file__)"

If that raises ModuleNotFoundError, you are on a wheel older than 4.19.1 — upgrade; the package used to install top-level modules named builder and parser instead.

pip install -U "satusehat-integration>=4.19.1"

Configure

The client reads SATUSEHAT_ENV, then pulls credentials from environment-specific variables:

SATUSEHAT_ENV=DEV

# DEV
CLIENTID_DEV=your_client_id
CLIENTSECRET_DEV=your_client_secret
ORGID_DEV=your_organization_ihs_number

# STG
# CLIENTID_STG / CLIENTSECRET_STG / ORGID_STG
# PROD
# CLIENTID_PROD / CLIENTSECRET_PROD / ORGID_PROD

The suffix must match SATUSEHAT_ENV: DEV reads CLIENTID_DEV, STG reads CLIENTID_STG, PROD reads CLIENTID_PROD. The client raises OAuth2ClientException when one of the three is missing, so a silent failure is not possible here.

SATUSEHAT_ENV accepts DEV, STG, PROD — anything else raises instead of quietly pointing at DEV.

Pass values explicitly instead

Explicit arguments win over the environment, which is what most applications do:

from satusehat_integration import OAuth2Client

client = OAuth2Client(
    satusehat_env="DEV",
    client_id="your_client_id",
    client_secret="your_client_secret",
    organization_id="your_organization_ihs_number",
)

print(client.satusehat_env, client.base_url, client.organization_id)

Override the base URL

The default host per environment is:

DEV   https://api-satusehat-dev.dto.kemkes.go.id
STG   https://api-satusehat-stg.dto.kemkes.go.id
PROD  https://api-satusehat.kemkes.go.id

Override it with base_url= or with SATUSEHAT_BASE_URL_DEV / _STG / _PROD. Forking a proxy or a sandbox with a different hostname is the only reason to touch this.

Loading .env

python-dotenv is not a dependency of the SDK. Install it separately if you want .env files:

pip install python-dotenv
import os

from dotenv import load_dotenv

from satusehat_integration import OAuth2Client

load_dotenv()

client = OAuth2Client(satusehat_env=os.getenv("SATUSEHAT_ENV", "DEV"))
print("Token OK:", bool(client.token()))

Developer portal checklist

  1. Register at https://satusehat.kemkes.go.id/developer
  2. Create an OAuth2 application (Web Application)
  3. Generate client credentials
  4. Request scopes — read:Patient, write:Patient, read:Encounter, write:Encounter, …
  5. Register the public key (required for JWT authentication)
  6. Whitelist the server IP that will call the API

Removing it

pip uninstall satusehat-integration

The package writes nothing outside site-packages: no cache directory, no state file, no configuration in $HOME.


Bahasa Indonesia

Kebutuhan

  • Python 3.10+ (requires-python = ">=3.10")
  • Dependensi runtime — requests>=2.31, pydantic>=2.0. Keduanya terpasang otomatis; tidak ada dependensi lain dan tidak ada extra yang perlu dipilih untuk SDK ini.
  • Akun SATUSEHAT developer dengan kredensial OAuth2 (portal developer)
  • HTTPS keluar ke host SATUSEHAT sesuai environment yang dituju

Pasang

pip install satusehat-integration
poetry add satusehat-integration
uv add satusehat-integration

Pastikan impornya bekerja sebelum apa pun

python -c "import satusehat_integration; print(satusehat_integration.__file__)"

Kalau keluar ModuleNotFoundError, Anda memakai wheel lama sebelum 4.19.1 — perbarui; dulu paket ini memasang modul tingkat atas bernama builder dan parser.

pip install -U "satusehat-integration>=4.19.1"

Konfigurasi

Klien membaca SATUSEHAT_ENV, lalu mengambil kredensial dari variabel spesifik environment:

SATUSEHAT_ENV=DEV

# DEV
CLIENTID_DEV=your_client_id
CLIENTSECRET_DEV=your_client_secret
ORGID_DEV=your_organization_ihs_number

# STG
# CLIENTID_STG / CLIENTSECRET_STG / ORGID_STG
# PROD
# CLIENTID_PROD / CLIENTSECRET_PROD / ORGID_PROD

Akhiran harus cocok dengan SATUSEHAT_ENV: DEV membaca CLIENTID_DEV, STG membaca CLIENTID_STG, PROD membaca CLIENTID_PROD. Klien melempar OAuth2ClientException bila salah satu dari tiga tidak ada, jadi kegagalan diam-diam tidak mungkin terjadi di sini.

SATUSEHAT_ENV menerima DEV, STG, PROD — nilai lain langsung melempar galat, bukan diam-diam mengarah ke DEV.

Atau berikan nilainya langsung

Argumen eksplisit mengalahkan environment, dan inilah yang dipakai sebagian besar aplikasi:

from satusehat_integration import OAuth2Client

client = OAuth2Client(
    satusehat_env="DEV",
    client_id="your_client_id",
    client_secret="your_client_secret",
    organization_id="your_organization_ihs_number",
)

print(client.satusehat_env, client.base_url, client.organization_id)

Menimpa base URL

Host bawaan per environment:

DEV   https://api-satusehat-dev.dto.kemkes.go.id
STG   https://api-satusehat-stg.dto.kemkes.go.id
PROD  https://api-satusehat.kemkes.go.id

Timpa dengan base_url= atau SATUSEHAT_BASE_URL_DEV / _STG / _PROD. Alasannya hanya satu: proxy atau sandbox dengan nama host berbeda.

Memuat .env

python-dotenv bukan dependensi SDK. Pasang terpisah bila ingin memakai berkas .env:

pip install python-dotenv
import os

from dotenv import load_dotenv

from satusehat_integration import OAuth2Client

load_dotenv()

client = OAuth2Client(satusehat_env=os.getenv("SATUSEHAT_ENV", "DEV"))
print("Token OK:", bool(client.token()))

Daftar periksa portal developer

  1. Daftar di https://satusehat.kemkes.go.id/developer
  2. Buat aplikasi OAuth2 (Web Application)
  3. Buat kredensial klien
  4. Minta scope — read:Patient, write:Patient, read:Encounter, write:Encounter, …
  5. Daftarkan public key (wajib untuk autentikasi JWT)
  6. Whitelist IP server yang akan memanggil API

Mencopotnya

pip uninstall satusehat-integration

Paket tidak menulis apa pun di luar site-packages: tanpa direktori cache, tanpa berkas status, tanpa konfigurasi di $HOME.

Clone this wiki locally