Skip to main content

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 location
  • get_meter_summary(meter_id: str = None, account_id: str = None) - Get meter summary
  • close() - Close the underlying session

Response Types

OutageCheckResponse

  • success: bool
  • latitude: float
  • longitude: float
  • radius: int
  • summary: OutageSummary
  • poles: List[Pole]
  • credits_remaining: int

MeterSummaryResponse

  • success: bool
  • account_id: str
  • meter_id: str
  • consumer_name: str
  • energy_type: str
  • energy: int
  • is_prepaid: bool
  • token_estimate: TokenEstimate
  • billing_history: List[BillingEntry]
  • credits_remaining: int

License

MIT

Author

Akbar Naufal Awalin

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

padam_api-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

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

Hashes for padam_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cf89acf430c52b4687641dffa3a51fd6152704716e5a8d143f26cdd1e12e25f0
MD5 d3f3591bc5bf43b71b9825deef078e70
BLAKE2b-256 ec1d45177f609cc824bbb6cc445aec33f4a0539e0543b798e1b340055655041d

See more details on using hashes here.

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

Hashes for padam_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff158a287217d76a34214f1f58546dfccef8f612c3b1aa437d2976764a0447bf
MD5 8896f8004dfae61778345d893f8fa7c1
BLAKE2b-256 79b1d44c64200f227332a7559e8517e41ff584d72a8d10268d7708297779744b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page