Every DPDP endpoint is available as a typed method on client.dpdp. The sub-client is attached automatically — construct a RailScoreClient and reach for client.dpdp.*. The async client (AsyncRAILClient) exposes the same methods on await client.dpdp.*.
from rail_score_sdk import RailScoreClientclient = RailScoreClient(api_key="YOUR_RAIL_API_KEY")scan = client.dpdp.scan("Applicant PAN ABCDE1234F", pii_action="mask")
Detect Aadhaar (Verhoeff-validated), PAN, UPI, mobile, and more, plus child signals (S.9) and purpose drift (S.4). Choose detect, mask, or block.
result = client.dpdp.scan( "Applicant PAN is ABCDE1234F and mobile 9876543210.", pii_action="detect", purpose="loan_advisory",)print(result.compliant, [p.type for p in result.pii_found])
A session threads one data principal’s journey together. create_session requires a purpose — the SDK raises ValueError immediately if it is empty (it will not waste a round trip).
List regulatory deadline timers, filtered by status, type, or how soon they are due.
timers = client.dpdp.list_timers(status="active", approaching_days=30)print(timers.summary.total_active)for t in timers.timers: print(t.type, t.days_remaining)
dpdp_audit runs a tiered compliance assessment of a system description, with entity-specific context and penalty-exposure scoring. It wraps the hosted compliance check, so it is hosted-only.
from rail_score_sdk import DPDPHostedOnlyErrortry: audit = client.dpdp.dpdp_audit( content="Our fintech processes Aadhaar for KYC; consent via checkbox.", entity_type="data_fiduciary", sector="finance", ) print(audit.overall_label, audit.total_penalty_exposure_crore)except DPDPHostedOnlyError: # Raised when pointed at a self-hosted agent that does not serve the audit. print("dpdp_audit runs against the hosted API only.")
dpdp_audit and the underlying compliance check are available on the hosted API only. Against a self-hosted RAIL agent the SDK raises DPDPHostedOnlyError instead of a raw 404/501.
The DPDP methods raise the standard SDK errors (AuthenticationError, RateLimitError, InsufficientTierError for evidence below Pro) plus DPDP-specific ones.
from rail_score_sdk import DPDPHostedOnlyErrorfrom rail_score_sdk import AuthenticationError, RateLimitErrortry: client.dpdp.scan("...", pii_action="block")except AuthenticationError: print("Check your API key")except RateLimitError: print("Slow down requests")