Integrating Aadhaar card API in Android app: Need guidance

Hey everyone! I’m trying to add Aadhaar card functionality to my Android app but I’m hitting a wall. I’ve been looking at the developer docs and tried some code, but nothing seems to work. Has anyone successfully integrated this API before? What am I missing?

I’ve tried something like this:

public class AadhaarVerification {
    private static final String API_ENDPOINT = "https://example-aadhaar-api.com/verify";

    public boolean verifyAadhaar(String aadhaarNumber) {
        // API call setup
        URL url = new URL(API_ENDPOINT);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/json");

        // Send Aadhaar number
        String input = "{\"aadhaar\":\"" + aadhaarNumber + "\"}";
        OutputStream os = conn.getOutputStream();
        os.write(input.getBytes());
        os.flush();

        // Get response
        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String response = br.readLine();

        // Parse response and return result
        return response.contains("\"verified\":true");
    }
}

But it’s not working as expected. Any tips or suggestions would be really helpful. Thanks in advance!

I’ve worked with the Aadhaar API in a couple of projects, and I can tell you it’s not as straightforward as it seems. First off, you need to be a registered entity with UIDAI to access their API. It’s not publicly available.

Assuming you’ve got that sorted, your code looks like it’s trying to use a RESTful API, which isn’t how the Aadhaar system works. They use SOAP-based web services. You’ll need to generate client stubs from their WSDL file.

Also, direct online verification isn’t allowed anymore due to privacy concerns. You’ll need to use offline XML-based verification or the virtual ID system.

One more thing - make sure you’re following all the security protocols. Aadhaar data is sensitive, and there are strict guidelines on how to handle it. You might want to look into the Aadhaar Data Vault concept.

It’s a complex system, but once you get the hang of it, it’s pretty powerful. Good luck with your integration!

hey mate, i’ve dabbled with aadhaar api too. it’s a real headache! first off, u need official approval from UIDAI. then, forget REST - it’s all SOAP. gotta use their WSDL file to make client stubs. oh, and direct verification? nope. gotta use offline XML or virtual ID now. stay safe with the data too, its touchy stuff. good luck!

Having integrated the Aadhaar API in a recent project, I can share some insights. The process is indeed complex and requires official approval from UIDAI. Your current approach won’t work as the Aadhaar system uses SOAP, not REST. You’ll need to generate client stubs from their WSDL file and implement proper encryption for data transmission.

Additionally, be aware of the legal implications. Storing Aadhaar numbers directly is prohibited. You must use tokenization or UID tokens instead. The API also has strict rate limits and security protocols that you need to adhere to.

I’d recommend thoroughly reviewing the latest UIDAI documentation and perhaps consulting with a legal expert to ensure compliance. It’s a challenging integration, but crucial for many Indian apps. Best of luck with your implementation.