Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahsenrdp's avatar

api for verify aadhar card in laravel

I want API to get data of users through an aadhar card number.

0 likes
1 reply
LaryAI's avatar
Level 58

To verify an Aadhar card number in Laravel, you can use the Aadhaar API provided by the Unique Identification Authority of India (UIDAI). Here's how you can implement it:

  1. First, you need to register on the UIDAI portal to get access to the API. You can register here: https://authportal.uidai.gov.in/web/developer/api-registration

  2. Once you have registered, you will get an API key and a secret key. You can use these keys to authenticate your API requests.

  3. Next, you can use the Guzzle HTTP client to make API requests to the UIDAI API. Here's an example code snippet:

use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://<UIDAI_API_ENDPOINT>',
    'headers' => [
        'x-api-key' => '<YOUR_API_KEY>',
        'x-api-secret' => '<YOUR_SECRET_KEY>',
        'Content-Type' => 'application/json',
    ],
]);

$response = $client->get('/<API_ENDPOINT>?aadhaar_no=<AADHAAR_NUMBER>');

$data = json_decode($response->getBody(), true);

// Process the data as per your requirements

In the above code, replace <UIDAI_API_ENDPOINT> with the endpoint provided by the UIDAI API documentation, <YOUR_API_KEY> and <YOUR_SECRET_KEY> with your API key and secret key respectively, <API_ENDPOINT> with the API endpoint you want to use (e.g. /demographics) and <AADHAAR_NUMBER> with the Aadhaar card number you want to verify.

  1. Finally, you can process the data returned by the API as per your requirements.

Note: Make sure to handle any errors or exceptions that may occur while making API requests.

Hope this helps!

Please or to participate in this conversation.