Eko Platform Services Logo
All SDKs

Python SDK

eps-sdk is a standard-library-only client for every EPS API. One generic call(slug, params) covers all of them: the endpoint catalog, each endpoint's params and which of them are required are baked into the package from the same surface these docs are built from, so the client validates your input before it signs and sends anything.

Warning

Backend only. access_key signs every request — it must never reach a browser, a mobile app, or a notebook you share.

Install

pip install eps-sdk
View eps-sdk on PyPI
Package
eps-sdk
Requires
Python 3.10 or newer
Dependencies
None — standard library only (urllib, hmac, hashlib, mimetypes).
Source
GitHub

Your first call

Read the two keys from the environment, pick an environment, and call an endpoint by its slug:

import os
from eps_sdk import EpsClient
client = EpsClient(
developer_key=os.environ["EPS_DEVELOPER_KEY"],
access_key=os.environ["EPS_ACCESS_KEY"],
initiator_id="9962981729",
environment="sandbox",
)
result = client.call("pan-lite", {
"pan_number": "ABCDE1234F",
"name": "Rajesh Kumar",
"dob": "1994-08-29",
})
print(result)

initiator_id and user_code are near-constant per developer, so set them once on the client. They are injected into every call — pass either in params to override it for a single call, or pass None to clear it.

Client options

EpsClient is a dataclass, so every option is a keyword argument.

OptionTypeRequiredNotes
developer_keystrYesYour EPS developer key, sent as the developer_key header.
access_keystrYesServer-side secret used to sign every request. Never ships to a browser.
environment"sandbox" | "production"YesSelects the base URL from the embedded surface.
initiator_idstrNoDefault initiator_id (registered mobile of the API user) injected into every call.
user_codestrNoDefault user_code (retailer/agent code) injected into every call.
timeoutfloatNoWhole-request budget passed through to urlopen. (seconds, default 30.0)
retriesintNoExtra attempts for a call whose outcome was indeterminate (timeout, transport failure, HTTP 429/5xx, a 2xx that is not an EPS envelope) — only on endpoints marked retrySafe (idempotent, free, moves no money; plain GETs when the endpoint carries no such flag). Money-moving and paid calls are never re-sent. 0 disables. (default 2)
retry_base_delayfloatNoBackoff base: attempt n waits a random slice of min(base × 2^(n-1), 2s). (seconds, default 0.2)
auto_status_checkboolNoAfter an indeterminate failure on a money-moving endpoint, look the transaction up by its client_ref_id (or the tid on initiate-refund) and attach the result to the indeterminate error. Turning it off skips only that lookup — the call still fails with the indeterminate error carrying the ref, its inquiry fields empty. (default true)
debugbool | Callable[[dict], None] | NoneNoDebug mode: logs each request (full URL, headers, body), response (status, raw body), retry, transport failure and error as masked JSON lines, to share with Eko support. Unset, it follows the env var EPS_SDK_DEBUG (1 or true turns it on, no code change). Keys and personal data are masked best-effort; review the output before sharing. (True = stderr, callable = your sink, False = off)

API surface

The SDK is deliberately small. There is no method per endpoint — call() takes the slug, and the baked surface supplies the method, path, and validation rules. resolve_target() is the same pipeline stopping one step short of the network, which is the fastest way to see exactly what would be sent.

MemberSignatureWhat it does
EpsClient
class
EpsClient(developer_key, access_key, environment, initiator_id=None, user_code=None, timeout=30.0)The client — a dataclass, so keyword arguments read well.
call
method
client.call(slug: str, params: Mapping[str, Any] | None = None) -> AnyValidates, signs and sends one endpoint call; returns the decoded envelope.
resolve_target
method
client.resolve_target(slug, params=None) -> TargetThe signed method/url/body/headers for a call, without sending it. Useful for debugging.
build_headers
method
client.build_headers(multipart: bool = False) -> dict[str, str]The four auth headers for a single request.
sign_secret_key
function
sign_secret_key(access_key: str, timestamp: str) -> strThe raw signing primitive, exported for debugging.
MULTIPART_JSON_FIELD
constant
MULTIPART_JSON_FIELD = "form-data"Name of the single form field carrying the JSON envelope on file-upload endpoints.
Target
type
@dataclass Target(method, url, body, headers, multipart)What resolve_target returns.
generate_client_ref_id
function
generate_client_ref_id(now_ms: int) -> strThe 15-char client_ref_id generator call() uses for a non-GET call that did not supply one — exported so you can mint refs the same way.

Authentication

You never compute a signature yourself. On every request the client derives secret-key = base64(HMAC-SHA256(timestamp, base64(access_key))) and sends it with secret-key-timestamp and developer_key. sign_secret_key is exported only so you can reproduce a signature while debugging a 401.

File uploads

A single type: "file" param flips the whole request to multipart/form-data. You still pass every parameter flat; on the wire the SDK packs them the way the API expects — one form field named form-data holding all the non-file params as a single JSON object, plus one part per upload. A None param is dropped (a form field has no null encoding), while a None nested inside a dict value is preserved.

