> For the complete documentation index, see [llms.txt](https://leenh.gitbook.io/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leenh.gitbook.io/api-docs/enpoints/consulta-dni.md).

# Consulta DNI

### Consideraciones

* Este servicio no se conecta con RENIEC
* El origen de datos depende del padrón reducido SUNAT y otras fuentes públicas.
* El padrón reducido SUNAT no devuelve datos de menores de edad, dirección, fecha nacimiento, sexo.
* En algunos casos no se obtendrá resultado de la consulta debido a la información de las fuentes públicas, esto no debe considerarse como falla o error del servicio.

## Consulta DNI

<mark style="color:blue;">`GET`</mark> `https://leenhcraft.com/api/dni/{dni}`

#### Headers

| Name                                 | Type   | Description                          |
| ------------------------------------ | ------ | ------------------------------------ |
| sk<mark style="color:red;">\*</mark> | String | palabra secreta                      |
| tk<mark style="color:red;">\*</mark> | String | token generado en la alta de usuario |

{% tabs %}
{% tab title="200: OK " %}

```json
{
	"success": true,
	"message": "Operación exitosa",
	"data": {
		"numero": "76144152",
		"nombre_completo": "BUSTAMANTE FERNANDEZ LEENH ALEXANDER",
		"nombres": "LEENH ALEXANDER",
		"apellido_paterno": "BUSTAMANTE",
		"apellido_materno": "FERNANDEZ",
		"direccion": "JR. SAN MARTIN C-02",
		"direccion_completa": "JR. SAN MARTIN C-02 SAN MARTIN RIOJA NUEVA CAJAMARCA",
		"departamento": "SAN MARTIN",
		"provincia": "RIOJA",
		"distrito": "NUEVA CAJAMARCA",
		"nombre_o_razon_social": "BUSTAMANTE FERNANDEZ LEENH ALEXANDER",
		"codigo_verificacion": "9",
		"ubigeo_reniec": "210505",
		"ubigeo": [
			"22",
			"2208",
			"220804"
		]
	}
}
```

{% endtab %}
{% endtabs %}

## Ejemplo de Uso

{% tabs %}
{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://leenhcraft.com/api/dni/{dni}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_SSL_VERIFYPEER => false
  CURLOPT_HTTPHEADER => [
    "sk: {...}",
    "tk: {...}"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="Respuesta" %}

```json
{
  "success": true,
  "message": "Operación exitosa",
  "data": {
    "numero": "76144152",
    "nombre_completo": "BUSTAMANTE FERNANDEZ LEENH ALEXANDER",
    "nombres": "LEENH ALEXANDER",
    "apellido_paterno": "BUSTAMANTE",
    "apellido_materno": "FERNANDEZ",
    "direccion": "JR. SAN MARTIN C-02",
    "direccion_completa": "JR. SAN MARTIN C-02 SAN MARTIN RIOJA NUEVA CAJAMARCA",
    "departamento": "SAN MARTIN",
    "provincia": "RIOJA",
    "distrito": "NUEVA CAJAMARCA",
    "nombre_o_razon_social": "BUSTAMANTE FERNANDEZ LEENH ALEXANDER",
    "codigo_verificacion": "9",
    "ubigeo_reniec": "210505",
    "ubigeo": ["22", "2208", "220804"]
  }
}
```

{% endtab %}
{% endtabs %}
