Official Python SDK for Padam.id PLN Outage API
Project description
padam-api
Official Python SDK for the Padam.id PLN Outage API - the first PLN outage API in Indonesia.
Installation
pip install padam-api
Quick Start
from padam_api import PadamClient
client = PadamClient(api_key="your_api_key")
# Check power outage at a location
outage = client.check_outage(-6.2088, 106.8456)
print(outage.summary.has_outage)
# Get meter billing and token estimate
meter = client.get_meter_summary(meter_id="566601485354")
print(meter.consumer_name)
Usage
Initialize Client
from padam_api import PadamClient
client = PadamClient(
api_key="your_api_key",
base_url="https://padam.id/api", # optional
timeout=10 # optional, default 10 seconds
)
Check Power Outage
Check for power outages within 500m radius of a location.
result = client.check_outage(-6.2088, 106.8456)
print(f"Total poles: {result.summary.total_poles}")
print(f"Poles ON: {result.summary.poles_on}")
print(f"Poles OFF: {result.summary.poles_off}")
print(f"Has outage: {result.summary.has_outage}")
# Iterate through poles
for pole in result.poles:
print(f"{pole.name}: {pole.status}")
Get Meter Summary
Get billing history and token estimate for a meter.
# Using meter ID (recommended)
result = client.get_meter_summary(meter_id="566601485354")
# Or using account ID
result = client.get_meter_summary(account_id="8651306")
print(f"Consumer: {result.consumer_name}")
print(f"Energy type: {result.energy_type}")
print(f"Energy: {result.energy} VA")
# Token estimate (prepaid meters)
if result.token_estimate:
print(f"Remaining days: {result.token_estimate.remaining_days}")
print(f"Remaining kWh: {result.token_estimate.remaining_kwh}")
print(f"Daily usage: {result.token_estimate.daily_usage_kwh} kWh")
# Billing history
for entry in result.billing_history:
print(f"{entry.date}: Rp {entry.amount:,} ({entry.kwh} kWh)")
Error Handling
from padam_api import PadamClient, PadamAPIError
try:
result = client.check_outage(-6.2088, 106.8456)
except PadamAPIError as e:
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print(f"Status code: {e.status_code}")
Context Manager
with PadamClient(api_key="your_api_key") as client:
result = client.check_outage(-6.2088, 106.8456)
print(result.summary.has_outage)
API Reference
PadamClient
Constructor
PadamClient(
api_key: str,
base_url: str = "https://padam.id/api",
timeout: int = 10
)
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | required | Your API key |
base_url |
str | https://padam.id/api |
API base URL |
timeout |
int | 10 |
Request timeout in seconds |
Methods
check_outage(latitude: float, longitude: float)- Check power outage at locationget_meter_summary(meter_id: str = None, account_id: str = None)- Get meter summaryclose()- Close the underlying session
Response Types
OutageCheckResponse
success: boollatitude: floatlongitude: floatradius: intsummary: OutageSummarypoles: List[Pole]credits_remaining: int
MeterSummaryResponse
success: boolaccount_id: strmeter_id: strconsumer_name: strenergy_type: strenergy: intis_prepaid: booltoken_estimate: TokenEstimatebilling_history: List[BillingEntry]credits_remaining: int
License
MIT
Author
Akbar Naufal Awalin
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
padam_api-1.0.0.tar.gz
(5.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file padam_api-1.0.0.tar.gz.
File metadata
- Download URL: padam_api-1.0.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf89acf430c52b4687641dffa3a51fd6152704716e5a8d143f26cdd1e12e25f0
|
|
| MD5 |
d3f3591bc5bf43b71b9825deef078e70
|
|
| BLAKE2b-256 |
ec1d45177f609cc824bbb6cc445aec33f4a0539e0543b798e1b340055655041d
|
File details
Details for the file padam_api-1.0.0-py3-none-any.whl.
File metadata
- Download URL: padam_api-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff158a287217d76a34214f1f58546dfccef8f612c3b1aa437d2976764a0447bf
|
|
| MD5 |
8896f8004dfae61778345d893f8fa7c1
|
|
| BLAKE2b-256 |
79b1d44c64200f227332a7559e8517e41ff584d72a8d10268d7708297779744b
|