Skip to content

Latest commit

 

History

History
191 lines (134 loc) · 9.65 KB

README.md

File metadata and controls

191 lines (134 loc) · 9.65 KB

Vardic for JavaScript

npm CI Licence: MIT

The official JavaScript SDK for Vardic: UK vehicle data, company checks, sanctions screening, company monitoring, postcodes and fuel prices on one API key.

import { Vardic } from 'vardic';

const vardic = new Vardic(); // reads VARDIC_API_KEY
const car = await vardic.vehicle.get('AB12 CDE');
const co = await vardic.business.check('00445790'); // Tesco PLC
const hit = await vardic.sanctions.screen({ name: 'Example Trading Sanctioned LLC', type: 'entity' });
const area = await vardic.location.postcode('SW1A 1AA');
const fuel = await vardic.location.fuelNearest({ postcode: 'SW1A 1AA', fuel: 'E10', limit: 3 });

console.log(car.data.make, car.data.mot.status, co.data.company.name, co.data.risk);
console.log(hit.data.matchCount, area.data.areas.localAuthority.name, fuel.data.items[0].price);

Install

npm install vardic

ESM only, no dependencies. Needs a global fetch: Node 18+, Deno, Bun or an edge runtime. TypeScript types are included.

Get a free key at https://vardic.dev/signup. Set it as VARDIC_API_KEY, or pass it to the constructor.

What is covered

One client, one namespace per product. Method names are camelCase here and snake_case in the Python SDK (fuelNearest and fuel_nearest).

Namespace Methods API
vardic.vehicle get, bulk DVLA vehicle record, DVSA MOT history, mileage checks, estimated clean air zone status
vardic.business check, officers, psc, charges, filings, ownership, search, eori, vat Companies House, charity status, EORI, risk flags
vardic.sanctions screen, screenBulk, screenCsv, listChecks, getCheck, deleteCheck, certificate, checkCsv, lists UK, US (OFAC) and EU sanctions lists, screening records and certificates
vardic.monitoring list, create, createMany, delete, testEvent Signed webhooks and email digests for vehicles, companies and monitored names
vardic.location postcode, fuelNearest, fuelStation, fuelHistory Postcode area codes, flood risk, crime and schools; UK fuel prices
vardic account, status Plan and usage; public service status

Every call resolves to the parsed { data, meta } response, except monitoring.delete (null), sanctions.certificate (bytes) and the CSV downloads (text).

Vehicles

const { data } = await vardic.vehicle.get('AB12 CDE'); // spaces and case are ignored
console.log(data.make, data.model, data.tax.status, data.mot.expiryDate);
console.log(data.mileage.anomalyFound, data.cleanAirZone?.result);

const { data: rows } = await vardic.vehicle.bulk(['AB12CDE', 'TL12OLD']); // up to 25

Business checks

const { data } = await vardic.business.check('00445790', { include: ['officers', 'psc'], eori: 'GB123456789000' });
for (const f of data.flags) console.log(f.severity, f.message);

await vardic.business.officers('00445790', { page: 1, size: 50 });
await vardic.business.filings('00445790', { category: 'accounts' });
await vardic.business.ownership('00445790', { depth: 2 });
await vardic.business.search('tesco');
await vardic.business.eori('GB123456789000');

UK VAT number checks are not open yet: until they are, vardic.business.vat() fails with a 503 upstream_unavailable that is not counted, and vat in a company check is null. EORI checks cover UK (GB) numbers only.

Sanctions screening

const { data } = await vardic.sanctions.screen({ name: 'Ivan Sandboxov', type: 'individual', dob: '1965', threshold: 85 });
for (const m of data.matches) console.log(m.score, m.list, m.matchedName);

await vardic.sanctions.screenBulk([{ name: 'A Name' }, { name: 'Another Name', country: 'RU' }]); // up to 25
const summary = await vardic.sanctions.screenCsv(csvText, { record: true });
const pdf = await vardic.sanctions.certificate(summary.data.checkId); // Uint8Array

Screening is a screening aid, not legal advice: review every potential match. Names are never logged; they are stored only when you ask for a screening record.

Monitoring and webhooks

await vardic.monitoring.create({ registration: 'AB12CDE', url: 'https://example.com/hooks/vardic', daysBefore: [30, 7, 1] });
await vardic.monitoring.create({ companyNumber: '00445790', url: 'https://example.com/hooks/vardic', emailDigest: true });
await vardic.monitoring.createMany({ companyNumbers: ['00445790', 'SC123456'], url: 'https://example.com/hooks/vardic' });

