AD-SearchAPI 1.0.3__tar.gz → 2.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.
@@ -0,0 +1,443 @@
1
+ Metadata-Version: 2.4
2
+ Name: AD-SearchAPI
3
+ Version: 2.0.0
4
+ Summary: A comprehensive Python client library for the Search API with enhanced error handling and balance management
5
+ Home-page: https://github.com/AntiChrist-Coder/search_api_library
6
+ Author: Search API Team
7
+ Author-email: support@search-api.dev
8
+ Project-URL: Bug Reports, https://github.com/AntiChrist-Coder/search_api_library/issues
9
+ Project-URL: Source, https://github.com/AntiChrist-Coder/search_api_library
10
+ Project-URL: Documentation, https://github.com/AntiChrist-Coder/search_api_library/blob/main/README.md
11
+ Keywords: search-api,email-search,phone-search,domain-search,people-search,api-client,balance-management,caching
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Communications :: Email
24
+ Classifier: Topic :: Internet :: Name Service (DNS)
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: requests>=2.31.0
29
+ Requires-Dist: phonenumbers>=8.13.0
30
+ Requires-Dist: python-dateutil>=2.8.2
31
+ Requires-Dist: cachetools>=5.3.0
32
+ Requires-Dist: typing-extensions>=4.7.0
33
+ Requires-Dist: urllib3>=2.0.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: black>=23.0.0; extra == "dev"
38
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
39
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
40
+ Provides-Extra: brotli
41
+ Requires-Dist: brotli>=1.0.0; extra == "brotli"
42
+ Dynamic: author
43
+ Dynamic: author-email
44
+ Dynamic: classifier
45
+ Dynamic: description
46
+ Dynamic: description-content-type
47
+ Dynamic: home-page
48
+ Dynamic: keywords
49
+ Dynamic: license-file
50
+ Dynamic: project-url
51
+ Dynamic: provides-extra
52
+ Dynamic: requires-dist
53
+ Dynamic: requires-python
54
+ Dynamic: summary
55
+
56
+ # Search API Python Client v2.0
57
+
58
+ A comprehensive Python client library for the Search API with enhanced error handling, balance management, and improved data processing. Acquire your API key through @ADSearchEngine_bot on Telegram.
59
+
60
+ ## 🚀 New in v2.0
61
+
62
+ - **Enhanced Balance Management**: Automatic balance checking before operations
63
+ - **Access Logs Integration**: Retrieve and analyze API access logs
64
+ - **Improved Error Handling**: Comprehensive exception hierarchy with detailed error messages
65
+ - **Advanced Caching**: Configurable response caching with TTL
66
+ - **Better Data Models**: Enhanced data structures with metadata
67
+ - **Context Manager Support**: Automatic resource cleanup
68
+ - **Comprehensive Validation**: Input validation for all search types
69
+ - **Multiple Phone Formats**: Support for international, national, and E164 formats
70
+ - **Batch Operations**: Efficient handling of multiple searches
71
+ - **Debug Mode**: Detailed logging for troubleshooting
72
+
73
+ ## 📦 Installation
74
+
75
+ ```bash
76
+ pip install AD-SearchAPI
77
+ ```
78
+
79
+ ## ⚡ Quick Start
80
+
81
+ ```python
82
+ from search_api import SearchAPI, InsufficientBalanceError
83
+
84
+ # Initialize the client
85
+ client = SearchAPI(api_key="your_api_key")
86
+
87
+ try:
88
+ # Check balance first
89
+ balance = client.get_balance()
90
+ print(f"Current balance: {balance}")
91
+
92
+ # Get access logs
93
+ access_logs = client.get_access_logs()
94
+ print(f"Total access log entries: {len(access_logs)}")
95
+
96
+ # Search by email
97
+ result = client.search_email(
98
+ "example@domain.com",
99
+ include_house_value=True,
100
+ include_extra_info=True
101
+ )
102
+
103
+ print(f"Name: {result.person.name if result.person else 'N/A'}")
104
+ print(f"Total results: {result.total_results}")
105
+ print(f"Search cost: ${result.search_cost}")
106
+
107
+ for addr in result.addresses:
108
+ print(f"Address: {addr}")
109
+ if addr.zestimate:
110
+ print(f" Zestimate: ${addr.zestimate:,.2f}")
111
+
112
+ except InsufficientBalanceError as e:
113
+ print(f"Insufficient balance: {e}")
114
+ print(f"Current: {e.current_balance}, Required: {e.required_credits}")
115
+ ```
116
+
117
+ ## 🔧 Advanced Configuration
118
+
119
+ ```python
120
+ from search_api import SearchAPI, SearchAPIConfig
121
+
122
+ config = SearchAPIConfig(
123
+ api_key="your_api_key",
124
+ debug_mode=True, # Enable debug logging
125
+ enable_caching=True, # Enable response caching
126
+ cache_ttl=1800, # 30 minutes cache
127
+ max_cache_size=500, # Maximum cache entries
128
+ timeout=120, # 2 minutes timeout
129
+ max_retries=5, # Retry failed requests
130
+ proxy={ # Optional proxy
131
+ "http": "http://proxy:8080",
132
+ "https": "https://proxy:8080"
133
+ }
134
+ )
135
+
136
+ client = SearchAPI(config=config)
137
+ ```
138
+
139
+ ## 💰 Balance Management
140
+
141
+ The client automatically checks your account balance before making requests:
142
+
143
+ ```python
144
+ from search_api import InsufficientBalanceError
145
+
146
+ try:
147
+ # Get current balance
148
+ balance = client.get_balance()
149
+ print(f"Balance: {balance.current_balance} {balance.currency}")
150
+ print(f"Cost per search: {balance.credit_cost_per_search}")
151
+
152
+ # Check if you have enough for multiple searches
153
+ required_credits = 10
154
+ if balance.current_balance < required_credits:
155
+ print(f"⚠️ Insufficient balance for {required_credits} searches")
156
+ else:
157
+ print(f"✅ Sufficient balance for {required_credits} searches")
158
+
159
+ except InsufficientBalanceError as e:
160
+ print(f"❌ Insufficient balance: {e}")
161
+ print(f" Current: {e.current_balance}")
162
+ print(f" Required: {e.required_credits}")
163
+ ```
164
+
165
+ ## 📊 Access Logs
166
+
167
+ Retrieve and analyze your API access logs:
168
+
169
+ ```python
170
+ # Get all access logs
171
+ access_logs = client.get_access_logs()
172
+
173
+ print(f"Total access log entries: {len(access_logs)}")
174
+
175
+ # Show recent activity
176
+ for log in access_logs[:5]:
177
+ print(f"IP: {log.ip_address}")
178
+ print(f"Last accessed: {log.last_accessed}")
179
+ print(f"Endpoint: {log.endpoint}")
180
+ print(f"Status: {log.status_code}")
181
+ print(f"Response time: {log.response_time:.3f}s")
182
+ print("---")
183
+
184
+ # Analyze access patterns
185
+ unique_ips = set(log.ip_address for log in access_logs)
186
+ print(f"Unique IP addresses: {len(unique_ips)}")
187
+
188
+ # Find most active IP
189
+ ip_counts = {}
190
+ for log in access_logs:
191
+ ip_counts[log.ip_address] = ip_counts.get(log.ip_address, 0) + 1
192
+
193
+ most_active_ip = max(ip_counts.items(), key=lambda x: x[1])
194
+ print(f"Most active IP: {most_active_ip[0]} ({most_active_ip[1]} accesses)")
195
+ ```
196
+
197
+ ## 🔍 Search Operations
198
+
199
+ ### Email Search
200
+
201
+ ```python
202
+ result = client.search_email(
203
+ "john.doe@example.com",
204
+ include_house_value=True,
205
+ include_extra_info=True,
206
+ phone_format="international" # or "national", "e164"
207
+ )
208
+
209
+ print(f"Email: {result.email}")
210
+ print(f"Valid: {result.email_valid}")
211
+ print(f"Type: {result.email_type}")
212
+
213
+ if result.person:
214
+ print(f"Name: {result.person.name}")
215
+ print(f"DOB: {result.person.dob}")
216
+ print(f"Age: {result.person.age}")
217
+
218
+ for addr in result.addresses:
219
+ print(f"Address: {addr}")
220
+ if addr.zestimate:
221
+ print(f" Zestimate: ${addr.zestimate:,.2f}")
222
+
223
+ for phone in result.phone_numbers:
224
+ print(f"Phone: {phone.number}")
225
+ print(f" Valid: {phone.is_valid}")
226
+ print(f" Type: {phone.phone_type}")
227
+ print(f" Carrier: {phone.carrier}")
228
+ ```
229
+
230
+ ### Phone Search
231
+
232
+ ```python
233
+ results = client.search_phone(
234
+ "+1234567890",
235
+ include_house_value=True,
236
+ include_extra_info=True,
237
+ phone_format="international"
238
+ )
239
+
240
+ for result in results:
241
+ print(f"Phone: {result.phone.number}")
242
+ print(f"Valid: {result.phone.is_valid}")
243
+ print(f"Type: {result.phone.phone_type}")
244
+ print(f"Carrier: {result.phone.carrier}")
245
+
246
+ if result.person:
247
+ print(f"Name: {result.person.name}")
248
+ print(f"DOB: {result.person.dob}")
249
+
250
+ print(f"Total results: {result.total_results}")
251
+ print(f"Search cost: ${result.search_cost}")
252
+ ```
253
+
254
+ ### Domain Search
255
+
256
+ ```python
257
+ result = client.search_domain("example.com")
258
+
259
+ print(f"Domain: {result.domain}")
260
+ print(f"Valid: {result.domain_valid}")
261
+ print(f"Total results: {result.total_results}")
262
+ print(f"Search cost: ${result.search_cost}")
263
+
264
+ for email_result in result.results:
265
+ print(f"Email: {email_result.email}")
266
+ print(f"Valid: {email_result.email_valid}")
267
+ print(f"Type: {email_result.email_type}")
268
+
269
+ if email_result.person:
270
+ print(f"Name: {email_result.person.name}")
271
+ ```
272
+
273
+ ## 🛡️ Error Handling
274
+
275
+ The library provides comprehensive error handling with specific exception types:
276
+
277
+ ```python
278
+ from search_api import (
279
+ SearchAPIError,
280
+ AuthenticationError,
281
+ ValidationError,
282
+ InsufficientBalanceError,
283
+ RateLimitError,
284
+ ServerError,
285
+ NetworkError,
286
+ TimeoutError,
287
+ ConfigurationError
288
+ )
289
+
290
+ try:
291
+ result = client.search_email("test@example.com")
292
+ except ValidationError as e:
293
+ print(f"Invalid input: {e}")
294
+ except InsufficientBalanceError as e:
295
+ print(f"Insufficient balance: {e}")
296
+ print(f"Current: {e.current_balance}, Required: {e.required_credits}")
297
+ except AuthenticationError as e:
298
+ print(f"Authentication failed: {e}")
299
+ except RateLimitError as e:
300
+ print(f"Rate limit exceeded: {e}")
301
+ except ServerError as e:
302
+ print(f"Server error: {e}")
303
+ except NetworkError as e:
304
+ print(f"Network error: {e}")
305
+ except TimeoutError as e:
306
+ print(f"Request timeout: {e}")
307
+ except SearchAPIError as e:
308
+ print(f"API error: {e}")
309
+ ```
310
+
311
+ ## 🔄 Caching
312
+
313
+ The client supports configurable response caching:
314
+
315
+ ```python
316
+ # Enable caching with custom settings
317
+ config = SearchAPIConfig(
318
+ api_key="your_api_key",
319
+ enable_caching=True,
320
+ cache_ttl=3600, # 1 hour
321
+ max_cache_size=1000 # Maximum 1000 cached responses
322
+ )
323
+
324
+ client = SearchAPI(config=config)
325
+
326
+ # Cache is automatically used for repeated searches
327
+ result1 = client.search_email("test@example.com") # Cached
328
+ result2 = client.search_email("test@example.com") # From cache
329
+
330
+ # Clear cache when needed
331
+ client.clear_cache()
332
+ ```
333
+
334
+ ## 🧹 Context Manager
335
+
336
+ Use the client as a context manager for automatic resource cleanup:
337
+
338
+ ```python
339
+ with SearchAPI(api_key="your_api_key") as client:
340
+ balance = client.get_balance()
341
+ result = client.search_email("test@example.com")
342
+ # Resources automatically cleaned up when exiting context
343
+ ```
344
+
345
+ ## 📊 Data Models
346
+
347
+ ### Address Model
348
+
349
+ ```python
350
+ @dataclass
351
+ class Address:
352
+ street: str
353
+ city: Optional[str] = None
354
+ state: Optional[str] = None
355
+ postal_code: Optional[str] = None
356
+ country: Optional[str] = None
357
+ zestimate: Optional[Decimal] = None
358
+ zpid: Optional[str] = None
359
+ bedrooms: Optional[int] = None
360
+ bathrooms: Optional[float] = None
361
+ living_area: Optional[int] = None
362
+ home_status: Optional[str] = None
363
+ last_known_date: Optional[date] = None
364
+ ```
365
+
366
+ ### Person Model
367
+
368
+ ```python
369
+ @dataclass
370
+ class Person:
371
+ name: Optional[str] = None
372
+ dob: Optional[date] = None
373
+ age: Optional[int] = None
374
+ ```
375
+
376
+ ### PhoneNumber Model
377
+
378
+ ```python
379
+ @dataclass
380
+ class PhoneNumber:
381
+ number: str
382
+ country_code: str = "US"
383
+ is_valid: bool = True
384
+ phone_type: Optional[str] = None
385
+ carrier: Optional[str] = None
386
+ ```
387
+
388
+ ### BalanceInfo Model
389
+
390
+ ```python
391
+ @dataclass
392
+ class BalanceInfo:
393
+ current_balance: float
394
+ currency: str = "USD"
395
+ last_updated: Optional[datetime] = None
396
+ credit_cost_per_search: Optional[float] = None
397
+ ```
398
+
399
+ ### AccessLog Model
400
+
401
+ ```python
402
+ @dataclass
403
+ class AccessLog:
404
+ ip_address: str
405
+ last_accessed: Optional[datetime] = None
406
+ user_agent: Optional[str] = None
407
+ endpoint: Optional[str] = None
408
+ method: Optional[str] = None
409
+ status_code: Optional[int] = None
410
+ response_time: Optional[float] = None
411
+ ```
412
+
413
+ ## 🔧 Configuration Options
414
+
415
+ ### SearchAPIConfig
416
+
417
+ | Parameter | Type | Default | Description |
418
+ |-----------|------|---------|-------------|
419
+ | `api_key` | str | Required | Your API key |
420
+ | `base_url` | str | `"https://search-api.dev/index.php"` | API base URL |
421
+ | `max_retries` | int | `3` | Maximum retry attempts |
422
+ | `timeout` | int | `90` | Request timeout in seconds |
423
+ | `debug_mode` | bool | `False` | Enable debug logging |
424
+ | `enable_caching` | bool | `True` | Enable response caching |
425
+ | `cache_ttl` | int | `3600` | Cache time-to-live in seconds |
426
+ | `max_cache_size` | int | `1000` | Maximum cache entries |
427
+ | `proxy` | Dict | `None` | Proxy configuration |
428
+ | `user_agent` | str | Chrome UA | Custom user agent |
429
+
430
+ ## 📝 Examples
431
+
432
+ See the `examples/` directory for comprehensive usage examples:
433
+
434
+ - `basic_usage.py` - Basic search operations, balance checking, and access logs
435
+ - `advanced_usage.py` - Advanced features like caching, batch operations, and access log analysis
436
+
437
+ ## 🤝 Contributing
438
+
439
+ Contributions are welcome! Please submit a Pull Request with your changes or open an issue for discussion.
440
+
441
+ ## 📄 License
442
+
443
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,16 @@
1
+ requests>=2.31.0
2
+ phonenumbers>=8.13.0
3
+ python-dateutil>=2.8.2
4
+ cachetools>=5.3.0
5
+ typing-extensions>=4.7.0
6
+ urllib3>=2.0.0
7
+
8
+ [brotli]
9
+ brotli>=1.0.0
10
+
11
+ [dev]
12
+ pytest>=7.0.0
13
+ pytest-cov>=4.0.0
14
+ black>=23.0.0
15
+ flake8>=6.0.0
16
+ mypy>=1.0.0
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Search API Team
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
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Search API Team
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
21
  SOFTWARE.