# 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.

<mark style="color:green;">`POST`</mark> `https://apiperu.dev/api/dni`&#x20;

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Accept        | String | application/json |
| Content-Type  | string | application/json |
| Authorization | string | Bearer \<token>  |

#### Body

| Name                                  | Type   | Description |
| ------------------------------------- | ------ | ----------- |
| dni<mark style="color:red;">\*</mark> | String | 8 dígitos   |

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

```json
{
    "success": true,
    "data": {
        "numero": "7**7**53",
        "nombre_completo": "PE** A**LAR, CA***INA",
        "nombres": "CA***INA",
        "apellido_paterno": "PE**",
        "apellido_materno": "A**LAR",
        "codigo_verificacion": "8"
    }
}
```

{% endtab %}
{% endtabs %}

### Ejemplos de uso&#x20;

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

```php
    $params = json_encode(['dni' => 'INGRESAR_NUMERO_DNI_AQUI']);
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => "https://apiperu.dev/api/dni",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_POSTFIELDS => $params,        
        CURLOPT_HTTPHEADER => [
            'Accept: application/json',
            'Content-Type: application/json',
            'Authorization: Bearer INGRESAR_TOKEN_AQUI'
        ],        
    ));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    if ($err) {
        echo "cURL Error #:" . $err;
    } else {
        echo $response;
    }
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.apiperu.dev/enpoints/consulta-dni.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
