Skip to content

Commit e400686

Browse files
docs: rewrite README with accurate copy, fix broken links, remove phantom Discord
- Rewrote from scratch aligned with business plan v13.6.21 positioning - Removed all broken links (api.validkit.com/docs 404, Discord doesn't exist) - Removed references to nonexistent example files - Removed duplicate Error Handling and License sections - Fixed CompactResult.d type: bool → bool | None (matches Optional[bool] model) - Fixed error handling example: added ValidKitError catch-all (TimeoutError/ConnectionError inherit from ValidKitError, not ValidKitAPIError) - Fixed format parameter: use ResponseFormat.FULL enum instead of string literal - Added None guard for optional MX records access Reviewed by developer-docs-writer (technical accuracy) and code-reviewer (code examples). Closes #2340
1 parent c2ebfc6 commit e400686

1 file changed

Lines changed: 102 additions & 167 deletions

File tree

README.md

Lines changed: 102 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,249 +1,184 @@
11
# ValidKit Python SDK
22

3-
[![PyPI version](https://badge.fury.io/py/validkit.svg)](https://badge.fury.io/py/validkit)
3+
[![PyPI version](https://badge.fury.io/py/validkit.svg)](https://pypi.org/project/validkit/)
44
[![Python Versions](https://img.shields.io/pypi/pyversions/validkit.svg)](https://pypi.org/project/validkit/)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6-
[![Documentation](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://docs.validkit.com)
76

8-
Async Python SDK for ValidKit Email Verification API - Built for AI Agents and high-volume applications.
9-
10-
## Features
11-
12-
- 🚀 **Fully Async**: Built on aiohttp for maximum performance
13-
- 🤖 **AI-Agent Optimized**: Token-efficient responses and agent-friendly formats
14-
- 📦 **Batch Processing**: Verify up to 10,000 emails in a single request
15-
- 🔄 **Smart Retries**: Automatic retry logic with exponential backoff
16-
- 🌊 **Connection Pooling**: Efficient connection reuse for high throughput
17-
- 📊 **Progress Tracking**: Real-time progress updates for large batches
18-
- 🪝 **Webhook Support**: Async webhook handling for batch results
19-
- 🔍 **Type Safety**: Full type hints and Pydantic models
20-
21-
**Full API Documentation**: https://api.validkit.com/docs/openapi.json
7+
Email validation for signup flows -- block junk without blocking `test+staging@example.com`. Async Python client with batch support up to 10K emails, automatic retries, and Pydantic models.
228

239
## Installation
2410

2511
```bash
2612
pip install validkit
2713
```
2814

15+
Requires Python 3.8+.
16+
2917
## Quick Start
3018

3119
```python
3220
import asyncio
3321
from validkit import AsyncValidKit
3422

3523
async def main():
36-
# Initialize the client
3724
async with AsyncValidKit(api_key="your_api_key") as client:
38-
# Single email verification
25+
# Single email
3926
result = await client.verify_email("user@example.com")
40-
print(f"Valid: {result.valid}")
41-
42-
# Batch verification
43-
emails = ["user1@example.com", "user2@example.com", "user3@example.com"]
44-
results = await client.verify_batch(emails)
45-
46-
for email, result in results.items():
47-
print(f"{email}: {result.valid}")
27+
print(result.valid) # True
4828

49-
asyncio.run(main())
50-
```
29+
# Batch -- compact format by default
30+
results = await client.verify_batch([
31+
"alice@company.com",
32+
"bob@tempmail.com",
33+
"not-an-email",
34+
])
35+
for email, r in results.items():
36+
print(f"{email}: valid={r.v}, disposable={r.d}")
5137

52-
## Advanced Usage
53-
54-
### Batch Processing with Progress
55-
56-
```python
57-
async def verify_large_batch():
58-
async with AsyncValidKit(api_key="your_api_key") as client:
59-
emails = ["email{}@example.com".format(i) for i in range(10000)]
60-
61-
# Process with progress callback
62-
async def progress_callback(processed, total):
63-
print(f"Progress: {processed}/{total} ({processed/total*100:.1f}%)")
64-
65-
results = await client.verify_batch(
66-
emails,
67-
chunk_size=1000,
68-
progress_callback=progress_callback
69-
)
70-
71-
valid_count = sum(1 for r in results.values() if r.valid)
72-
print(f"Valid emails: {valid_count}/{len(emails)}")
38+
asyncio.run(main())
7339
```
7440

75-
### Webhook Support
41+
## Features
7642

77-
```python
78-
# Start async batch job with webhook
79-
job = await client.verify_batch_async(
80-
emails=large_email_list,
81-
webhook_url="https://your-app.com/webhook/validkit",
82-
webhook_headers={"Authorization": "Bearer your_token"}
83-
)
43+
- **Async-native** -- aiohttp with connection pooling (100 connections default)
44+
- **Batch verification** -- up to 10,000 emails per call, chunked automatically
45+
- **Developer Pattern Intelligence** -- understands `test@`, `+addressing`, disposable domains
46+
- **Compact format** -- token-efficient responses (`v`, `d`, `r` fields) enabled by default
47+
- **Streaming** -- `async for` results as they complete
48+
- **Webhook delivery** -- fire-and-forget async batch jobs with callback
49+
- **Automatic retries** -- exponential backoff, 3 retries default
50+
- **Type-safe** -- Pydantic v2 models with full type hints
8451

85-
print(f"Batch job started: {job.id}")
86-
print(f"Check status at: {job.status_url}")
87-
```
52+
## Advanced Usage
8853

89-
### Custom Configuration
54+
### Custom configuration
9055

9156
```python
9257
from validkit import AsyncValidKit, ValidKitConfig
9358

9459
config = ValidKitConfig(
9560
api_key="your_api_key",
96-
base_url="https://api.validkit.com",
97-
timeout=30,
98-
max_retries=3,
99-
max_connections=100,
100-
rate_limit=10000 # requests per minute
61+
timeout=30, # seconds
62+
max_retries=3, # retry count
63+
max_connections=100, # connection pool size
64+
rate_limit=10000, # requests/min (None = unlimited)
65+
compact_format=True, # smaller payloads
10166
)
10267

10368
async with AsyncValidKit(config=config) as client:
104-
# Your code here
105-
pass
69+
result = await client.verify_email("user@example.com")
10670
```
10771

108-
## Response Format
109-
110-
### Single Email Response
72+
### Batch with progress tracking
11173

11274
```python
113-
{
114-
"valid": true,
115-
"email": "user@example.com",
116-
"format": {"valid": true},
117-
"disposable": {"valid": true, "value": false},
118-
"mx": {"valid": true, "records": ["mx1.example.com"]},
119-
"smtp": {"valid": true}
120-
}
75+
def on_progress(processed, total):
76+
print(f"{processed}/{total} ({processed / total * 100:.1f}%)")
77+
78+
results = await client.verify_batch(
79+
emails,
80+
chunk_size=1000,
81+
progress_callback=on_progress,
82+
)
12183
```
12284

123-
### Batch Response (Compact Format)
85+
### Async batch with webhook
12486

12587
```python
126-
{
127-
"user1@example.com": {"v": true, "d": false},
128-
"user2@example.com": {"v": false, "r": "invalid_format"},
129-
"user3@example.com": {"v": true, "d": true}
130-
}
131-
```
88+
job = await client.verify_batch_async(
89+
emails=large_list,
90+
webhook_url="https://your-app.com/webhooks/validkit",
91+
webhook_headers={"Authorization": "Bearer token"},
92+
)
13293

133-
Where:
134-
- `v`: valid (boolean)
135-
- `d`: disposable (boolean)
136-
- `r`: reason (string, only if invalid)
94+
# Poll until complete, or wait for webhook
95+
job = await client.get_batch_status(job.id)
96+
results = await client.get_batch_results(job.id)
13797

138-
## Agent-Optimized Features
98+
# Cancel if needed
99+
await client.cancel_batch(job.id)
100+
```
139101

140-
### Token-Efficient Mode
102+
### Streaming
141103

142104
```python
143-
# Get compact responses (80% smaller)
144-
result = await client.verify_email(
145-
"user@example.com",
146-
format="compact"
147-
)
105+
async for email, result in client.stream_verify(emails, batch_size=100):
106+
print(f"{email}: valid={result.v}")
148107
```
149108

150-
### Multi-Agent Tracing
109+
### Trace IDs
110+
111+
Attach a trace ID for cross-service debugging:
151112

152113
```python
153-
# Include trace headers for multi-agent debugging
154-
result = await client.verify_email(
155-
"user@example.com",
156-
trace_id="agent_123_task_456"
157-
)
114+
result = await client.verify_email("user@example.com", trace_id="req_abc123")
158115
```
159116

160117
## Error Handling
161118

162119
```python
163120
from validkit.exceptions import (
164-
ValidKitAPIError,
165-
RateLimitError,
166-
InvalidAPIKeyError,
167-
BatchSizeError
121+
ValidKitError, # base -- catches everything
122+
ValidKitAPIError, # API errors (4xx, 5xx)
123+
InvalidAPIKeyError, # 401
124+
RateLimitError, # 429, includes retry_after
125+
BatchSizeError, # batch exceeds 10K
126+
TimeoutError, # request timeout (inherits ValidKitError, not API)
127+
ConnectionError, # network failure (inherits ValidKitError, not API)
168128
)
169129

170130
try:
171-
result = await client.verify_email("invalid-email")
131+
result = await client.verify_email("user@example.com")
132+
except RateLimitError as e:
133+
print(e.retry_after) # seconds until retry
134+
except InvalidAPIKeyError:
135+
print("Check your API key")
172136
except ValidKitAPIError as e:
173-
print(f"API Error: {e.message}")
174-
print(f"Error Code: {e.code}")
175-
print(f"Status Code: {e.status_code}")
137+
print(e.message, e.status_code, e.code)
138+
except ValidKitError as e:
139+
# Catches TimeoutError, ConnectionError, and any other non-API errors
140+
print(f"SDK error: {e}")
176141
```
177142

178-
## Rate Limiting
143+
The SDK retries automatically on rate limits and transient errors (up to `max_retries`). Catch exceptions only if you need custom handling.
144+
145+
## Compact Response Format
179146

180-
The SDK automatically handles rate limiting with smart backoff:
147+
Default format. Smaller payloads, same information:
148+
149+
| Field | Type | Meaning |
150+
|-------|------|---------|
151+
| `v` | `bool` | Email is valid |
152+
| `d` | `bool \| None` | Domain is disposable (None if not checked) |
153+
| `r` | `str \| None` | Reason (present only when invalid) |
181154

182155
```python
183-
# SDK will automatically retry with exponential backoff
184-
results = await client.verify_batch(
185-
large_email_list,
186-
auto_retry=True # Default: True
187-
)
156+
# Compact (default)
157+
r = await client.verify_email("bad@example.com")
158+
print(r.v, r.d, r.r) # False, False, "invalid_format"
159+
160+
# Full format -- use when you need MX records, SMTP details
161+
from validkit.models import ResponseFormat
162+
full = await client.verify_email("user@example.com", format=ResponseFormat.FULL)
163+
if full.mx:
164+
print(full.mx.records) # ["mx1.example.com"]
188165
```
189166

190167
## Examples
191168

192-
Check the `examples/` directory for more detailed examples:
193-
194-
- `basic_usage.py` - Simple verification examples
195-
- `batch_processing.py` - Large batch processing patterns
196-
- `webhook_handler.py` - Webhook endpoint implementation
197-
- `agent_integration.py` - AI agent integration patterns
198-
- `error_handling.py` - Comprehensive error handling
199-
200-
## Requirements
201-
202-
- Python 3.8+
203-
- aiohttp
204-
- pydantic
169+
See [`examples/`](examples/):
205170

206-
## License
207-
208-
MIT License - see LICENSE file for details.
209-
210-
## Performance Tips
211-
212-
1. **Use batch verification** for multiple emails (up to 10,000 per request)
213-
2. **Enable connection pooling** (default) for high-throughput applications
214-
3. **Set appropriate timeouts** based on your batch size
215-
4. **Use webhooks** for large async batches to avoid long-running requests
171+
- [`basic_usage.py`](examples/basic_usage.py) -- single verification, batch, streaming, configuration
172+
- [`batch_processing.py`](examples/batch_processing.py) -- large batches, CSV processing, webhook jobs, domain analysis
216173

217174
## Contributing
218175

219-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
220-
221-
### Development Setup
222-
223-
```bash
224-
# Clone the repository
225-
git clone https://github.com/ValidKit/validkit-python-sdk.git
226-
cd validkit-python-sdk
227-
228-
# Create virtual environment
229-
python -m venv venv
230-
source venv/bin/activate # On Windows: venv\Scripts\activate
231-
232-
# Install dependencies
233-
pip install -e ".[dev]"
234-
235-
# Run tests
236-
pytest
237-
```
176+
See [CONTRIBUTING.md](CONTRIBUTING.md).
238177

239178
## Support
240179

241-
- 📖 **Documentation**: https://docs.validkit.com
242-
- 🔧 **API Reference**: https://api.validkit.com/docs/openapi.json
243-
- 🐛 **Issues**: https://github.com/ValidKit/validkit-python-sdk/issues
244-
- 📧 **Email**: support@validkit.com
245-
- 💬 **Discord**: [Join our community](https://discord.gg/validkit)
180+
[Docs](https://docs.validkit.com) -- [GitHub Issues](https://github.com/ValidKit/validkit-python-sdk/issues) -- support@validkit.com
246181

247-
---
182+
## License
248183

249-
Built with ❤️ for AI agents by [ValidKit](https://validkit.com)
184+
MIT -- see [LICENSE](LICENSE).

0 commit comments

Comments
 (0)