> For the complete documentation index see https://domscan.net/llms.txt. Markdown versions of every docs page are available by appending .md to the page URL.

Source: https://domscan.net/sv/docs/products/dni-validation

# API för validering av spanska DNI, NIE och NIF API-referens

Validera spanska DNI-, NIE- och NIF/CIF-nummer. Använd denna referens för att välja en operation och integrera dess dokumenterade svarskontrakt.

[Visa produktsidan](https://domscan.net/sv/dni-validation-api)

## Operationer

GET `/v1/national-id/validate` [Visa API-referens](https://domscan.net/sv/docs/products/dni-validation#validateNationalId)

## GET `/v1/national-id/validate`

Operation: `validateNationalId`
Credits och autentisering: 1
Autentisering krävs

GET /v1/national-id/validate Krediter: 1

#### Frågeparametrar

| Parameter | Typ | obligatorisk |
| --- | --- | --- |
| id | string | obligatorisk |
| country | string Tillåtna värden `ES` Standard `ES` | valfri |

#### Svarsfält

| Fält | Typ |
| --- | --- |
| `country` | string |
| `input` | string |
| `normalized` | string \| null |
| `valid` | boolean |
| `type` | string \| null |
| `entity_type` | string \| null |
| `holder` | string \| null |
| `checks` | object |
| `checks.format` | boolean |
| `checks.control` | boolean \| null |
| `expected_control` | string \| null |
| `errors[]` | string[] |

#### Exempelbegäran

```bash
curl -H "X-API-Key: $DOMSCAN_API_KEY" "https://domscan.net/v1/national-id/validate?id=example-id&country=ES"
```

```javascript
const response = await fetch("https://domscan.net/v1/national-id/validate?id=example-id&country=ES", {
  headers: { "X-API-Key": process.env.DOMSCAN_API_KEY },
});
const data = await response.json();
console.log(data);
```

```python
import os
import requests

response = requests.get(
    "https://domscan.net/v1/national-id/validate?id=example-id&country=ES",
    headers={"X-API-Key": os.environ["DOMSCAN_API_KEY"]},
)
print(response.json())
```

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	req, err := http.NewRequest(http.MethodGet, "https://domscan.net/v1/national-id/validate?id=example-id&country=ES", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("X-API-Key", os.Getenv("DOMSCAN_API_KEY"))

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	data, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.Status, string(data))
}
```

```ruby
require "json"
require "net/http"

uri = URI("https://domscan.net/v1/national-id/validate?id=example-id&country=ES")
request = Net::HTTP::Get.new(uri)
request["X-API-Key"] = ENV.fetch("DOMSCAN_API_KEY")

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end
puts JSON.pretty_generate(JSON.parse(response.body))
```

#### Exempelsvar

```json
{
  "country": "ES",
  "input": "B-58378431",
  "normalized": "B58378431",
  "valid": true,
  "type": "cif",
  "entity_type": "sociedad_responsabilidad_limitada",
  "holder": null,
  "checks": {
    "format": true,
    "control": true
  },
  "expected_control": null,
  "errors": []
}
```

#### HTTP-statuskoder

- `200` OK
- `400` Felaktig begäran
- `401` Obehörig
- `402` Betalning krävs
- `429` För många begäranden

## Referensresurser

[OpenAPI 3.0](https://domscan.net/v1/openapi.json)
[Postman](https://domscan.net/v1/postman.json)
[MCP](https://domscan.net/sv/mcp-domain-checker)
