How to verify a Spanish company by NIF in Python

A short tutorial that verifies a Spanish company's NIF (Número de Identificación Fiscal) in about 30 lines of Python: validate the identifier locally with its control-character checksum, then resolve the full company profile from the official BORME registry via the Prometiam Risk API.

What the guide covers

Runs on the free tier (1,000 calls/month, no credit card). The same key covers France, the UK, Ireland, Poland, and Norway, plus sanctions + US export-control screening.

Read more · Get a free API key

Frequently asked questions

What is a Spanish NIF?
NIF (Número de Identificación Fiscal) is the Spanish tax identifier. For companies it is 9 characters: a letter prefix indicating legal form (A=SA, B=SL, F=Cooperative, etc.), 7 digits, and a control character that may be a digit or letter.
Can I validate a NIF without an API call?
Yes. The format and checksum are deterministic and can be checked entirely in Python with no network call. The Prometiam API call is needed afterward to confirm the NIF maps to a real registered company.
What if the NIF starts with X, Y, or Z?
Those prefixes are personal NIE (foreign-resident IDs), not corporate. Reject them at the validator step if you only accept companies.