Repository navigation
Installation
Bahasa / Language: English · Bahasa Indonesia
-
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
pip install satusehat-integrationpoetry add satusehat-integration
uv add satusehat-integrationpython -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"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_PRODThe 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.
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)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.
python-dotenv is not a dependency of the SDK. Install it separately if you want .env files:
pip install python-dotenvimport 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()))- Register at https://satusehat.kemkes.go.id/developer
- Create an OAuth2 application (Web Application)
- Generate client credentials
- Request scopes —
read:Patient,write:Patient,read:Encounter,write:Encounter, … - Register the public key (required for JWT authentication)
- Whitelist the server IP that will call the API
pip uninstall satusehat-integrationThe package writes nothing outside site-packages: no cache directory, no state file, no configuration in
$HOME.
-
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
pip install satusehat-integrationpoetry add satusehat-integration
uv add satusehat-integrationpython -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"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_PRODAkhiran 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.
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)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.
python-dotenv bukan dependensi SDK. Pasang terpisah bila ingin memakai berkas .env:
pip install python-dotenvimport 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 di https://satusehat.kemkes.go.id/developer
- Buat aplikasi OAuth2 (Web Application)
- Buat kredensial klien
- Minta scope —
read:Patient,write:Patient,read:Encounter,write:Encounter, … - Daftarkan public key (wajib untuk autentikasi JWT)
- Whitelist IP server yang akan memanggil API
pip uninstall satusehat-integrationPaket tidak menulis apa pun di luar site-packages: tanpa direktori cache, tanpa berkas status, tanpa
konfigurasi di $HOME.