const { data: watches } = await vardic.monitoring.list();
await vardic.monitoring.delete(watches[0].id);
await vardic.monitoring.testEvent({ url: 'https://example.com/hooks/vardic', type: 'company.filing' });

Watches need a live key. A sandbox key can still send a signed sample with testEvent. Event types and payloads: https://vardic.dev/docs/webhooks

Verify every delivery with the vardic-signature header and your webhook secret (from vardic.account()). Reject anything older than five minutes (the default tolerance).

import { verifyWebhook } from 'vardic';

// rawBody must be the exact request body, not re-serialised JSON
const ok = await verifyWebhook(rawBody, req.headers['vardic-signature'], process.env.VARDIC_WEBHOOK_SECRET);
if (!ok) return res.writeHead(400).end();

Postcodes and fuel

const { data } = await vardic.location.postcode('SW1A 1AA', { include: ['areas', 'flood'], schools: 3 });
const { data: cheapest } = await vardic.location.fuelNearest({ postcode: 'SW1A 1AA', fuel: 'E10', radius: 5 });
await vardic.location.fuelStation(cheapest.items[0].station.id);
await vardic.location.fuelHistory(cheapest.items[0].station.id, { days: 30 });

Postcode checks cover Great Britain; a Northern Ireland, Channel Islands or Isle of Man postcode fails with unsupported_region.

Account and status

const { data } = await vardic.account(); // plans, usage this month, webhook secret
const { data: status } = await vardic.status(); // public service status

Options

const vardic = new Vardic({
  apiKey: 'vd_live_...',      // default: process.env.VARDIC_API_KEY
  timeoutMs: 10000,           // per attempt, default 15000
  maxRetries: 2,              // on 429 and 503, default 2
  baseUrl: 'https://api.vardic.dev',
});

Errors

Failed calls throw VardicApiError with status, code, message, requestId (from the x-request-id header; quote it if you contact support), body (the parsed error response) and retryAfter.

import { VardicApiError } from 'vardic';

try {
  await vardic.vehicle.get('ZZ99ZZZ');
} catch (e) {
  if (e instanceof VardicApiError) console.log(e.status, e.code, e.requestId); // 404 vehicle_not_found req_...
  else throw e;
}

Timeouts and network failures throw the same class with status 0 and code timeout or network_error. The full code list is at https://vardic.dev/docs/errors, for example invalid_registration (400), vehicle_not_found (404), quota_exceeded (429) and upstream_unavailable (503).

Retries

The SDK retries 429 and 503 responses up to twice, waiting for the Retry-After header (or 0.5 s then 1 s without one). It never retries quota_exceeded or coming_soon, which retrying cannot fix, and it gives up at once when Retry-After is longer than 30 seconds. 400, 401 and 404 are never retried. Failed calls that return 429 or 503 are not counted against your allowance.

Sandbox keys

Every account gets a vd_test_ key as well as a live key. It returns realistic made-up data for any input, never counts towards your allowance and allows 5 requests a second. Special values:

  • Vehicle ZZ99ZZZ returns vehicle_not_found; TL12OLD returns a 2012 diesel with a mileage reading that went down.
  • Company 00000000 returns company_not_found.
  • Sanctions names Example Trading Sanctioned LLC, Ivan Sandboxov and Sandbox Example Bank return fictional matches; any other name returns none.
  • Postcode ZZ1 1ZZ returns postcode_not_found.

All sandbox values: https://vardic.dev/docs/sandbox

Pricing

Every product has a free monthly allowance on one key, no card needed: 100 vehicle lookups, 50 business checks, 50 sanctions screens, 5 watched companies, 100 postcode checks and 1,000 fuel requests. Paid plans and prices: https://vardic.dev/pricing

Links

Data

Contains public sector information licensed under the Open Government Licence v3.0, from the DVLA, DVSA, Companies House, the Charity Commission, the Environment Agency, the Office for National Statistics, police.uk and Fuel Finder. EORI data from HMRC. Sanctions lists are published by the UK, US (OFAC) and EU authorities; screening results are a screening aid, not legal advice. Each response carries its licence text in meta.attribution: show it wherever you display the data to others. Not affiliated with or endorsed by any of the government bodies whose data we use. Clean air zone results are estimates: check the official TfL or GOV.UK vehicle checker before relying on one.

Licence

MIT. Made by Vardic.