File params accept:

  • A path str or os.PathLike (the MIME type is guessed, falling back to application/octet-stream)
  • An in-memory (filename, bytes) tuple

Errors and timeouts

A non-2xx response raises — an auth or infrastructure failure is never returned as if it were a result. The decoded envelope is still on the exception, so you can read status and message off .body.

TypeRaised whenFields
EpsIndeterminateErrorA money-moving (financial) call whose outcome is unknown — timeout, transport failure, HTTP 429/5xx, or a 2xx that is not an EPS envelope. The SDK never re-sends it; it looks the transaction up by its client_ref_id (or, on an endpoint without one such as initiate-refund, the tid it acted on) and attaches the result. With the status check off, or no key to look up by, it skips the lookup and still throws this. For a refund only tx_status 4 confirms it; 3 settles nothing. Reconcile before retrying.slug, client_ref_id (or None), tid (or None), status (or None), status_check, status_check_error, __cause__
EpsHttpErrorAny non-2xx response..status, .url, .body (decoded envelope or None), .raw (bytes)
EpsInvalidResponseErrorA 2xx whose body is not an EPS envelope: not JSON, not a JSON object, no numeric status, or — on a money-moving endpoint — no numeric response_status_id (e.g. a proxy's {"status":502,…}). Never a silent empty result. On a money-moving call it becomes the cause of the indeterminate error; a retrySafe call is retried first. Subclasses EpsError..status, .url, .raw (bytes)
EpsErrorUnknown slug, missing required param, wrong param type, or an invalid param value — including a blank client_ref_id passed to a money-moving call (empty, or only whitespace / zero-width characters), refused before sending, or bad config. Every other SDK error subclasses it.—
urllib.error.URLErrorTransport failure or timeout on a call that is not money-moving (after any retries). Surfaced raw.—
HTTP statusMeaning
200OK — response returned by our system.
401Unauthorized — authentication failed. Known causes are reported in the body status (2483–2487).
404Not Found — wrong request URL.
405Method Not Allowed — incorrect HTTP method.
415Unsupported Media Type — wrong Content-Type header.
500Internal Server Error — connectivity or URL misconfiguration.

Debugging

When a call misbehaves, turn on debug mode and send the output to Eko support instead of just the response body: it shows exactly what was sent, to which environment, and what EPS replied.

No code change: set the env var and rerun.

EPS_SDK_DEBUG=1 python app.py

Or switch it in code:

EpsClient(..., debug=True) # JSON lines on stderr
EpsClient(..., debug=lambda event: log.debug(event)) # your logger (event is a dict)
EpsClient(..., debug=False) # off, even when EPS_SDK_DEBUG is set

Each event is one JSON object per line, for example:

{"logger":"eps-sdk","ts":"2026-11-23T11:31:25.884Z","event":"request","sdk":"js","sdk_version":"3.1.0","surface":"48eb0cf2","env":"sandbox","call_id":"f020eef5","slug":"bbps-operator-code-circle","attempt":1,"method":"GET","url":"https://staging.eko.in/ekoapi/v3/customer/payment/bbps/recharge/****3210/operator?initiator_id=****1729","headers":{"developer_key":"****wxyz","secret-key":"****","secret-key-timestamp":"1763897485884","content-type":"application/json"},"body":null}
  • **Events** — init once per client; request and response per attempt; transport_error when no usable response came back; retry; and error when the call throws. A validation failure logs error with no request before it, so you know nothing was sent. Lines of one call share a call_id.
  • **What it shows** — the environment (sandbox / production), the full URL, headers and body sent, the HTTP status and raw EPS response, timings, retries and the automatic status check.
  • **What it hides** — developer_key shows only its last 4 characters and secret-key is never shown. Aadhaar, PAN, account and mobile numbers show their last 4; OTPs, biometrics, names, addresses, e-mails, dates of birth and any field the SDK does not recognise print as ****. Ids, status codes, amounts and the EPS message print as-is so support can trace the call.
  • **Safe to leave in code** — off unless you switch it on; while off it costs nothing, and it never changes a call's outcome.
  • **Review before sharing** — masking is best-effort: free text such as an upstream error page is scrubbed but may still hold personal data. Share the output only with Eko support, and turn debug mode off when you are done.

Environments

Switch with the environment argument; there is no base-URL override.

EnvironmentBase URLNotes
sandbox
UAT / Sandbox
https://staging.eko.in/ekoapi/v3Credentials self-issued on signup. Use for development and testing. Login to Console to view your sandbox credentials.
production
Production
https://api.eko.in/ekoicici/v3Credentials issued after organizational KYC.

Python-specific notes

  • Paths are checked for existence during validation, so a typo fails before the request is signed.
  • The slug list is pinned to the SDK release, so a newly launched API fails with "Unknown endpoint slug" until you upgrade (pip install -U eps-sdk).

Every endpoint

call() accepts every slug in the EPS catalog. Each endpoint's reference page shows its parameters, response fields and a ready-to-paste Python snippet.

Browse the API reference
Next SDKPHP SDK