verifnow 0.1.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.
- verifnow-0.1.0/.gitignore +14 -0
- verifnow-0.1.0/CHANGELOG.md +19 -0
- verifnow-0.1.0/LICENSE +72 -0
- verifnow-0.1.0/PKG-INFO +355 -0
- verifnow-0.1.0/README.md +326 -0
- verifnow-0.1.0/pyproject.toml +80 -0
- verifnow-0.1.0/src/verifnow/__init__.py +84 -0
- verifnow-0.1.0/src/verifnow/_async.py +86 -0
- verifnow-0.1.0/src/verifnow/_client.py +403 -0
- verifnow-0.1.0/src/verifnow/_errors.py +85 -0
- verifnow-0.1.0/src/verifnow/_models.py +499 -0
- verifnow-0.1.0/src/verifnow/_transport.py +91 -0
- verifnow-0.1.0/src/verifnow/_version.py +8 -0
- verifnow-0.1.0/src/verifnow/py.typed +0 -0
- verifnow-0.1.0/tests/conftest.py +84 -0
- verifnow-0.1.0/tests/test_async.py +51 -0
- verifnow-0.1.0/tests/test_client.py +464 -0
- verifnow-0.1.0/tests/test_models.py +267 -0
- verifnow-0.1.0/tests/test_release.py +25 -0
- verifnow-0.1.0/tests/test_transport.py +119 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the package follows
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-13
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- First release, at parity with the Node.js SDK 1.9.0.
|
|
11
|
+
- `VerifNow` and `AsyncVerifNow` clients: `validate_email`, `validate_phone`, `validate_iban`,
|
|
12
|
+
`validate_vat` (with `trader_name`), `validate_nas`, `validate_ssn`, `validate_nif`, the generic
|
|
13
|
+
`validate`, and `vat_rates` / `vat_rate` for the EU VAT rates from TEDB.
|
|
14
|
+
- Frozen, fully typed results (`py.typed`), with the untouched body on `raw`.
|
|
15
|
+
- Typed exceptions per failure class. The SDK never reports an unverified value as valid.
|
|
16
|
+
- Retries with exponential backoff for connection failures, timeouts and 5xx. A 429 is retried
|
|
17
|
+
only when its reset is close; 400 and 401 never are.
|
|
18
|
+
- No runtime dependencies: the default transport is `urllib`, replaceable through `transport`.
|
|
19
|
+
- Every request sends `X-VerifNow-SDK: python/<version>`.
|
verifnow-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
|
|
4
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
5
|
+
|
|
6
|
+
1. Definitions.
|
|
7
|
+
|
|
8
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
9
|
+
|
|
10
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
11
|
+
|
|
12
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
13
|
+
|
|
14
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
15
|
+
|
|
16
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
17
|
+
|
|
18
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
19
|
+
|
|
20
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
21
|
+
|
|
22
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
23
|
+
|
|
24
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
25
|
+
|
|
26
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
27
|
+
|
|
28
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
29
|
+
|
|
30
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
31
|
+
|
|
32
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
33
|
+
|
|
34
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
35
|
+
|
|
36
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
37
|
+
|
|
38
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
39
|
+
|
|
40
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
41
|
+
|
|
42
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
43
|
+
|
|
44
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
45
|
+
|
|
46
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
47
|
+
|
|
48
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
49
|
+
|
|
50
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
51
|
+
|
|
52
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
53
|
+
|
|
54
|
+
END OF TERMS AND CONDITIONS
|
|
55
|
+
|
|
56
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
57
|
+
|
|
58
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
59
|
+
|
|
60
|
+
Copyright (c) 2025 VerifNow
|
|
61
|
+
|
|
62
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
63
|
+
you may not use this file except in compliance with the License.
|
|
64
|
+
You may obtain a copy of the License at
|
|
65
|
+
|
|
66
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
67
|
+
|
|
68
|
+
Unless required by applicable law or agreed to in writing, software
|
|
69
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
70
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
71
|
+
See the License for the specific language governing permissions and
|
|
72
|
+
limitations under the License.
|
verifnow-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: verifnow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the VerifNow validation API: email, phone, IBAN, VAT (VIES), SSN, SIN and NIF validation in one call.
|
|
5
|
+
Project-URL: Homepage, https://www.verifnow.io
|
|
6
|
+
Project-URL: Documentation, https://docs.verifnow.io
|
|
7
|
+
Project-URL: Source, https://github.com/verifnowio/verifnow-python
|
|
8
|
+
Project-URL: Issues, https://github.com/verifnowio/verifnow-python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/verifnowio/verifnow-python/blob/main/CHANGELOG.md
|
|
10
|
+
Author: VerifNow
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: api-client,email-validation,email-verification,iban,phone-validation,validation,vat,verifnow,vies
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# VerifNow Python SDK
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/verifnow/)
|
|
33
|
+
[](https://pypi.org/project/verifnow/)
|
|
34
|
+
[](https://github.com/verifnowio/verifnow-python/actions/workflows/ci.yml)
|
|
35
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
36
|
+
|
|
37
|
+
Official Python SDK for the [VerifNow](https://www.verifnow.io) validation API. One API key for
|
|
38
|
+
email, phone, IBAN, VAT (VIES), SSN, SIN and NIF validation.
|
|
39
|
+
|
|
40
|
+
Fully typed, no runtime dependencies, sync and asyncio clients.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install verifnow
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Requires Python 3.10 or later.
|
|
49
|
+
|
|
50
|
+
## Getting an API key
|
|
51
|
+
|
|
52
|
+
1. Create an account at [app.verifnow.io](https://app.verifnow.io).
|
|
53
|
+
2. Create an API key from the dashboard.
|
|
54
|
+
3. Keep it server-side. It authorises calls against your quota — never ship it to a browser.
|
|
55
|
+
|
|
56
|
+
The Free plan gives you 250 validations a month with the full `STANDARD` check set, no credit card.
|
|
57
|
+
|
|
58
|
+
## Quick start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from verifnow import VerifNow
|
|
62
|
+
|
|
63
|
+
client = VerifNow() # reads the VERIFNOW_API_KEY environment variable
|
|
64
|
+
|
|
65
|
+
result = client.validate_email("user@exmaple.com")
|
|
66
|
+
|
|
67
|
+
result.valid # False
|
|
68
|
+
result.message # "Email address is unlikely to be deliverable"
|
|
69
|
+
result.normalized_value # None when invalid
|
|
70
|
+
|
|
71
|
+
# Turn a typo into a correction prompt instead of a rejection
|
|
72
|
+
signals = result.email_details.signals if result.email_details else None
|
|
73
|
+
if signals and signals.typo_detected:
|
|
74
|
+
print(f"Did you mean {signals.suggested_domain}?") # "example.com"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pass the key explicitly with `VerifNow("vn_...")` if you do not use the environment variable.
|
|
78
|
+
Create one client and share it: it holds no per-request state and is safe across threads.
|
|
79
|
+
|
|
80
|
+
## VAT and VIES
|
|
81
|
+
|
|
82
|
+
VAT is the one validator whose answer can be *unknown* rather than yes or no. Registration is
|
|
83
|
+
checked against VIES, the European Commission's registry, which publishes no SLA and drops member
|
|
84
|
+
states several times a month.
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
result = client.validate_vat("IE6388047V")
|
|
88
|
+
vat = result.vat_details
|
|
89
|
+
|
|
90
|
+
vat.format_valid # True — structural, decided locally, never depends on VIES
|
|
91
|
+
vat.registered # True | False | None
|
|
92
|
+
vat.source # "LIVE" | "CACHE" | "STALE" | "UNVERIFIED" | "NOT_APPLICABLE"
|
|
93
|
+
vat.trader_name # "GOOGLE IRELAND LIMITED" — when the member state discloses it
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**`registered is None` means unknown, never "not registered."** It is what you get when VIES could
|
|
97
|
+
not be consulted. Treating it as `False` rejects legitimate businesses during someone else's outage:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
if not vat.format_valid:
|
|
101
|
+
return reject("That VAT number is not correctly formed.")
|
|
102
|
+
if vat.registered is False:
|
|
103
|
+
return reject("That VAT number is not registered.")
|
|
104
|
+
|
|
105
|
+
if vat.registered is None:
|
|
106
|
+
# Accept, record that it is unconfirmed, and re-check later.
|
|
107
|
+
queue_for_recheck(vat_number)
|
|
108
|
+
return accept(verified=False)
|
|
109
|
+
|
|
110
|
+
return accept(verified=True, stale=vat.source == "STALE")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use `is False` and `is None`, not `not vat.registered`: the latter lumps the two together.
|
|
114
|
+
|
|
115
|
+
### Does the number belong to this company?
|
|
116
|
+
|
|
117
|
+
Pass the name you expect — from a supplier form, for instance — and the response says whether it
|
|
118
|
+
matches the registered holder:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
result = client.validate_vat("ESA28015865", trader_name="Telefonica")
|
|
122
|
+
|
|
123
|
+
result.vat_details.trader_name_match # "MATCH" | "MISMATCH" | "NOT_AVAILABLE"
|
|
124
|
+
result.vat_details.trader_name_match_source # "VERIFNOW" | "VIES"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Who compares depends on the member state. Where VIES publishes the holder's name (most of them),
|
|
128
|
+
VerifNow compares, ignoring case, accents, punctuation and legal forms. Spain publishes no name but
|
|
129
|
+
has VIES check one. Germany does neither, and the answer is `NOT_AVAILABLE` rather than a guess. A
|
|
130
|
+
`MISMATCH` is a question for a human, not proof of fraud.
|
|
131
|
+
|
|
132
|
+
When your account has its own VAT number configured, `vat_details.consultation_number` carries the
|
|
133
|
+
receipt VIES issues for the lookup: the evidence a tax authority accepts that you checked.
|
|
134
|
+
|
|
135
|
+
Per-country VIES availability is public and needs no API key:
|
|
136
|
+
[`GET /api/v1/status/vies`](https://www.verifnow.io/en/status).
|
|
137
|
+
|
|
138
|
+
### VAT rates
|
|
139
|
+
|
|
140
|
+
The rates of the 27 member states, retrieved daily from the Commission's
|
|
141
|
+
[TEDB](https://ec.europa.eu/taxation_customs/tedb/). Public reference data: these calls spend no
|
|
142
|
+
quota.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
france = client.vat_rate("FR") # GR is accepted for Greece (EL)
|
|
146
|
+
|
|
147
|
+
france.standard_rate # 20.0
|
|
148
|
+
france.reduced_rates # (2.1, 5.5, 10.0) — which one applies depends on the product
|
|
149
|
+
france.regional_rates # (RegionalVatRate(rate=8.5, note='…Martinique…', eu_vat_area=False), …)
|
|
150
|
+
france.situation_on # "2026-07-01" — the date TEDB says these rates apply from
|
|
151
|
+
france.fetched_at # datetime — when VerifNow last retrieved them
|
|
152
|
+
|
|
153
|
+
every_state = client.vat_rates().rates
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`eu_vat_area=False` marks the Canary Islands and the French overseas territories, which the VAT
|
|
157
|
+
Directive excludes: goods shipped there from another member state are an export.
|
|
158
|
+
|
|
159
|
+
**These are the rates a member state has, not the rate an invoice carries.** In B2B trade between
|
|
160
|
+
member states the invoice is usually zero-rated under the reverse charge, whatever the buyer's
|
|
161
|
+
country rate is. Multiplying an amount by the buyer's standard rate is wrong in exactly the case a
|
|
162
|
+
VAT number is collected for.
|
|
163
|
+
|
|
164
|
+
## Validators
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
client.validate_email("user@example.com")
|
|
168
|
+
client.validate_phone("+33612345678") # country code required
|
|
169
|
+
client.validate_iban("FR7630006000011234567890189")
|
|
170
|
+
client.validate_vat("FR12345678901")
|
|
171
|
+
client.validate_nas("046454286") # Canadian Social Insurance Number
|
|
172
|
+
client.validate_ssn(form["ssn"]) # US Social Security Number — never commit a real one
|
|
173
|
+
client.validate_nif("B12345674") # Spanish NIF — DNI, NIE or company
|
|
174
|
+
|
|
175
|
+
# When the rule is only known at runtime
|
|
176
|
+
client.validate("iban", value)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Every call returns the same frozen `ValidationResult`:
|
|
180
|
+
|
|
181
|
+
| Field | |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `valid` | `bool` |
|
|
184
|
+
| `message` | human-readable explanation |
|
|
185
|
+
| `normalized_value` | canonical form (E.164 for a phone), `None` when invalid |
|
|
186
|
+
| `original_value` | the value as submitted |
|
|
187
|
+
| `validation_level` | `"BASIC"`, `"STANDARD"`, `"ADVANCED"` or `"PREMIUM"` |
|
|
188
|
+
| `email_details` | email only — risk score, deliverability, signals |
|
|
189
|
+
| `vat_details` | VAT only — registration, source, trader name and match |
|
|
190
|
+
| `phone_details` | phone only — country, line type, formats |
|
|
191
|
+
| `iban_details` | IBAN only — structure, checksum and SEPA scope |
|
|
192
|
+
| `nas_details` | Canadian SIN only — temporary resident, series |
|
|
193
|
+
| `nif_details` | Spanish NIF only — DNI, NIE or company, legal form |
|
|
194
|
+
| `ssn_details` | US SSN only — whether the number is an ITIN |
|
|
195
|
+
| `quota` | counters from the `X-RateLimit-*` headers |
|
|
196
|
+
| `raw` | the untouched response body |
|
|
197
|
+
|
|
198
|
+
Enumerated values are plain strings typed with `Literal`, so your type checker knows them and a
|
|
199
|
+
value a newer API adds does not break parsing.
|
|
200
|
+
|
|
201
|
+
## Email signals and your plan
|
|
202
|
+
|
|
203
|
+
Email validation returns a per-signal breakdown. **Which signals are present depends on your
|
|
204
|
+
plan**, so branch on `applied_level` rather than assuming a field is set:
|
|
205
|
+
|
|
206
|
+
| Signal | STANDARD (Free, Starter) | ADVANCED (Growth) | PREMIUM (Pro) |
|
|
207
|
+
|--------|:------------------------:|:-----------------:|:-------------:|
|
|
208
|
+
| `syntax_valid`, `mx_valid` | ✅ | ✅ | ✅ |
|
|
209
|
+
| `typo_detected`, `suggested_domain` | ✅ | ✅ | ✅ |
|
|
210
|
+
| `role_based`, `disposable` | ✅ | ✅ | ✅ |
|
|
211
|
+
| `risk_score` (0–100), `deliverability` | ✅ | ✅ | ✅ |
|
|
212
|
+
| `free_provider`, `domain_age_days` | ❌ | ✅ | ✅ |
|
|
213
|
+
| `mx_provider`, `mx_quality_score` | ❌ | ✅ | ✅ |
|
|
214
|
+
| `risk_level` (LOW/MEDIUM/HIGH) | ❌ | ✅ | ✅ |
|
|
215
|
+
|
|
216
|
+
A signal the applied level does not compute is `None`, never `False`.
|
|
217
|
+
|
|
218
|
+
## Error handling
|
|
219
|
+
|
|
220
|
+
**This SDK raises when it cannot reach the API. It never reports an unverified value as valid.**
|
|
221
|
+
A validation client that swallows an outage and answers `valid=True` turns downtime into silently
|
|
222
|
+
accepted bad data, and you find out months later. Deciding to accept input during an outage is
|
|
223
|
+
reasonable — it should just be your decision, written down:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from verifnow import (
|
|
227
|
+
VerifNowAuthError,
|
|
228
|
+
VerifNowConnectionError,
|
|
229
|
+
VerifNowRateLimitError,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
try:
|
|
233
|
+
return client.validate_email(email).valid
|
|
234
|
+
except VerifNowAuthError:
|
|
235
|
+
raise # misconfiguration — fix it, do not degrade
|
|
236
|
+
except VerifNowRateLimitError as error:
|
|
237
|
+
log.warning("VerifNow quota exhausted until %s", error.quota and error.quota.reset_at)
|
|
238
|
+
return True # deliberate: accept rather than block signups
|
|
239
|
+
except VerifNowConnectionError:
|
|
240
|
+
log.exception("VerifNow unreachable, accepting unverified")
|
|
241
|
+
return True
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
| Exception | Raised on | Retried |
|
|
245
|
+
|-----------|-----------|:-------:|
|
|
246
|
+
| `VerifNowRequestError` | 400 / 404 — malformed payload, empty value, unknown country | no |
|
|
247
|
+
| `VerifNowAuthError` | 401 / 403 — key missing, invalid or revoked | no |
|
|
248
|
+
| `VerifNowRateLimitError` | 429 — monthly quota or concurrency limit | only if the reset is imminent |
|
|
249
|
+
| `VerifNowServerError` | 5xx | yes |
|
|
250
|
+
| `VerifNowConnectionError` | DNS, TLS, refused connection, timeout | yes |
|
|
251
|
+
| `VerifNowResponseError` | 2xx with an unparseable body | no |
|
|
252
|
+
|
|
253
|
+
All inherit from `VerifNowError` and carry `status` and `request_id` where available — quote the
|
|
254
|
+
request id in a support request. `VerifNowRateLimitError` adds `quota` and `retry_after` (seconds).
|
|
255
|
+
|
|
256
|
+
## Quota
|
|
257
|
+
|
|
258
|
+
Every successful response carries the quota counters:
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
quota = client.validate_email(email).quota
|
|
262
|
+
|
|
263
|
+
quota.remaining # 187
|
|
264
|
+
quota.limit # 250
|
|
265
|
+
quota.reset_at # datetime (UTC) — start of the next billing period
|
|
266
|
+
quota.overage # True once you are billed per unit
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Paid plans are never cut off: past the included quota, extra requests are billed per unit and
|
|
270
|
+
`overage` flips to `True`. The Free plan blocks at its limit with a 429.
|
|
271
|
+
|
|
272
|
+
## asyncio
|
|
273
|
+
|
|
274
|
+
`AsyncVerifNow` has the same methods, awaitable:
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from verifnow import AsyncVerifNow
|
|
278
|
+
|
|
279
|
+
client = AsyncVerifNow()
|
|
280
|
+
|
|
281
|
+
result = await client.validate_vat("IE6388047V", trader_name="Google Ireland")
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Each call runs in a worker thread (`asyncio.to_thread`), which keeps the SDK free of an async HTTP
|
|
285
|
+
dependency and never blocks your event loop, retries included.
|
|
286
|
+
|
|
287
|
+
## Configuration
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
from verifnow import RetryPolicy, VerifNow
|
|
291
|
+
|
|
292
|
+
client = VerifNow(
|
|
293
|
+
"vn_...", # default: the VERIFNOW_API_KEY environment variable
|
|
294
|
+
base_url="https://api.verifnow.io", # default
|
|
295
|
+
timeout=5.0, # default, seconds, per attempt
|
|
296
|
+
retry=RetryPolicy(
|
|
297
|
+
attempts=2, # default — up to 3 requests in total
|
|
298
|
+
backoff=0.2, # default, seconds, doubles each attempt
|
|
299
|
+
max_backoff=2.0, # default
|
|
300
|
+
),
|
|
301
|
+
headers={"X-Trace-Id": trace_id}, # added to every request
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
client.validate_email(email, timeout=1.0) # per-call override
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Pass `retry=None` to disable retries. The `transport` argument replaces the built-in `urllib`
|
|
308
|
+
transport — a callable taking an `HttpRequest` and returning an `HttpResponse` — for tests, or to
|
|
309
|
+
route calls through your own HTTP client.
|
|
310
|
+
|
|
311
|
+
## Validating at the edge of your app
|
|
312
|
+
|
|
313
|
+
Validate on the server, where data enters — not in the browser, which would expose your API key
|
|
314
|
+
and can be bypassed:
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
# FastAPI
|
|
318
|
+
from fastapi import FastAPI, HTTPException
|
|
319
|
+
from verifnow import AsyncVerifNow, VerifNowError
|
|
320
|
+
|
|
321
|
+
app = FastAPI()
|
|
322
|
+
verifnow = AsyncVerifNow()
|
|
323
|
+
|
|
324
|
+
@app.post("/signup")
|
|
325
|
+
async def signup(email: str) -> dict[str, bool]:
|
|
326
|
+
try:
|
|
327
|
+
result = await verifnow.validate_email(email)
|
|
328
|
+
except VerifNowError:
|
|
329
|
+
await create_account(email, verified=False) # accept rather than block the signup
|
|
330
|
+
return {"ok": True}
|
|
331
|
+
|
|
332
|
+
if not result.valid:
|
|
333
|
+
signals = result.email_details.signals if result.email_details else None
|
|
334
|
+
raise HTTPException(422, {
|
|
335
|
+
"error": result.message,
|
|
336
|
+
"suggestion": signals.suggested_domain if signals else None,
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
await create_account(result.normalized_value, verified=True) # store the canonical form
|
|
340
|
+
return {"ok": True}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Other SDKs
|
|
344
|
+
|
|
345
|
+
- **Node.js / TypeScript**: [`@verifnow/sdk`](https://www.npmjs.com/package/@verifnow/sdk)
|
|
346
|
+
- **Java / Spring**: [`io.verifnow:verifnow-spring-boot-starter`](https://central.sonatype.com/artifact/io.verifnow/verifnow-spring-boot-starter)
|
|
347
|
+
|
|
348
|
+
## Documentation
|
|
349
|
+
|
|
350
|
+
- API reference and guides: [docs.verifnow.io](https://docs.verifnow.io)
|
|
351
|
+
- Pricing and plans: [verifnow.io/pricing](https://www.verifnow.io/en/pricing)
|
|
352
|
+
|
|
353
|
+
## License
|
|
354
|
+
|
|
355
|
+
Apache-2.0
|