npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@valix/sdk

v1.0.0

Published

SDK oficial para la API de validación de identificadores fiscales españoles (NIF, NIE, CIF, IBAN)

Readme

valix

SDK oficial de Valix para validar identificadores fiscales españoles: NIF, NIE, CIF e IBAN.

npm install @valix/sdk

Quickstart

import { Valix } from 'valix'

const valix = new Valix({ apiKey: 'vx_live_...' })

const result = await valix.validate('12345678Z')
// { valid: true, detected_type: 'NIF', formatted: '12345678-Z', errors: [] }

Probar sin API key

import { trial } from 'valix'

const result = await trial([
  { value: '12345678Z' },
  { value: 'X1234567L' },
])

console.log(result.valid_count) // 2

El endpoint trial permite hasta 50 validaciones por día sin necesidad de registro. Ideal para evaluar el servicio antes de suscribirse.


Instalación

# npm
npm install @valix/sdk

# pnpm
pnpm add @valix/sdk

# yarn
yarn add @valix/sdk

Requiere Node.js 18+ (usa fetch nativo). Compatible con todos los bundlers modernos (Vite, webpack, esbuild).


Uso con API key

Obtén tu API key en getvalix.io.

Validación con detección automática de tipo

import { Valix } from 'valix'

const valix = new Valix({ apiKey: 'vx_live_...' })

await valix.validate('12345678Z')    // NIF detectado automáticamente
await valix.validate('X1234567L')    // NIE detectado automáticamente
await valix.validate('A12345674')    // CIF detectado automáticamente
await valix.validate('ES9121000418450200051332')  // IBAN detectado

Forzar el tipo

await valix.validateNIF('12345678Z')
await valix.validateNIE('X1234567L')
await valix.validateCIF('A12345674')
await valix.validateIBAN('ES9121000418450200051332')

Validación en lote (hasta 100 identificadores)

const response = await valix.batch([
  { value: '12345678Z', type: 'AUTO' },
  { value: 'X1234567L', type: 'NIE' },
  { value: 'A12345674', type: 'CIF' },
  { value: 'ES9121000418450200051332', type: 'IBAN' },
])

console.log(response.total)         // 4
console.log(response.valid_count)   // 4
console.log(response.invalid_count) // 0

for (const result of response.results) {
  console.log(`${result.value}: ${result.valid ? '✓' : '✗'} (${result.detected_type})`)
}

Formato de respuesta

Cada resultado incluye:

{
  valid: boolean          // true si el identificador es válido
  detected_type: string  // 'NIF' | 'NIE' | 'CIF' | 'IBAN'
  value: string          // valor original enviado
  formatted: string | null  // formato oficial (ej: '12345678-Z') o null si inválido
  errors: string[]       // mensajes de error (vacío si válido)
  entity_type?: string   // solo en CIF válidos (ej: 'SOCIEDAD_ANONIMA')
}

Manejo de errores

import { Valix, ValixError, ValixRateLimitError, ValixAuthError } from 'valix'

const valix = new Valix({ apiKey: 'vx_live_...' })

try {
  const result = await valix.validate('12345678Z')
} catch (error) {
  if (error instanceof ValixAuthError) {
    console.error('API key inválida')
  } else if (error instanceof ValixRateLimitError) {
    console.error('Límite de plan alcanzado')
  } else if (error instanceof ValixError) {
    console.error(`Error ${error.status}: ${error.message} (${error.code})`)
  }
}

Los errores de validación (NIF inválido, etc.) no lanzan excepciones — se devuelven como { valid: false, errors: [...] }. Las excepciones solo ocurren ante errores de red, autenticación o límites de plan.


TypeScript

El paquete incluye tipos completos. No necesitas instalar @types/valix.

import type { ValidationItem, BatchResponse, IdentifierType } from 'valix'

const items: ValidationItem[] = [
  { value: '12345678Z', type: 'NIF' },
  { value: 'X1234567L', type: 'NIE' },
]

const response: BatchResponse = await valix.batch(items)

Uso en el servidor (Next.js, Express, etc.)

// app/api/checkout/route.ts (Next.js App Router)
import { Valix } from 'valix'

const valix = new Valix({ apiKey: process.env.VALIX_API_KEY! })

export async function POST(request: Request) {
  const { nif } = await request.json()

  const result = await valix.validateNIF(nif)
  if (!result.valid) {
    return Response.json({ error: 'NIF inválido' }, { status: 400 })
  }

  // continuar con el checkout...
}

Planes y límites

| Plan | Validaciones/mes | |---|---| | Trial (sin registro) | 50/día | | Starter | 10.000 | | Pro | 100.000 | | Enterprise | 1.000.000 |

Ver precios en getvalix.io/#precios.


Licencia

MIT — ver LICENSE.