Async/sync Python client for the myORLEN eBOK (formerly PGNiG) self-care portal
Project description
myorlen-api
Python client library for the myORLEN eBOK self-care portal (gas accounts, formerly PGNiG). Reverse-engineered from browser traffic. Supports both async and sync usage.
Features
- Direct myORLEN eBOK login and OrlenID federated login (shared Orlen Group account)
- Automatic re-login on token expiry (tokens last ~1 hour, no refresh endpoint)
- Fetch account balance
- List invoices with pagination
- Download invoice PDFs
- MCP server for Claude and other AI assistants
Installation
From PyPI
pip install myorlen-api
From source (with uv)
git clone https://github.com/vincentto13/myorlen-api.git
cd myorlen-api
uv sync
Configuration
Set credentials for one of the following:
| Env vars | Login mode | Notes |
|---|---|---|
ORLENID_USERNAME + ORLENID_PASSWORD |
OrlenID (oid-ws.orlen.pl) |
Shared across Orlen Group services. Takes priority if both pairs are set. |
MYORLEN_USERNAME + MYORLEN_PASSWORD |
Native myORLEN eBOK | Use if you have a standalone account (formerly PGNiG). |
Usage
Async
from myorlen import MyOrlenClient
# Native myORLEN eBOK credentials
async with MyOrlenClient("user@example.com", "password") as client:
...
# OrlenID credentials (shared Orlen Group account)
async with MyOrlenClient("user@example.com", "orlenid-password", use_orlenid=True) as client:
print(client.user_info.first_name, client.user_info.last_name)
for agreement in client.agreements:
print(agreement.agreement_number, "active:", agreement.active)
for mp in client.metering_points:
print(mp.ppg_id, mp.tariff, mp.address)
balance = await client.get_balance()
print(balance.value, "PLN to pay:", balance.amount_to_pay, "PLN")
invoices = await client.get_invoices(page=1, page_size=12)
for inv in invoices:
print(inv.invoice_number, inv.issue_date, inv.amount, "PLN paid:", inv.is_paid)
# Download a PDF
pdf = await client.get_invoice_pdf(invoices[0].invoice_number)
Sync
from myorlen import MyOrlenClientSync
with MyOrlenClientSync("user@example.com", "orlenid-password", use_orlenid=True) as client:
balance = client.get_balance()
invoices = client.get_invoices()
pdf = client.get_invoice_pdf(invoices[0].invoice_number)
Development
MCP server — local setup with Claude Code
1. Install the MCP extra
uv sync --extra mcp
2. Export your credentials
# OrlenID (recommended — works across all Orlen Group services)
export ORLENID_USERNAME=you@example.com
export ORLENID_PASSWORD=your-orlenid-password
# — or — native myORLEN eBOK credentials
export MYORLEN_USERNAME=you@example.com
export MYORLEN_PASSWORD=your-myorlen-password
Persist in ~/.bashrc / ~/.zshrc so they're always available.
3. Verify the server starts
uv run python -m myorlen.mcp_server
The process should start and wait for MCP input on stdin (no output is normal — that's correct stdio behaviour). Press Ctrl+C to stop.
4. Connect Claude Code
The repo includes a .mcp.json that points Claude Code at the server automatically.
Open Claude Code from this project directory — it will pick up .mcp.json and prompt you to approve the server on first use.
Check the connection inside a Claude Code session:
/mcp
You should see myorlen listed as connected with 4 tools.
Running the smoke test (live API)
# OrlenID credentials
ORLENID_USERNAME=you@example.com ORLENID_PASSWORD=orlenid-secret uv run python scripts/smoke_test.py
# Native myORLEN credentials
MYORLEN_USERNAME=you@example.com MYORLEN_PASSWORD=myorlen-secret uv run python scripts/smoke_test.py
MCP Server
The library ships an MCP server that exposes your myORLEN gas account as tools for Claude and other MCP-compatible AI assistants.
Install
pip install myorlen-api[mcp]
Available tools
| Tool | Description |
|---|---|
get_account_info |
User profile, agreements and metering points (cached, no network request) |
get_balance |
Current balance and amount to pay |
get_invoices |
Paginated invoice list with gas consumption data |
download_invoice |
Download a PDF invoice — saves to a temp file and returns the path |
Run standalone
# OrlenID credentials
ORLENID_USERNAME=you@example.com ORLENID_PASSWORD=orlenid-secret uv run python -m myorlen.mcp_server
# Native myORLEN credentials
MYORLEN_USERNAME=you@example.com MYORLEN_PASSWORD=myorlen-secret uv run python -m myorlen.mcp_server
Claude Desktop configuration
Add to ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"myorlen": {
"command": "uv",
"args": ["run", "--project", "/path/to/myorlen-api", "python", "-m", "myorlen.mcp_server"],
"env": {
"ORLENID_USERNAME": "you@example.com",
"ORLENID_PASSWORD": "your-orlenid-password"
}
}
}
}
Use ORLENID_USERNAME/ORLENID_PASSWORD for OrlenID, or MYORLEN_USERNAME/MYORLEN_PASSWORD for native login. If both are set, OrlenID takes priority.
Note: Tokens expire after ~1 hour. The client re-logs in transparently up to 2 times before raising an error — no manual restart needed in most cases.
Example prompts
Ask Claude naturally:
- "What's my gas balance?"
- "Show me my last 3 gas invoices"
- "Do I have any unpaid gas bills?"
- "What's my gas consumption for the last invoice?"
- "Download the latest invoice"
Acknowledgements
This library was built with the help of Claude (Anthropic's AI assistant). Claude assisted with reverse-engineering the authentication flow from browser HAR captures, designing the library architecture, and implementing the async/sync client and MCP server.
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
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 myorlen_api-0.1.0.tar.gz.
File metadata
- Download URL: myorlen_api-0.1.0.tar.gz
- Upload date:
- Size: 96.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aeaeb423493fb06fb97b29e7344eb3257f6b16eb0de84022a23978977183d5e
|
|
| MD5 |
41e74d1b52f9cc86657aa55d52b61f7f
|
|
| BLAKE2b-256 |
1240a877067e5f51174a078cb6f66a84f6cbe683d70787a35d57ad9b6ec1c981
|
File details
Details for the file myorlen_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: myorlen_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52da635ba2579d6f73c82d7e97fc681e979ff3320a3e8d71517ffa4c28700226
|
|
| MD5 |
56646e58e89179b816fd08c15f71bcd4
|
|
| BLAKE2b-256 |
f9b7d47f58e80f9e891d846ec5ce5314d73bf066c7603bcc392caaf2f20794b6
|