leadwebia 0.2.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.
- leadwebia-0.2.0/.gitignore +9 -0
- leadwebia-0.2.0/LICENSE +21 -0
- leadwebia-0.2.0/PKG-INFO +202 -0
- leadwebia-0.2.0/README.md +177 -0
- leadwebia-0.2.0/pyproject.toml +45 -0
- leadwebia-0.2.0/src/leadwebia/__init__.py +41 -0
- leadwebia-0.2.0/src/leadwebia/__main__.py +68 -0
- leadwebia-0.2.0/src/leadwebia/_http.py +129 -0
- leadwebia-0.2.0/src/leadwebia/_version.py +1 -0
- leadwebia-0.2.0/src/leadwebia/client.py +340 -0
- leadwebia-0.2.0/src/leadwebia/errors.py +89 -0
- leadwebia-0.2.0/src/leadwebia/py.typed +0 -0
- leadwebia-0.2.0/src/leadwebia/webhooks.py +27 -0
- leadwebia-0.2.0/tests/test_client.py +335 -0
- leadwebia-0.2.0/tests/test_live.py +77 -0
leadwebia-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LeadWebia
|
|
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.
|
leadwebia-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: leadwebia
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Official LeadWebia API client: find local businesses on Google Maps by niche and city, their emails and website audits, CRM status, exports, reports and signed webhooks.
|
|
5
|
+
Project-URL: Homepage, https://leadwebia.com
|
|
6
|
+
Project-URL: Documentation, https://leadwebia.com/docs/api
|
|
7
|
+
Project-URL: API reference, https://api.leadwebia.com/api/v1/docs
|
|
8
|
+
Project-URL: Free tools, https://leadwebia.com/tools
|
|
9
|
+
Project-URL: Source, https://github.com/leadwebia/leadwebia-sdk
|
|
10
|
+
Project-URL: Issues, https://github.com/leadwebia/leadwebia-sdk/issues
|
|
11
|
+
Author: LeadWebia
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: api client,b2b leads,email finder,google maps leads,lead generation,leadwebia,local business,webhooks,website audit
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
20
|
+
Classifier: Topic :: Office/Business
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# LeadWebia for Python
|
|
27
|
+
|
|
28
|
+
Official Python client for the [LeadWebia API](https://leadwebia.com/docs/api). Find local businesses on Google Maps by niche and city, get their emails, phones and website audit, manage them as leads, and push them to your tools or receive them by webhook.
|
|
29
|
+
|
|
30
|
+
[LeadWebia](https://leadwebia.com) is a lead generation tool for web designers, agencies and anyone who sells to local businesses: it finds businesses with or without a website, their contact details and what their current website is missing. The API does with an API key what you do in the app.
|
|
31
|
+
|
|
32
|
+
- Zero dependencies (standard library only), Python 3.8+, typed.
|
|
33
|
+
- Automatic `Idempotency-Key` on searches, so a retry never charges twice.
|
|
34
|
+
- Retries on `429` (honouring `Retry-After`), `502`, `503` and network errors.
|
|
35
|
+
- Typed errors per `error.code`, cursor iteration over new leads, webhook signature check.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install leadwebia
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Authentication
|
|
44
|
+
|
|
45
|
+
Create an API key in the app: [leadwebia.com/api](https://leadwebia.com/api) (Integrations → API). Pass it to the client or set `LEADWEBIA_API_KEY`.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from leadwebia import LeadWebia
|
|
49
|
+
|
|
50
|
+
client = LeadWebia(api_key="lw_live_...") # or LeadWebia() with LEADWEBIA_API_KEY set
|
|
51
|
+
print(client.me()["credits"])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Keep the key on your server: it spends your account's credits.
|
|
55
|
+
|
|
56
|
+
## Find leads
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from leadwebia import LeadWebia
|
|
60
|
+
|
|
61
|
+
client = LeadWebia()
|
|
62
|
+
|
|
63
|
+
# 1. Pick the area
|
|
64
|
+
area = client.locations("Austin", state="TX")["data"][0]
|
|
65
|
+
|
|
66
|
+
# 2. Start a search: plumbers and roofers without a website, up to 50 businesses
|
|
67
|
+
search = client.searches.create(
|
|
68
|
+
niches=["plumber", "roofing contractor"],
|
|
69
|
+
area_ids=[area["area_id"]],
|
|
70
|
+
max_leads=50,
|
|
71
|
+
only_without_website=True,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# 3. Wait for it and read the leads
|
|
75
|
+
client.searches.wait(search["search_id"])
|
|
76
|
+
page = client.leads.list(search_id=search["search_id"], limit=100)
|
|
77
|
+
for lead in page["data"]:
|
|
78
|
+
print(lead["name"], lead.get("phone"), lead.get("emails"))
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
A search reserves `max_leads` credits and charges 1 per business delivered (with `only_with_email=True`, 1 per business delivered with an email); unused credits return. `client.searches.more(search_id, max_leads=50)` loads more in the same area.
|
|
82
|
+
|
|
83
|
+
## New leads as they arrive
|
|
84
|
+
|
|
85
|
+
`iter_leads` follows the polling cursor. Store the last cursor and pass it next time to get only new leads:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
cursor = load_cursor() or "0" # "0" = everything, "now" = from now on
|
|
89
|
+
for lead in client.iter_leads(since=cursor, on_cursor=save_cursor):
|
|
90
|
+
add_to_crm(lead)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Resources
|
|
94
|
+
|
|
95
|
+
| Group | Methods |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| Account | `me()`, `lead_statuses()` |
|
|
98
|
+
| Locations | `locations(city, country="US", state=None)` |
|
|
99
|
+
| Searches | `searches.create`, `.list`, `.updates(updated_since)`, `.get`, `.runs`, `.more`, `.remaining`, `.wait` |
|
|
100
|
+
| Leads | `leads.list(**filters)`, `.feed(since)`, `.iter(since)`, `.get`, `.set_status`, `.bulk_status`, `.delete`, `.bulk_delete`, `.outreach_message` |
|
|
101
|
+
| Exports | `exports.create(search_id=… or place_ids=…, website="any")` → CSV URL (paid plans) |
|
|
102
|
+
| Integrations | `integrations.list`, `.targets(kind)`, `.send(kind, …)`, `.send_status(task_id)` |
|
|
103
|
+
| Reports | `reports.lookup(name, city)`, `.create(place_id)`, `.get`, `.share`, `.pdf` |
|
|
104
|
+
| Tools | `tools.website_check(url, include_pagespeed=False)`, `tools.emails(url)` |
|
|
105
|
+
| Webhooks | `webhooks.create(url, events)`, `.list`, `.get`, `.update`, `.delete`, `.test`, `.deliveries` |
|
|
106
|
+
|
|
107
|
+
Lead filters: `search_id`, `website` (`any`, `without`, `with`, `social_or_directory`), `status`, `q`, `cms`, `cms_outdated`, `uses_ads`, `has_email`, `sort`, `limit`, `offset`. The full reference, with every field, is the [OpenAPI document](https://api.leadwebia.com/api/v1/docs).
|
|
108
|
+
|
|
109
|
+
## Website tools
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
site = client.tools.website_check("joesplumbing.com", include_pagespeed=True)
|
|
113
|
+
contacts = client.tools.emails("joesplumbing.com")
|
|
114
|
+
print(site["technologies"].get("cms"), site["ssl"].get("days_remaining"), contacts["emails"])
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The same checks power LeadWebia's free [website tools](https://leadwebia.com/tools).
|
|
118
|
+
|
|
119
|
+
## Webhooks
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
hook = client.webhooks.create("https://example.com/leadwebia", ["lead.created", "search.completed"])
|
|
123
|
+
secret = hook["signing_secret"] # shown only once: store it
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Verify each delivery with the raw body (before parsing JSON). Flask example:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from flask import Flask, request, abort
|
|
130
|
+
from leadwebia import verify_signature
|
|
131
|
+
|
|
132
|
+
app = Flask(__name__)
|
|
133
|
+
|
|
134
|
+
@app.post("/leadwebia")
|
|
135
|
+
def leadwebia_webhook():
|
|
136
|
+
if not verify_signature(request.get_data(), request.headers.get("X-LeadWebia-Signature"), SECRET):
|
|
137
|
+
abort(401)
|
|
138
|
+
event = request.get_json()
|
|
139
|
+
if event["type"] == "lead.created":
|
|
140
|
+
add_to_crm(event["data"])
|
|
141
|
+
return "", 204
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Webhooks need a paid plan.
|
|
145
|
+
|
|
146
|
+
## Errors
|
|
147
|
+
|
|
148
|
+
Every API error is a `LeadWebiaError` with `code`, `message`, `status`, `request_id` and `docs_url`, raised as a subclass you can catch:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from leadwebia import InsufficientCreditsError, ConflictError, RateLimitError, LeadWebiaError
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
client.searches.more(search_id, max_leads=100)
|
|
155
|
+
except InsufficientCreditsError as e:
|
|
156
|
+
print("Top up:", e.message)
|
|
157
|
+
except ConflictError as e:
|
|
158
|
+
if e.code == "search_exhausted":
|
|
159
|
+
print("This area is used up, search a new one")
|
|
160
|
+
except RateLimitError as e:
|
|
161
|
+
print("Retry in", e.retry_after, "s")
|
|
162
|
+
except LeadWebiaError as e:
|
|
163
|
+
print(e.code, e.message, e.request_id)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
| Exception | Status | Codes |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| `AuthenticationError` | 401 | `invalid_api_key` |
|
|
169
|
+
| `InsufficientCreditsError` | 402 | `insufficient_credits` |
|
|
170
|
+
| `PermissionDeniedError` | 403 | `paid_plan_required`, `professional_plan_required` |
|
|
171
|
+
| `NotFoundError` | 404 | `not_found`, `search_not_found`, `lead_not_found`, `report_not_found` |
|
|
172
|
+
| `ConflictError` | 409 | `search_exhausted`, `idempotency_conflict`, `report_not_ready`, `integration_not_connected`, … |
|
|
173
|
+
| `ValidationError` | 422 | `validation_error` (`details` lists the fields) |
|
|
174
|
+
| `RateLimitError` | 429 | `rate_limited`, `email_lookup_limit`, `lookup_limit`, `message_limit`, `queue_full` |
|
|
175
|
+
| `ServerError` | 5xx | `upstream_error`, `website_unreadable`, `internal_error` |
|
|
176
|
+
| `APIConnectionError` | — | network error or timeout |
|
|
177
|
+
|
|
178
|
+
Limits: 60 requests/min per key, 120 per account, 10 credit-spending calls/min.
|
|
179
|
+
|
|
180
|
+
## Command line
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
export LEADWEBIA_API_KEY=lw_live_...
|
|
184
|
+
leadwebia me
|
|
185
|
+
leadwebia locations Austin --state TX
|
|
186
|
+
leadwebia website-check example.com --pagespeed
|
|
187
|
+
leadwebia emails example.com
|
|
188
|
+
leadwebia leads --search-id 123
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
pip install -e .
|
|
195
|
+
python -m unittest discover -s tests -v
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The integration tests in `tests/test_live.py` run only with `LEADWEBIA_API_KEY` set (or a git-ignored `sdk/.env.test`); `LEADWEBIA_LIVE_SPEND=1..5` also runs one real search.
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# LeadWebia for Python
|
|
2
|
+
|
|
3
|
+
Official Python client for the [LeadWebia API](https://leadwebia.com/docs/api). Find local businesses on Google Maps by niche and city, get their emails, phones and website audit, manage them as leads, and push them to your tools or receive them by webhook.
|
|
4
|
+
|
|
5
|
+
[LeadWebia](https://leadwebia.com) is a lead generation tool for web designers, agencies and anyone who sells to local businesses: it finds businesses with or without a website, their contact details and what their current website is missing. The API does with an API key what you do in the app.
|
|
6
|
+
|
|
7
|
+
- Zero dependencies (standard library only), Python 3.8+, typed.
|
|
8
|
+
- Automatic `Idempotency-Key` on searches, so a retry never charges twice.
|
|
9
|
+
- Retries on `429` (honouring `Retry-After`), `502`, `503` and network errors.
|
|
10
|
+
- Typed errors per `error.code`, cursor iteration over new leads, webhook signature check.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install leadwebia
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Authentication
|
|
19
|
+
|
|
20
|
+
Create an API key in the app: [leadwebia.com/api](https://leadwebia.com/api) (Integrations → API). Pass it to the client or set `LEADWEBIA_API_KEY`.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from leadwebia import LeadWebia
|
|
24
|
+
|
|
25
|
+
client = LeadWebia(api_key="lw_live_...") # or LeadWebia() with LEADWEBIA_API_KEY set
|
|
26
|
+
print(client.me()["credits"])
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Keep the key on your server: it spends your account's credits.
|
|
30
|
+
|
|
31
|
+
## Find leads
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from leadwebia import LeadWebia
|
|
35
|
+
|
|
36
|
+
client = LeadWebia()
|
|
37
|
+
|
|
38
|
+
# 1. Pick the area
|
|
39
|
+
area = client.locations("Austin", state="TX")["data"][0]
|
|
40
|
+
|
|
41
|
+
# 2. Start a search: plumbers and roofers without a website, up to 50 businesses
|
|
42
|
+
search = client.searches.create(
|
|
43
|
+
niches=["plumber", "roofing contractor"],
|
|
44
|
+
area_ids=[area["area_id"]],
|
|
45
|
+
max_leads=50,
|
|
46
|
+
only_without_website=True,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# 3. Wait for it and read the leads
|
|
50
|
+
client.searches.wait(search["search_id"])
|
|
51
|
+
page = client.leads.list(search_id=search["search_id"], limit=100)
|
|
52
|
+
for lead in page["data"]:
|
|
53
|
+
print(lead["name"], lead.get("phone"), lead.get("emails"))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
A search reserves `max_leads` credits and charges 1 per business delivered (with `only_with_email=True`, 1 per business delivered with an email); unused credits return. `client.searches.more(search_id, max_leads=50)` loads more in the same area.
|
|
57
|
+
|
|
58
|
+
## New leads as they arrive
|
|
59
|
+
|
|
60
|
+
`iter_leads` follows the polling cursor. Store the last cursor and pass it next time to get only new leads:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
cursor = load_cursor() or "0" # "0" = everything, "now" = from now on
|
|
64
|
+
for lead in client.iter_leads(since=cursor, on_cursor=save_cursor):
|
|
65
|
+
add_to_crm(lead)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Resources
|
|
69
|
+
|
|
70
|
+
| Group | Methods |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| Account | `me()`, `lead_statuses()` |
|
|
73
|
+
| Locations | `locations(city, country="US", state=None)` |
|
|
74
|
+
| Searches | `searches.create`, `.list`, `.updates(updated_since)`, `.get`, `.runs`, `.more`, `.remaining`, `.wait` |
|
|
75
|
+
| Leads | `leads.list(**filters)`, `.feed(since)`, `.iter(since)`, `.get`, `.set_status`, `.bulk_status`, `.delete`, `.bulk_delete`, `.outreach_message` |
|
|
76
|
+
| Exports | `exports.create(search_id=… or place_ids=…, website="any")` → CSV URL (paid plans) |
|
|
77
|
+
| Integrations | `integrations.list`, `.targets(kind)`, `.send(kind, …)`, `.send_status(task_id)` |
|
|
78
|
+
| Reports | `reports.lookup(name, city)`, `.create(place_id)`, `.get`, `.share`, `.pdf` |
|
|
79
|
+
| Tools | `tools.website_check(url, include_pagespeed=False)`, `tools.emails(url)` |
|
|
80
|
+
| Webhooks | `webhooks.create(url, events)`, `.list`, `.get`, `.update`, `.delete`, `.test`, `.deliveries` |
|
|
81
|
+
|
|
82
|
+
Lead filters: `search_id`, `website` (`any`, `without`, `with`, `social_or_directory`), `status`, `q`, `cms`, `cms_outdated`, `uses_ads`, `has_email`, `sort`, `limit`, `offset`. The full reference, with every field, is the [OpenAPI document](https://api.leadwebia.com/api/v1/docs).
|
|
83
|
+
|
|
84
|
+
## Website tools
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
site = client.tools.website_check("joesplumbing.com", include_pagespeed=True)
|
|
88
|
+
contacts = client.tools.emails("joesplumbing.com")
|
|
89
|
+
print(site["technologies"].get("cms"), site["ssl"].get("days_remaining"), contacts["emails"])
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The same checks power LeadWebia's free [website tools](https://leadwebia.com/tools).
|
|
93
|
+
|
|
94
|
+
## Webhooks
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
hook = client.webhooks.create("https://example.com/leadwebia", ["lead.created", "search.completed"])
|
|
98
|
+
secret = hook["signing_secret"] # shown only once: store it
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Verify each delivery with the raw body (before parsing JSON). Flask example:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from flask import Flask, request, abort
|
|
105
|
+
from leadwebia import verify_signature
|
|
106
|
+
|
|
107
|
+
app = Flask(__name__)
|
|
108
|
+
|
|
109
|
+
@app.post("/leadwebia")
|
|
110
|
+
def leadwebia_webhook():
|
|
111
|
+
if not verify_signature(request.get_data(), request.headers.get("X-LeadWebia-Signature"), SECRET):
|
|
112
|
+
abort(401)
|
|
113
|
+
event = request.get_json()
|
|
114
|
+
if event["type"] == "lead.created":
|
|
115
|
+
add_to_crm(event["data"])
|
|
116
|
+
return "", 204
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Webhooks need a paid plan.
|
|
120
|
+
|
|
121
|
+
## Errors
|
|
122
|
+
|
|
123
|
+
Every API error is a `LeadWebiaError` with `code`, `message`, `status`, `request_id` and `docs_url`, raised as a subclass you can catch:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from leadwebia import InsufficientCreditsError, ConflictError, RateLimitError, LeadWebiaError
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
client.searches.more(search_id, max_leads=100)
|
|
130
|
+
except InsufficientCreditsError as e:
|
|
131
|
+
print("Top up:", e.message)
|
|
132
|
+
except ConflictError as e:
|
|
133
|
+
if e.code == "search_exhausted":
|
|
134
|
+
print("This area is used up, search a new one")
|
|
135
|
+
except RateLimitError as e:
|
|
136
|
+
print("Retry in", e.retry_after, "s")
|
|
137
|
+
except LeadWebiaError as e:
|
|
138
|
+
print(e.code, e.message, e.request_id)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
| Exception | Status | Codes |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| `AuthenticationError` | 401 | `invalid_api_key` |
|
|
144
|
+
| `InsufficientCreditsError` | 402 | `insufficient_credits` |
|
|
145
|
+
| `PermissionDeniedError` | 403 | `paid_plan_required`, `professional_plan_required` |
|
|
146
|
+
| `NotFoundError` | 404 | `not_found`, `search_not_found`, `lead_not_found`, `report_not_found` |
|
|
147
|
+
| `ConflictError` | 409 | `search_exhausted`, `idempotency_conflict`, `report_not_ready`, `integration_not_connected`, … |
|
|
148
|
+
| `ValidationError` | 422 | `validation_error` (`details` lists the fields) |
|
|
149
|
+
| `RateLimitError` | 429 | `rate_limited`, `email_lookup_limit`, `lookup_limit`, `message_limit`, `queue_full` |
|
|
150
|
+
| `ServerError` | 5xx | `upstream_error`, `website_unreadable`, `internal_error` |
|
|
151
|
+
| `APIConnectionError` | — | network error or timeout |
|
|
152
|
+
|
|
153
|
+
Limits: 60 requests/min per key, 120 per account, 10 credit-spending calls/min.
|
|
154
|
+
|
|
155
|
+
## Command line
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
export LEADWEBIA_API_KEY=lw_live_...
|
|
159
|
+
leadwebia me
|
|
160
|
+
leadwebia locations Austin --state TX
|
|
161
|
+
leadwebia website-check example.com --pagespeed
|
|
162
|
+
leadwebia emails example.com
|
|
163
|
+
leadwebia leads --search-id 123
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pip install -e .
|
|
170
|
+
python -m unittest discover -s tests -v
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The integration tests in `tests/test_live.py` run only with `LEADWEBIA_API_KEY` set (or a git-ignored `sdk/.env.test`); `LEADWEBIA_LIVE_SPEND=1..5` also runs one real search.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "leadwebia"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Official LeadWebia API client: find local businesses on Google Maps by niche and city, their emails and website audits, CRM status, exports, reports and signed webhooks."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
authors = [{ name = "LeadWebia" }]
|
|
14
|
+
keywords = ["leadwebia", "lead generation", "google maps leads", "local business", "b2b leads", "email finder", "website audit", "api client", "webhooks"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
21
|
+
"Topic :: Office/Business",
|
|
22
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = []
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://leadwebia.com"
|
|
29
|
+
Documentation = "https://leadwebia.com/docs/api"
|
|
30
|
+
"API reference" = "https://api.leadwebia.com/api/v1/docs"
|
|
31
|
+
"Free tools" = "https://leadwebia.com/tools"
|
|
32
|
+
Source = "https://github.com/leadwebia/leadwebia-sdk"
|
|
33
|
+
Issues = "https://github.com/leadwebia/leadwebia-sdk/issues"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
leadwebia = "leadwebia.__main__:main"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.version]
|
|
39
|
+
path = "src/leadwebia/_version.py"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/leadwebia"]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.sdist]
|
|
45
|
+
include = ["src/leadwebia", "tests", "README.md", "LICENSE"]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""LeadWebia — find local businesses and their contacts from Python.
|
|
2
|
+
|
|
3
|
+
Official client for the LeadWebia API v1: Google Maps lead searches by niche
|
|
4
|
+
and city, leads with emails and website audits, CRM status, CSV exports,
|
|
5
|
+
prospect reports, website tools and signed webhooks.
|
|
6
|
+
Docs: https://leadwebia.com/docs/api
|
|
7
|
+
"""
|
|
8
|
+
from ._version import __version__
|
|
9
|
+
from .client import DEFAULT_BASE_URL, LeadWebia
|
|
10
|
+
from .errors import (
|
|
11
|
+
APIConnectionError,
|
|
12
|
+
AuthenticationError,
|
|
13
|
+
ConflictError,
|
|
14
|
+
InsufficientCreditsError,
|
|
15
|
+
LeadWebiaError,
|
|
16
|
+
NotFoundError,
|
|
17
|
+
PermissionDeniedError,
|
|
18
|
+
RateLimitError,
|
|
19
|
+
ServerError,
|
|
20
|
+
ValidationError,
|
|
21
|
+
)
|
|
22
|
+
from .webhooks import SIGNATURE_HEADER, compute_signature, verify_signature
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"LeadWebia",
|
|
26
|
+
"DEFAULT_BASE_URL",
|
|
27
|
+
"verify_signature",
|
|
28
|
+
"compute_signature",
|
|
29
|
+
"SIGNATURE_HEADER",
|
|
30
|
+
"LeadWebiaError",
|
|
31
|
+
"APIConnectionError",
|
|
32
|
+
"AuthenticationError",
|
|
33
|
+
"InsufficientCreditsError",
|
|
34
|
+
"PermissionDeniedError",
|
|
35
|
+
"NotFoundError",
|
|
36
|
+
"ConflictError",
|
|
37
|
+
"ValidationError",
|
|
38
|
+
"RateLimitError",
|
|
39
|
+
"ServerError",
|
|
40
|
+
"__version__",
|
|
41
|
+
]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Command line (reads the key from LEADWEBIA_API_KEY), prints JSON:
|
|
2
|
+
|
|
3
|
+
leadwebia me
|
|
4
|
+
leadwebia locations "Austin" --state TX
|
|
5
|
+
leadwebia website-check example.com [--pagespeed]
|
|
6
|
+
leadwebia emails example.com
|
|
7
|
+
leadwebia leads [--search-id 123]
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
import sys
|
|
14
|
+
from typing import Any, List, Optional
|
|
15
|
+
|
|
16
|
+
from . import __version__
|
|
17
|
+
from .client import LeadWebia
|
|
18
|
+
from .errors import LeadWebiaError
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _parser() -> argparse.ArgumentParser:
|
|
22
|
+
parser = argparse.ArgumentParser(prog="leadwebia", description="LeadWebia API v1 from the command line.")
|
|
23
|
+
parser.add_argument("--version", action="version", version=f"leadwebia {__version__}")
|
|
24
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
25
|
+
sub.add_parser("me", help="plan and credits of your key's account")
|
|
26
|
+
p = sub.add_parser("locations", help="areas (area_id) of a city")
|
|
27
|
+
p.add_argument("city")
|
|
28
|
+
p.add_argument("--country", default="US")
|
|
29
|
+
p.add_argument("--state")
|
|
30
|
+
p = sub.add_parser("website-check", help="CMS, tech stack, SSL (and PageSpeed) of a website")
|
|
31
|
+
p.add_argument("url")
|
|
32
|
+
p.add_argument("--pagespeed", action="store_true")
|
|
33
|
+
p = sub.add_parser("emails", help="emails, phones and socials published on a website")
|
|
34
|
+
p.add_argument("url")
|
|
35
|
+
p = sub.add_parser("leads", help="your latest leads")
|
|
36
|
+
p.add_argument("--search-id", type=int)
|
|
37
|
+
p.add_argument("--limit", type=int, default=25)
|
|
38
|
+
return parser
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _run(client: LeadWebia, args: argparse.Namespace) -> Any:
|
|
42
|
+
if args.command == "me":
|
|
43
|
+
return client.me()
|
|
44
|
+
if args.command == "locations":
|
|
45
|
+
return client.locations(args.city, country=args.country, state=args.state)
|
|
46
|
+
if args.command == "website-check":
|
|
47
|
+
return client.tools.website_check(args.url, include_pagespeed=args.pagespeed)
|
|
48
|
+
if args.command == "emails":
|
|
49
|
+
return client.tools.emails(args.url)
|
|
50
|
+
return client.leads.list(search_id=args.search_id, limit=args.limit)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def main(argv: Optional[List[str]] = None, client: Optional[LeadWebia] = None) -> int:
|
|
54
|
+
args = _parser().parse_args(argv)
|
|
55
|
+
try:
|
|
56
|
+
result = _run(client or LeadWebia(), args)
|
|
57
|
+
except ValueError as e:
|
|
58
|
+
print(f"error: {e}", file=sys.stderr)
|
|
59
|
+
return 2
|
|
60
|
+
except LeadWebiaError as e:
|
|
61
|
+
print(f"error: {e.code or e.status}: {e}", file=sys.stderr)
|
|
62
|
+
return 1
|
|
63
|
+
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__": # pragma: no cover
|
|
68
|
+
sys.exit(main())
|