हर DPDP endpoint client.dpdp पर एक typed method के रूप में उपलब्ध है। Sub-client automatically attach होता है — एक RailScoreClient construct करें और client.dpdp.* के लिए reach करें। Async client (AsyncRAILClient) await client.dpdp.* पर same methods को expose करता है।
from rail_score_sdk import RailScoreClientclient = RailScoreClient(api_key="YOUR_RAIL_API_KEY")scan = client.dpdp.scan("Applicant PAN ABCDE1234F", pii_action="mask")
Aadhaar (Verhoeff-validated), PAN, UPI, mobile, और अन्य को detect करें, plus child signals (S.9) और purpose drift (S.4)। detect, mask, या block choose करें।
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])
emit 1–50 compliance events को write करता है और किसी भी statutory timers को auto-start करता है जो वह trigger करते हैं (उदाहरण के लिए, dsr.received response clock को start करता है)।
एक session एक data principal की journey को thread करता है। create_session को एक purpose require है — SDK अगर यह empty है तो immediately एक ValueError raise करता है (यह एक round trip को waste नहीं करेगा)।
Regulatory deadline timers को list करें, status, type, या कितने जल्दी वह due हैं के आधार पर filter करें।
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 एक system description की एक tiered compliance assessment को run करता है, entity-specific context और penalty-exposure scoring के साथ। यह hosted compliance check को wrap करता है, तो यह 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 जब pointed एक self-hosted agent पर जो audit को serve नहीं करता। print("dpdp_audit runs against the hosted API only.")
dpdp_audit और underlying compliance check hosted API पर ही उपलब्ध हैं। एक self-hosted RAIL agent के against SDK एक raw 404/501 की जगह DPDPHostedOnlyError raise करता है।
DPDP methods standard SDK errors को raise करते हैं (AuthenticationError, RateLimitError, InsufficientTierError for evidence जो 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")