Metadata-Version: 2.4
Name: vardic
Version: 1.0.0
Summary: Official Vardic SDK for Python: UK vehicle data (DVLA and MOT), company checks, sanctions screening, company monitoring, postcodes and fuel prices on one API key.
Author-email: Vardic <hello@vardic.dev>
Maintainer-email: Vardic <hello@vardic.dev>
License: MIT
Project-URL: Homepage, https://vardic.dev
Project-URL: Documentation, https://vardic.dev/docs
Project-URL: Source, https://github.com/vardic-dev/vardic-python
Project-URL: Issues, https://github.com/vardic-dev/vardic-python/issues
Project-URL: Changelog, https://github.com/vardic-dev/vardic-python/blob/main/CHANGELOG.md
Keywords: vardic,sdk,api-client,uk,dvla,mot-history,vehicle-data,companies-house,kyb,sanctions,eori,postcode,fuel-prices,webhooks
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Vardic for Python

[![CI](https://github.com/vardic-dev/vardic-python/actions/workflows/ci.yml/badge.svg)](https://github.com/vardic-dev/vardic-python/actions/workflows/ci.yml) [![Licence: MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](LICENSE)

The official Python SDK for [Vardic](https://vardic.dev): UK vehicle data, company checks, sanctions screening, company monitoring, postcodes and fuel prices on one API key.

```python
from vardic import Vardic

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

print(car["data"]["make"], car["data"]["mot"]["status"], co["data"]["company"]["name"], co["data"]["risk"])
print(hit["data"]["matchCount"], area["data"]["areas"]["localAuthority"]["name"], fuel["data"]["items"][0]["price"])
```

## Install

```sh
pip install vardic
```

Python 3.9+, standard library only. Type hints are included (`py.typed`).

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 snake_case here and camelCase in the [JavaScript SDK](https://github.com/vardic-dev/vardic-node) (`fuel_nearest` and `fuelNearest`).

| 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`, `screen_bulk`, `screen_csv`, `list_checks`, `get_check`, `delete_check`, `certificate`, `check_csv`, `lists` | UK, US (OFAC) and EU sanctions lists, screening records and certificates |
| `vardic.monitoring` | `list`, `create`, `create_many`, `delete`, `test_event` | Signed webhooks and email digests for vehicles, companies and monitored names |
| `vardic.location` | `postcode`, `fuel_nearest`, `fuel_station`, `fuel_history` | Postcode area codes, flood risk, crime and schools; UK fuel prices |
| `vardic` | `account`, `status` | Plan and usage; public service status |

Every call returns the parsed `{"data": ..., "meta": ...}` response, except `monitoring.delete` (`None`), `sanctions.certificate` (bytes) and the CSV downloads (text).

### Vehicles

```python
car = vardic.vehicle.get("AB12 CDE")["data"]  # spaces and case are ignored
print(car["make"], car["model"], car["tax"]["status"], car["mot"]["expiryDate"])
print(car["mileage"]["anomalyFound"], (car["cleanAirZone"] or {}).get("result"))

rows = vardic.vehicle.bulk(["AB12CDE", "TL12OLD"])["data"]  # up to 25
```

### Business checks

```python
data = vardic.business.check("00445790", include=["officers", "psc"], eori="GB123456789000")["data"]
for f in data["flags"]:
    print(f["severity"], f["message"])

vardic.business.officers("00445790", page=1, size=50)
vardic.business.filings("00445790", category="accounts")
vardic.business.ownership("00445790", depth=2)
vardic.business.search("tesco")
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

```python
data = vardic.sanctions.screen({"name": "Ivan Sandboxov", "type": "individual", "dob": "1965", "threshold": 85})["data"]
for m in data["matches"]:
    print(m["score"], m["list"], m["matchedName"])

vardic.sanctions.screen_bulk([{"name": "A Name"}, {"name": "Another Name", "country": "RU"}])  # up to 25
summary = vardic.sanctions.screen_csv(csv_text, record=True)
pdf = vardic.sanctions.certificate(summary["data"]["checkId"])  # bytes
```

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

```python
vardic.monitoring.create(registration="AB12CDE", url="https://example.com/hooks/vardic", days_before=[30, 7, 1])
vardic.monitoring.create(company_number="00445790", url="https://example.com/hooks/vardic", email_digest=True)
vardic.monitoring.create_many(["00445790", "SC123456"], url="https://example.com/hooks/vardic")

watches = vardic.monitoring.list()["data"]
vardic.monitoring.delete(watches[0]["id"])
vardic.monitoring.test_event("https://example.com/hooks/vardic", type="company.filing")
```

Watches need a live key. A sandbox key can still send a signed sample with `test_event`. 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).

```python
from vardic import verify_webhook

# raw_body must be the exact bytes received, not re-serialised JSON
ok = verify_webhook(raw_body, request.headers["vardic-signature"], WEBHOOK_SECRET)
if not ok:
    abort(400)
```

### Postcodes and fuel

```python
data = vardic.location.postcode("SW1A 1AA", include=["areas", "flood"], schools=3)["data"]
cheapest = vardic.location.fuel_nearest(postcode="SW1A 1AA", fuel="E10", radius=5)["data"]
vardic.location.fuel_station(cheapest["items"][0]["station"]["id"])
vardic.location.fuel_history(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

```python
account = vardic.account()["data"]  # plans, usage this month, webhook secret
status = vardic.status()["data"]  # public service status
```

## Options

```python
vardic = Vardic(
    api_key="vd_live_...",       # default: the VARDIC_API_KEY environment variable
    timeout=10.0,                # seconds, per attempt, default 15
    max_retries=2,               # on 429 and 503, default 2
    base_url="https://api.vardic.dev",
)
```

## Errors

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

```python
from vardic import VardicApiError

try:
    vardic.vehicle.get("ZZ99ZZZ")
except VardicApiError as e:
    print(e.status, e.code, e.request_id)  # 404 vehicle_not_found req_...
```

Timeouts and network failures raise 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

- Get a free key: https://vardic.dev/signup
- API docs: https://vardic.dev/docs
- OpenAPI files: https://vardic.dev/docs/openapi
- Service status: https://vardic.dev/status
- JavaScript SDK: https://github.com/vardic-dev/vardic-node
- Examples: [examples/](examples/)
- Changelog: [CHANGELOG.md](CHANGELOG.md)
- Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
- Security: [SECURITY.md](SECURITY.md)

## 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](https://vardic.dev).
