REST API from any language
The DevKit’s REST API lets any program use it over HTTP. Start the practice ABDM with node apps/cli/dist/main.js mock; it prints an address and a token. Send the token with every request as Authorization: Bearer <token>.
The one rule: prepare, then send
Section titled “The one rule: prepare, then send”Anything that sends a request to ABDM takes two calls, so a person always sees what is about to happen:
- Prepare.
POST .../preparechecks the request and returns a plain-Englishsummaryand anapprovalId. Show the summary to your user. - Send. If they agree,
POSTtheapprovalIdwith the same request. If the request changed, the approval was already used, or it is over 10 minutes old, you get409and nothing is sent.
Example in Python
Section titled “Example in Python”examples/python/consent_and_fetch.py does the whole flow with only Python’s standard library:
ABDM_DEVKIT_TOKEN=paste-your-token-here python3 examples/python/consent_and_fetch.pyThe core of it:
pending = call("POST", "/consent-requests/prepare", consent_request)print(pending["summary"]) # show this to your usersent = call("POST", "/consent-requests", {"approvalId": pending["approvalId"], "request": consent_request})consent = wait_for(f"/consent-requests/{sent['requestId']}", "state", "granted")See the REST API reference for every endpoint and error.