VatchexVies (VatchexVies v1.0.0)

Copy Markdown View Source

Client for the EU VIES REST API (VAT number validation and company lookup).

Public API

VatchexVies.lookup("EL", "998144460")
VatchexVies.lookup("EL", "998144460", cache: VatchexVies.CachexCache)

Returns {:ok, map} with company data or {:error, %{code: atom, descr: string}}.

Response map (on success)

%{
  country_code: "EL",
  afm: "998144460",
  onomasia: "Company Name",
  commer_title: "Trading Name",
  address: "Street Address
PostCode City",
  address_collapsed: "Street Address PostCode City",
  source: :vies
}

Error codes

codedescrmeaning
:invalid_vat"Invalid VAT number"VAT number invalid per VIES
:invalid_vat"VAT number is blank"Empty or whitespace-only input (no API call)
:vies_http_error"HTTP 500"Non-2xx from VIES
:vies_too_many_requests"Rate limited by VIES"HTTP 429 — caller should back off
:vies_request_failed"connection refused"Transport failure
:vies_status_unavailable"VIES status endpoint unavailable"Cannot reach VIES status endpoint

Summary

Functions

Checks if VIES is available for the given country code. Returns {:ok, boolean()} or {:error, %{code: atom, descr: string}}.

Returns a map of country codes to VIES availability (true/false).

Looks up a VAT number via the EU VIES API.

Functions

available?(country_code, opts \\ [])

Checks if VIES is available for the given country code. Returns {:ok, boolean()} or {:error, %{code: atom, descr: string}}.

Options

  • :test_adapter — a {Req.Test, module} tuple for test stubbing

available_countries(opts \\ [])

Returns a map of country codes to VIES availability (true/false).

Options

  • :test_adapter — a {Req.Test, module} tuple for test stubbing

lookup(country_code, tin, opts \\ [])

Looks up a VAT number via the EU VIES API.

Options