vardic 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vardic-1.0.0/CHANGELOG.md +18 -0
- vardic-1.0.0/CONTRIBUTING.md +27 -0
- vardic-1.0.0/LICENSE +21 -0
- vardic-1.0.0/MANIFEST.in +4 -0
- vardic-1.0.0/PKG-INFO +221 -0
- vardic-1.0.0/README.md +192 -0
- vardic-1.0.0/SECURITY.md +15 -0
- vardic-1.0.0/examples/onboard_a_company.py +30 -0
- vardic-1.0.0/examples/overview.py +25 -0
- vardic-1.0.0/examples/webhook_server.py +38 -0
- vardic-1.0.0/pyproject.toml +40 -0
- vardic-1.0.0/setup.cfg +4 -0
- vardic-1.0.0/tests/__init__.py +0 -0
- vardic-1.0.0/tests/helpers.py +69 -0
- vardic-1.0.0/tests/test_client.py +389 -0
- vardic-1.0.0/tests/test_live.py +48 -0
- vardic-1.0.0/tests/test_webhook.py +51 -0
- vardic-1.0.0/vardic/__init__.py +363 -0
- vardic-1.0.0/vardic/py.typed +0 -0
- vardic-1.0.0/vardic/types.py +23 -0
- vardic-1.0.0/vardic.egg-info/PKG-INFO +221 -0
- vardic-1.0.0/vardic.egg-info/SOURCES.txt +22 -0
- vardic-1.0.0/vardic.egg-info/dependency_links.txt +1 -0
- vardic-1.0.0/vardic.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
<!-- Version badges for PyPI are left out of the README on purpose: add one once the first release is published, because it shows "not found" until then. -->
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [1.0.0] - 2026-11-29
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- First release of the unified Vardic SDK for Python, covering every public endpoint: `vehicle` (get, bulk), `business` (check, officers, psc, charges, filings, ownership, search, eori, vat), `sanctions` (screen, screen_bulk, screen_csv, list_checks, get_check, delete_check, certificate, check_csv, lists), `monitoring` (list, create, create_many, delete, test_event), `location` (postcode, fuel_nearest, fuel_station, fuel_history), plus `account` and `status`.
|
|
14
|
+
- `VardicApiError` with `status`, `code`, `request_id`, `body` and `retry_after`.
|
|
15
|
+
- Automatic retries on 429 and 503 (up to two, honouring `Retry-After`), and a `timeout` option.
|
|
16
|
+
- `verify_webhook` for the `vardic-signature` header.
|
|
17
|
+
- Type hints and a `py.typed` marker.
|
|
18
|
+
- Unit tests with mocked HTTP for every method, plus optional live smoke tests (set `VARDIC_TEST_KEY`).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping. Bug reports and small, focused pull requests are welcome.
|
|
4
|
+
|
|
5
|
+
## Set up
|
|
6
|
+
|
|
7
|
+
You need Python 3.9 or newer. There are no dependencies to install.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
python -m unittest discover -s tests -t . -v
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Tests mock `urllib.request.urlopen`, so they need no network or API key. To also run the live smoke tests against the sandbox, set `VARDIC_TEST_KEY` to a `vd_test_` key:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
VARDIC_TEST_KEY=vd_test_... python -m unittest discover -s tests -t . -v
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Pull requests
|
|
20
|
+
|
|
21
|
+
- Keep the package free of runtime dependencies (standard library only).
|
|
22
|
+
- Add or update a test for every change in behaviour.
|
|
23
|
+
- Update the type hints and the README when you change the public API.
|
|
24
|
+
- Add a line under "Unreleased" in `CHANGELOG.md`.
|
|
25
|
+
- Keep method names in step with the [JavaScript SDK](https://github.com/vardic-dev/vardic-node): the same methods, snake_case here and camelCase there.
|
|
26
|
+
|
|
27
|
+
Questions about the API itself: hello@vardic.dev. Security problems: see `SECURITY.md`.
|
vardic-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vardic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
vardic-1.0.0/MANIFEST.in
ADDED
vardic-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vardic
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
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.
|
|
5
|
+
Author-email: Vardic <hello@vardic.dev>
|
|
6
|
+
Maintainer-email: Vardic <hello@vardic.dev>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://vardic.dev
|
|
9
|
+
Project-URL: Documentation, https://vardic.dev/docs
|
|
10
|
+
Project-URL: Source, https://github.com/vardic-dev/vardic-python
|
|
11
|
+
Project-URL: Issues, https://github.com/vardic-dev/vardic-python/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/vardic-dev/vardic-python/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: vardic,sdk,api-client,uk,dvla,mot-history,vehicle-data,companies-house,kyb,sanctions,eori,postcode,fuel-prices,webhooks
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Vardic for Python
|
|
31
|
+
|
|
32
|
+
[](https://github.com/vardic-dev/vardic-python/actions/workflows/ci.yml) [](LICENSE)
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from vardic import Vardic
|
|
38
|
+
|
|
39
|
+
vardic = Vardic() # reads VARDIC_API_KEY
|
|
40
|
+
car = vardic.vehicle.get("AB12 CDE")
|
|
41
|
+
co = vardic.business.check("00445790") # Tesco PLC
|
|
42
|
+
hit = vardic.sanctions.screen({"name": "Example Trading Sanctioned LLC", "type": "entity"})
|
|
43
|
+
area = vardic.location.postcode("SW1A 1AA")
|
|
44
|
+
fuel = vardic.location.fuel_nearest(postcode="SW1A 1AA", fuel="E10", limit=3)
|
|
45
|
+
|
|
46
|
+
print(car["data"]["make"], car["data"]["mot"]["status"], co["data"]["company"]["name"], co["data"]["risk"])
|
|
47
|
+
print(hit["data"]["matchCount"], area["data"]["areas"]["localAuthority"]["name"], fuel["data"]["items"][0]["price"])
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
pip install vardic
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Python 3.9+, standard library only. Type hints are included (`py.typed`).
|
|
57
|
+
|
|
58
|
+
Get a free key at https://vardic.dev/signup. Set it as `VARDIC_API_KEY`, or pass it to the constructor.
|
|
59
|
+
|
|
60
|
+
## What is covered
|
|
61
|
+
|
|
62
|
+
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`).
|
|
63
|
+
|
|
64
|
+
| Namespace | Methods | API |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `vardic.vehicle` | `get`, `bulk` | DVLA vehicle record, DVSA MOT history, mileage checks, estimated clean air zone status |
|
|
67
|
+
| `vardic.business` | `check`, `officers`, `psc`, `charges`, `filings`, `ownership`, `search`, `eori`, `vat` | Companies House, charity status, EORI, risk flags |
|
|
68
|
+
| `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 |
|
|
69
|
+
| `vardic.monitoring` | `list`, `create`, `create_many`, `delete`, `test_event` | Signed webhooks and email digests for vehicles, companies and monitored names |
|
|
70
|
+
| `vardic.location` | `postcode`, `fuel_nearest`, `fuel_station`, `fuel_history` | Postcode area codes, flood risk, crime and schools; UK fuel prices |
|
|
71
|
+
| `vardic` | `account`, `status` | Plan and usage; public service status |
|
|
72
|
+
|
|
73
|
+
Every call returns the parsed `{"data": ..., "meta": ...}` response, except `monitoring.delete` (`None`), `sanctions.certificate` (bytes) and the CSV downloads (text).
|
|
74
|
+
|
|
75
|
+
### Vehicles
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
car = vardic.vehicle.get("AB12 CDE")["data"] # spaces and case are ignored
|
|
79
|
+
print(car["make"], car["model"], car["tax"]["status"], car["mot"]["expiryDate"])
|
|
80
|
+
print(car["mileage"]["anomalyFound"], (car["cleanAirZone"] or {}).get("result"))
|
|
81
|
+
|
|
82
|
+
rows = vardic.vehicle.bulk(["AB12CDE", "TL12OLD"])["data"] # up to 25
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Business checks
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
data = vardic.business.check("00445790", include=["officers", "psc"], eori="GB123456789000")["data"]
|
|
89
|
+
for f in data["flags"]:
|
|
90
|
+
print(f["severity"], f["message"])
|
|
91
|
+
|
|
92
|
+
vardic.business.officers("00445790", page=1, size=50)
|
|
93
|
+
vardic.business.filings("00445790", category="accounts")
|
|
94
|
+
vardic.business.ownership("00445790", depth=2)
|
|
95
|
+
vardic.business.search("tesco")
|
|
96
|
+
vardic.business.eori("GB123456789000")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
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.
|
|
100
|
+
|
|
101
|
+
### Sanctions screening
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
data = vardic.sanctions.screen({"name": "Ivan Sandboxov", "type": "individual", "dob": "1965", "threshold": 85})["data"]
|
|
105
|
+
for m in data["matches"]:
|
|
106
|
+
print(m["score"], m["list"], m["matchedName"])
|
|
107
|
+
|
|
108
|
+
vardic.sanctions.screen_bulk([{"name": "A Name"}, {"name": "Another Name", "country": "RU"}]) # up to 25
|
|
109
|
+
summary = vardic.sanctions.screen_csv(csv_text, record=True)
|
|
110
|
+
pdf = vardic.sanctions.certificate(summary["data"]["checkId"]) # bytes
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
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.
|
|
114
|
+
|
|
115
|
+
### Monitoring and webhooks
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
vardic.monitoring.create(registration="AB12CDE", url="https://example.com/hooks/vardic", days_before=[30, 7, 1])
|
|
119
|
+
vardic.monitoring.create(company_number="00445790", url="https://example.com/hooks/vardic", email_digest=True)
|
|
120
|
+
vardic.monitoring.create_many(["00445790", "SC123456"], url="https://example.com/hooks/vardic")
|
|
121
|
+
|
|
122
|
+
watches = vardic.monitoring.list()["data"]
|
|
123
|
+
vardic.monitoring.delete(watches[0]["id"])
|
|
124
|
+
vardic.monitoring.test_event("https://example.com/hooks/vardic", type="company.filing")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
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
|
|
128
|
+
|
|
129
|
+
Verify every delivery with the `vardic-signature` header and your webhook secret (from `vardic.account()`). Reject anything older than five minutes (the default tolerance).
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from vardic import verify_webhook
|
|
133
|
+
|
|
134
|
+
# raw_body must be the exact bytes received, not re-serialised JSON
|
|
135
|
+
ok = verify_webhook(raw_body, request.headers["vardic-signature"], WEBHOOK_SECRET)
|
|
136
|
+
if not ok:
|
|
137
|
+
abort(400)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Postcodes and fuel
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
data = vardic.location.postcode("SW1A 1AA", include=["areas", "flood"], schools=3)["data"]
|
|
144
|
+
cheapest = vardic.location.fuel_nearest(postcode="SW1A 1AA", fuel="E10", radius=5)["data"]
|
|
145
|
+
vardic.location.fuel_station(cheapest["items"][0]["station"]["id"])
|
|
146
|
+
vardic.location.fuel_history(cheapest["items"][0]["station"]["id"], days=30)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Postcode checks cover Great Britain; a Northern Ireland, Channel Islands or Isle of Man postcode fails with `unsupported_region`.
|
|
150
|
+
|
|
151
|
+
### Account and status
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
account = vardic.account()["data"] # plans, usage this month, webhook secret
|
|
155
|
+
status = vardic.status()["data"] # public service status
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Options
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
vardic = Vardic(
|
|
162
|
+
api_key="vd_live_...", # default: the VARDIC_API_KEY environment variable
|
|
163
|
+
timeout=10.0, # seconds, per attempt, default 15
|
|
164
|
+
max_retries=2, # on 429 and 503, default 2
|
|
165
|
+
base_url="https://api.vardic.dev",
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Errors
|
|
170
|
+
|
|
171
|
+
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`.
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from vardic import VardicApiError
|
|
175
|
+
|
|
176
|
+
try:
|
|
177
|
+
vardic.vehicle.get("ZZ99ZZZ")
|
|
178
|
+
except VardicApiError as e:
|
|
179
|
+
print(e.status, e.code, e.request_id) # 404 vehicle_not_found req_...
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
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).
|
|
183
|
+
|
|
184
|
+
### Retries
|
|
185
|
+
|
|
186
|
+
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.
|
|
187
|
+
|
|
188
|
+
## Sandbox keys
|
|
189
|
+
|
|
190
|
+
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:
|
|
191
|
+
|
|
192
|
+
- Vehicle `ZZ99ZZZ` returns `vehicle_not_found`; `TL12OLD` returns a 2012 diesel with a mileage reading that went down.
|
|
193
|
+
- Company `00000000` returns `company_not_found`.
|
|
194
|
+
- Sanctions names `Example Trading Sanctioned LLC`, `Ivan Sandboxov` and `Sandbox Example Bank` return fictional matches; any other name returns none.
|
|
195
|
+
- Postcode `ZZ1 1ZZ` returns `postcode_not_found`.
|
|
196
|
+
|
|
197
|
+
All sandbox values: https://vardic.dev/docs/sandbox
|
|
198
|
+
|
|
199
|
+
## Pricing
|
|
200
|
+
|
|
201
|
+
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
|
|
202
|
+
|
|
203
|
+
## Links
|
|
204
|
+
|
|
205
|
+
- Get a free key: https://vardic.dev/signup
|
|
206
|
+
- API docs: https://vardic.dev/docs
|
|
207
|
+
- OpenAPI files: https://vardic.dev/docs/openapi
|
|
208
|
+
- Service status: https://vardic.dev/status
|
|
209
|
+
- JavaScript SDK: https://github.com/vardic-dev/vardic-node
|
|
210
|
+
- Examples: [examples/](examples/)
|
|
211
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
212
|
+
- Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
213
|
+
- Security: [SECURITY.md](SECURITY.md)
|
|
214
|
+
|
|
215
|
+
## Data
|
|
216
|
+
|
|
217
|
+
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.
|
|
218
|
+
|
|
219
|
+
## Licence
|
|
220
|
+
|
|
221
|
+
MIT. Made by [Vardic](https://vardic.dev).
|
vardic-1.0.0/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Vardic for Python
|
|
2
|
+
|
|
3
|
+
[](https://github.com/vardic-dev/vardic-python/actions/workflows/ci.yml) [](LICENSE)
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from vardic import Vardic
|
|
9
|
+
|
|
10
|
+
vardic = Vardic() # reads VARDIC_API_KEY
|
|
11
|
+
car = vardic.vehicle.get("AB12 CDE")
|
|
12
|
+
co = vardic.business.check("00445790") # Tesco PLC
|
|
13
|
+
hit = vardic.sanctions.screen({"name": "Example Trading Sanctioned LLC", "type": "entity"})
|
|
14
|
+
area = vardic.location.postcode("SW1A 1AA")
|
|
15
|
+
fuel = vardic.location.fuel_nearest(postcode="SW1A 1AA", fuel="E10", limit=3)
|
|
16
|
+
|
|
17
|
+
print(car["data"]["make"], car["data"]["mot"]["status"], co["data"]["company"]["name"], co["data"]["risk"])
|
|
18
|
+
print(hit["data"]["matchCount"], area["data"]["areas"]["localAuthority"]["name"], fuel["data"]["items"][0]["price"])
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pip install vardic
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Python 3.9+, standard library only. Type hints are included (`py.typed`).
|
|
28
|
+
|
|
29
|
+
Get a free key at https://vardic.dev/signup. Set it as `VARDIC_API_KEY`, or pass it to the constructor.
|
|
30
|
+
|
|
31
|
+
## What is covered
|
|
32
|
+
|
|
33
|
+
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`).
|
|
34
|
+
|
|
35
|
+
| Namespace | Methods | API |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `vardic.vehicle` | `get`, `bulk` | DVLA vehicle record, DVSA MOT history, mileage checks, estimated clean air zone status |
|
|
38
|
+
| `vardic.business` | `check`, `officers`, `psc`, `charges`, `filings`, `ownership`, `search`, `eori`, `vat` | Companies House, charity status, EORI, risk flags |
|
|
39
|
+
| `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 |
|
|
40
|
+
| `vardic.monitoring` | `list`, `create`, `create_many`, `delete`, `test_event` | Signed webhooks and email digests for vehicles, companies and monitored names |
|
|
41
|
+
| `vardic.location` | `postcode`, `fuel_nearest`, `fuel_station`, `fuel_history` | Postcode area codes, flood risk, crime and schools; UK fuel prices |
|
|
42
|
+
| `vardic` | `account`, `status` | Plan and usage; public service status |
|
|
43
|
+
|
|
44
|
+
Every call returns the parsed `{"data": ..., "meta": ...}` response, except `monitoring.delete` (`None`), `sanctions.certificate` (bytes) and the CSV downloads (text).
|
|
45
|
+
|
|
46
|
+
### Vehicles
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
car = vardic.vehicle.get("AB12 CDE")["data"] # spaces and case are ignored
|
|
50
|
+
print(car["make"], car["model"], car["tax"]["status"], car["mot"]["expiryDate"])
|
|
51
|
+
print(car["mileage"]["anomalyFound"], (car["cleanAirZone"] or {}).get("result"))
|
|
52
|
+
|
|
53
|
+
rows = vardic.vehicle.bulk(["AB12CDE", "TL12OLD"])["data"] # up to 25
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Business checks
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
data = vardic.business.check("00445790", include=["officers", "psc"], eori="GB123456789000")["data"]
|
|
60
|
+
for f in data["flags"]:
|
|
61
|
+
print(f["severity"], f["message"])
|
|
62
|
+
|
|
63
|
+
vardic.business.officers("00445790", page=1, size=50)
|
|
64
|
+
vardic.business.filings("00445790", category="accounts")
|
|
65
|
+
vardic.business.ownership("00445790", depth=2)
|
|
66
|
+
vardic.business.search("tesco")
|
|
67
|
+
vardic.business.eori("GB123456789000")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
### Sanctions screening
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
data = vardic.sanctions.screen({"name": "Ivan Sandboxov", "type": "individual", "dob": "1965", "threshold": 85})["data"]
|
|
76
|
+
for m in data["matches"]:
|
|
77
|
+
print(m["score"], m["list"], m["matchedName"])
|
|
78
|
+
|
|
79
|
+
vardic.sanctions.screen_bulk([{"name": "A Name"}, {"name": "Another Name", "country": "RU"}]) # up to 25
|
|
80
|
+
summary = vardic.sanctions.screen_csv(csv_text, record=True)
|
|
81
|
+
pdf = vardic.sanctions.certificate(summary["data"]["checkId"]) # bytes
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
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.
|
|
85
|
+
|
|
86
|
+
### Monitoring and webhooks
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
vardic.monitoring.create(registration="AB12CDE", url="https://example.com/hooks/vardic", days_before=[30, 7, 1])
|
|
90
|
+
vardic.monitoring.create(company_number="00445790", url="https://example.com/hooks/vardic", email_digest=True)
|
|
91
|
+
vardic.monitoring.create_many(["00445790", "SC123456"], url="https://example.com/hooks/vardic")
|
|
92
|
+
|
|
93
|
+
watches = vardic.monitoring.list()["data"]
|
|
94
|
+
vardic.monitoring.delete(watches[0]["id"])
|
|
95
|
+
vardic.monitoring.test_event("https://example.com/hooks/vardic", type="company.filing")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
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
|
|
99
|
+
|
|
100
|
+
Verify every delivery with the `vardic-signature` header and your webhook secret (from `vardic.account()`). Reject anything older than five minutes (the default tolerance).
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from vardic import verify_webhook
|
|
104
|
+
|
|
105
|
+
# raw_body must be the exact bytes received, not re-serialised JSON
|
|
106
|
+
ok = verify_webhook(raw_body, request.headers["vardic-signature"], WEBHOOK_SECRET)
|
|
107
|
+
if not ok:
|
|
108
|
+
abort(400)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Postcodes and fuel
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
data = vardic.location.postcode("SW1A 1AA", include=["areas", "flood"], schools=3)["data"]
|
|
115
|
+
cheapest = vardic.location.fuel_nearest(postcode="SW1A 1AA", fuel="E10", radius=5)["data"]
|
|
116
|
+
vardic.location.fuel_station(cheapest["items"][0]["station"]["id"])
|
|
117
|
+
vardic.location.fuel_history(cheapest["items"][0]["station"]["id"], days=30)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Postcode checks cover Great Britain; a Northern Ireland, Channel Islands or Isle of Man postcode fails with `unsupported_region`.
|
|
121
|
+
|
|
122
|
+
### Account and status
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
account = vardic.account()["data"] # plans, usage this month, webhook secret
|
|
126
|
+
status = vardic.status()["data"] # public service status
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Options
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
vardic = Vardic(
|
|
133
|
+
api_key="vd_live_...", # default: the VARDIC_API_KEY environment variable
|
|
134
|
+
timeout=10.0, # seconds, per attempt, default 15
|
|
135
|
+
max_retries=2, # on 429 and 503, default 2
|
|
136
|
+
base_url="https://api.vardic.dev",
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Errors
|
|
141
|
+
|
|
142
|
+
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`.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from vardic import VardicApiError
|
|
146
|
+
|
|
147
|
+
try:
|
|
148
|
+
vardic.vehicle.get("ZZ99ZZZ")
|
|
149
|
+
except VardicApiError as e:
|
|
150
|
+
print(e.status, e.code, e.request_id) # 404 vehicle_not_found req_...
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
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).
|
|
154
|
+
|
|
155
|
+
### Retries
|
|
156
|
+
|
|
157
|
+
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.
|
|
158
|
+
|
|
159
|
+
## Sandbox keys
|
|
160
|
+
|
|
161
|
+
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:
|
|
162
|
+
|
|
163
|
+
- Vehicle `ZZ99ZZZ` returns `vehicle_not_found`; `TL12OLD` returns a 2012 diesel with a mileage reading that went down.
|
|
164
|
+
- Company `00000000` returns `company_not_found`.
|
|
165
|
+
- Sanctions names `Example Trading Sanctioned LLC`, `Ivan Sandboxov` and `Sandbox Example Bank` return fictional matches; any other name returns none.
|
|
166
|
+
- Postcode `ZZ1 1ZZ` returns `postcode_not_found`.
|
|
167
|
+
|
|
168
|
+
All sandbox values: https://vardic.dev/docs/sandbox
|
|
169
|
+
|
|
170
|
+
## Pricing
|
|
171
|
+
|
|
172
|
+
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
|
|
173
|
+
|
|
174
|
+
## Links
|
|
175
|
+
|
|
176
|
+
- Get a free key: https://vardic.dev/signup
|
|
177
|
+
- API docs: https://vardic.dev/docs
|
|
178
|
+
- OpenAPI files: https://vardic.dev/docs/openapi
|
|
179
|
+
- Service status: https://vardic.dev/status
|
|
180
|
+
- JavaScript SDK: https://github.com/vardic-dev/vardic-node
|
|
181
|
+
- Examples: [examples/](examples/)
|
|
182
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
183
|
+
- Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
184
|
+
- Security: [SECURITY.md](SECURITY.md)
|
|
185
|
+
|
|
186
|
+
## Data
|
|
187
|
+
|
|
188
|
+
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.
|
|
189
|
+
|
|
190
|
+
## Licence
|
|
191
|
+
|
|
192
|
+
MIT. Made by [Vardic](https://vardic.dev).
|
vardic-1.0.0/SECURITY.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Email hello@vardic.dev with the subject "Security: vardic-python". Include what you found, how to reproduce it and the version you tested. Please do not open a public issue for a security problem.
|
|
6
|
+
|
|
7
|
+
We aim to reply within 3 working days and to ship a fix or a clear plan within 14 days.
|
|
8
|
+
|
|
9
|
+
## Supported versions
|
|
10
|
+
|
|
11
|
+
Only the latest release of this package receives security fixes.
|
|
12
|
+
|
|
13
|
+
## Your API key
|
|
14
|
+
|
|
15
|
+
Never commit an API key or a webhook secret. If one leaks, revoke it in your Vardic dashboard at https://vardic.dev and create a new one.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Know-your-business check for a new customer: company status, owners and sanctions.
|
|
2
|
+
|
|
3
|
+
Run: VARDIC_API_KEY=vd_test_... python examples/onboard_a_company.py 00445790
|
|
4
|
+
"""
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
9
|
+
|
|
10
|
+
from vardic import Vardic, VardicApiError # noqa: E402
|
|
11
|
+
|
|
12
|
+
number = sys.argv[1] if len(sys.argv) > 1 else "00445790" # Tesco PLC
|
|
13
|
+
vardic = Vardic()
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
data = vardic.business.check(number, include=["officers"])["data"]
|
|
17
|
+
print(f"{data['company']['name']}: {data['company']['status']}, risk {data['risk']}")
|
|
18
|
+
for f in data["flags"]:
|
|
19
|
+
print(f" - {f['severity']}: {f['message']}")
|
|
20
|
+
|
|
21
|
+
own = vardic.business.ownership(number, depth=2)["data"]
|
|
22
|
+
print("Ownership result:", own["result"], f"({len(own['owners'])} owners)")
|
|
23
|
+
|
|
24
|
+
for officer in ((data.get("officers") or {}).get("items") or [])[:5]: # each screen counts as one
|
|
25
|
+
s = vardic.sanctions.screen(name=officer["name"])["data"]
|
|
26
|
+
print(f" {officer['name']}: {s['matchCount']} potential matches")
|
|
27
|
+
except VardicApiError as e:
|
|
28
|
+
if e.code == "company_not_found":
|
|
29
|
+
sys.exit(f"No company {number}")
|
|
30
|
+
raise
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""One call from each product. Run: VARDIC_API_KEY=vd_test_... python examples/overview.py"""
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
6
|
+
|
|
7
|
+
from vardic import Vardic # noqa: E402
|
|
8
|
+
|
|
9
|
+
vardic = Vardic() # reads VARDIC_API_KEY
|
|
10
|
+
|
|
11
|
+
car = vardic.vehicle.get("AB12 CDE")["data"]
|
|
12
|
+
print(car["make"], car["model"], "MOT", car["mot"]["status"], car["mot"]["expiryDate"])
|
|
13
|
+
|
|
14
|
+
check = vardic.business.check("00445790")["data"] # Tesco PLC
|
|
15
|
+
print(check["company"]["name"], check["company"]["status"], "risk:", check["risk"])
|
|
16
|
+
|
|
17
|
+
screen = vardic.sanctions.screen({"name": "Example Trading Sanctioned LLC", "type": "entity"})["data"]
|
|
18
|
+
print("Sanctions matches:", screen["matchCount"])
|
|
19
|
+
|
|
20
|
+
area = vardic.location.postcode("SW1A 1AA")["data"]
|
|
21
|
+
print(area["postcode"], area["areas"]["localAuthority"]["name"])
|
|
22
|
+
|
|
23
|
+
fuel = vardic.location.fuel_nearest(postcode="SW1A 1AA", fuel="E10", limit=3)["data"]
|
|
24
|
+
for item in fuel["items"]:
|
|
25
|
+
print(item["price"], "p", item["distanceKm"], "km")
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Receive Vardic webhooks and check their signature.
|
|
2
|
+
|
|
3
|
+
Run: VARDIC_WEBHOOK_SECRET=whsec_... python examples/webhook_server.py
|
|
4
|
+
Then register the public URL of this server: vardic.monitoring.create(registration=..., url=...).
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
10
|
+
|
|
11
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
12
|
+
|
|
13
|
+
from vardic import verify_webhook # noqa: E402
|
|
14
|
+
|
|
15
|
+
SECRET = os.environ.get("VARDIC_WEBHOOK_SECRET")
|
|
16
|
+
if not SECRET:
|
|
17
|
+
sys.exit("Set VARDIC_WEBHOOK_SECRET")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Handler(BaseHTTPRequestHandler):
|
|
21
|
+
def do_POST(self):
|
|
22
|
+
raw = self.rfile.read(int(self.headers.get("content-length", 0))) # verify the exact bytes
|
|
23
|
+
if not verify_webhook(raw, self.headers.get("vardic-signature", ""), SECRET):
|
|
24
|
+
self.send_response(400)
|
|
25
|
+
self.end_headers()
|
|
26
|
+
self.wfile.write(b"bad signature")
|
|
27
|
+
return
|
|
28
|
+
event = json.loads(raw)
|
|
29
|
+
print("Received", event.get("type"), event.get("data"))
|
|
30
|
+
self.send_response(200) # answer any 2xx within 8 seconds
|
|
31
|
+
self.end_headers()
|
|
32
|
+
self.wfile.write(b"ok")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
port = int(os.environ.get("PORT", "3000"))
|
|
37
|
+
print(f"Listening for webhooks on port {port}")
|
|
38
|
+
HTTPServer(("", port), Handler).serve_forever()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vardic"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "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."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
maintainers = [{ name = "Vardic", email = "hello@vardic.dev" }]
|
|
13
|
+
authors = [{ name = "Vardic", email = "hello@vardic.dev" }]
|
|
14
|
+
keywords = ["vardic", "sdk", "api-client", "uk", "dvla", "mot-history", "vehicle-data", "companies-house", "kyb", "sanctions", "eori", "postcode", "fuel-prices", "webhooks"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://vardic.dev"
|
|
31
|
+
Documentation = "https://vardic.dev/docs"
|
|
32
|
+
Source = "https://github.com/vardic-dev/vardic-python"
|
|
33
|
+
Issues = "https://github.com/vardic-dev/vardic-python/issues"
|
|
34
|
+
Changelog = "https://github.com/vardic-dev/vardic-python/blob/main/CHANGELOG.md"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools]
|
|
37
|
+
packages = ["vardic"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
vardic = ["py.typed"]
|
vardic-1.0.0/setup.cfg
ADDED
|
File without changes
|