searlo 0.2.0__py3-none-any.whl

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.
searlo/__init__.py ADDED
@@ -0,0 +1,28 @@
1
+ from .client import Searlo
2
+ from .exceptions import (
3
+ SearloAPIError,
4
+ SearloAuthError,
5
+ SearloError,
6
+ SearloInsufficientCreditsError,
7
+ SearloRateLimitError,
8
+ )
9
+
10
+ __version__ = "0.2.0"
11
+
12
+ __all__ = [
13
+ "Searlo",
14
+ "SearloError",
15
+ "SearloAPIError",
16
+ "SearloAuthError",
17
+ "SearloInsufficientCreditsError",
18
+ "SearloRateLimitError",
19
+ ]
20
+
21
+
22
+ def __getattr__(name):
23
+ # Lazy-load SearloSearchTool so `import searlo` never requires langchain.
24
+ if name == "SearloSearchTool":
25
+ from .langchain_tool import SearloSearchTool
26
+
27
+ return SearloSearchTool
28
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
searlo/client.py ADDED
@@ -0,0 +1,416 @@
1
+ import os
2
+ from typing import Any, Dict, List, Optional
3
+
4
+ import requests
5
+
6
+ from .exceptions import (
7
+ SearloAPIError,
8
+ SearloAuthError,
9
+ SearloError,
10
+ SearloInsufficientCreditsError,
11
+ SearloRateLimitError,
12
+ )
13
+
14
+ DEFAULT_BASE_URL = "https://api.searlo.tech/api/v1"
15
+
16
+
17
+ class Searlo:
18
+ """Client for the Searlo API.
19
+
20
+ Example:
21
+ >>> client = Searlo(api_key="sk_...")
22
+ >>> results = client.search("best serp api")
23
+ >>> for item in results["organic"]:
24
+ ... print(item["title"], item["link"])
25
+ """
26
+
27
+ def __init__(
28
+ self,
29
+ api_key: Optional[str] = None,
30
+ base_url: str = DEFAULT_BASE_URL,
31
+ timeout: float = 15.0,
32
+ session: Optional[requests.Session] = None,
33
+ ):
34
+ self.api_key = api_key or os.environ.get("SEARLO_API_KEY")
35
+ if not self.api_key:
36
+ raise SearloError(
37
+ "No API key provided. Pass api_key= or set the SEARLO_API_KEY "
38
+ "environment variable. Get a free key with 3,000 credits at "
39
+ "https://dashboard.searlo.tech"
40
+ )
41
+ self.base_url = base_url.rstrip("/")
42
+ self.timeout = timeout
43
+ self._session = session or requests.Session()
44
+
45
+ # ── Internal request helper ──────────────────────────────────
46
+
47
+ def _request(
48
+ self, method: str, path: str, timeout: Optional[float] = None, **kwargs
49
+ ) -> Dict[str, Any]:
50
+ url = f"{self.base_url}{path}"
51
+ headers = {"x-api-key": self.api_key, "Accept": "application/json"}
52
+ try:
53
+ resp = self._session.request(
54
+ method,
55
+ url,
56
+ headers=headers,
57
+ # Per-call override. The default suits a search; a scrape with
58
+ # JS rendering or a crawl start legitimately takes far longer,
59
+ # and inheriting the search timeout would abort work the caller
60
+ # has already been charged for.
61
+ timeout=timeout or self.timeout,
62
+ **kwargs,
63
+ )
64
+ except requests.RequestException as exc:
65
+ raise SearloError(f"Network error calling Searlo API: {exc}") from exc
66
+
67
+ if resp.status_code == 401:
68
+ raise SearloAuthError(
69
+ "Invalid or missing API key.", status_code=401
70
+ )
71
+ if resp.status_code == 402:
72
+ body = self._safe_json(resp)
73
+ raise SearloInsufficientCreditsError(
74
+ body.get("message", "Insufficient credits."), status_code=402
75
+ )
76
+ if resp.status_code == 429:
77
+ raise SearloRateLimitError(
78
+ "Rate limit exceeded. Slow down or upgrade your plan.",
79
+ status_code=429,
80
+ retryable=True,
81
+ )
82
+ if resp.status_code >= 400:
83
+ body = self._safe_json(resp)
84
+ raise SearloAPIError(
85
+ body.get("message", f"Searlo API error ({resp.status_code})"),
86
+ status_code=resp.status_code,
87
+ retryable=bool(body.get("retryable")),
88
+ error_code=body.get("errorCode"),
89
+ )
90
+
91
+ return self._safe_json(resp)
92
+
93
+ @staticmethod
94
+ def _safe_json(resp: requests.Response) -> Dict[str, Any]:
95
+ try:
96
+ return resp.json()
97
+ except ValueError:
98
+ return {"message": resp.text}
99
+
100
+ @staticmethod
101
+ def _camel(opts: Dict[str, Any]) -> Dict[str, Any]:
102
+ """snake_case kwargs -> the camelCase keys the API documents.
103
+
104
+ Python callers should write ``only_main_content=True``, not
105
+ ``onlyMainContent``. Without this the option is silently dropped by the
106
+ API's validation and the caller never learns why their setting did
107
+ nothing.
108
+ """
109
+ out: Dict[str, Any] = {}
110
+ for key, value in opts.items():
111
+ if value is None:
112
+ continue
113
+ head, *rest = key.split("_")
114
+ out[head + "".join(part.title() for part in rest)] = value
115
+ return out
116
+
117
+ @staticmethod
118
+ def _clean(params: Dict[str, Any]) -> Dict[str, Any]:
119
+ return {k: v for k, v in params.items() if v is not None}
120
+
121
+ # ── Search endpoints ──────────────────────────────────────────
122
+
123
+ def search(
124
+ self,
125
+ query: str,
126
+ num: int = 10,
127
+ page: int = 1,
128
+ safe: Optional[str] = None,
129
+ gl: Optional[str] = None,
130
+ hl: Optional[str] = None,
131
+ engine: Optional[str] = None,
132
+ format: str = "enhanced",
133
+ ) -> Dict[str, Any]:
134
+ """Web search — organic results, knowledge panels, featured snippets."""
135
+ return self._request(
136
+ "GET",
137
+ "/search/web",
138
+ params=self._clean(
139
+ {
140
+ "q": query,
141
+ "limit": num,
142
+ "page": page,
143
+ "safe": safe,
144
+ "gl": gl,
145
+ "hl": hl,
146
+ "engine": engine,
147
+ "format": format,
148
+ }
149
+ ),
150
+ )
151
+
152
+ def images(
153
+ self,
154
+ query: str,
155
+ num: int = 10,
156
+ page: int = 1,
157
+ size: Optional[str] = None,
158
+ img_type: Optional[str] = None,
159
+ img_color_type: Optional[str] = None,
160
+ gl: Optional[str] = None,
161
+ hl: Optional[str] = None,
162
+ ) -> Dict[str, Any]:
163
+ """Image search results."""
164
+ return self._request(
165
+ "GET",
166
+ "/search/images",
167
+ params=self._clean(
168
+ {
169
+ "q": query,
170
+ "limit": num,
171
+ "page": page,
172
+ "size": size,
173
+ "imgType": img_type,
174
+ "imgColorType": img_color_type,
175
+ "gl": gl,
176
+ "hl": hl,
177
+ }
178
+ ),
179
+ )
180
+
181
+ def news(
182
+ self,
183
+ query: str,
184
+ num: int = 10,
185
+ page: int = 1,
186
+ date_restrict: Optional[str] = None,
187
+ gl: Optional[str] = None,
188
+ hl: Optional[str] = None,
189
+ ) -> Dict[str, Any]:
190
+ """News search results."""
191
+ return self._request(
192
+ "GET",
193
+ "/search/news",
194
+ params=self._clean(
195
+ {
196
+ "q": query,
197
+ "limit": num,
198
+ "page": page,
199
+ "dateRestrict": date_restrict,
200
+ "gl": gl,
201
+ "hl": hl,
202
+ }
203
+ ),
204
+ )
205
+
206
+ def videos(
207
+ self,
208
+ query: str,
209
+ num: int = 10,
210
+ page: int = 1,
211
+ safe: Optional[str] = None,
212
+ gl: Optional[str] = None,
213
+ hl: Optional[str] = None,
214
+ ) -> Dict[str, Any]:
215
+ """Video search results."""
216
+ return self._request(
217
+ "GET",
218
+ "/search/videos",
219
+ params=self._clean(
220
+ {"q": query, "limit": num, "page": page, "safe": safe, "gl": gl, "hl": hl}
221
+ ),
222
+ )
223
+
224
+ def site_search(
225
+ self, query: str, site: str, num: int = 10, page: int = 1
226
+ ) -> Dict[str, Any]:
227
+ """Search results restricted to a single site (site: operator)."""
228
+ return self._request(
229
+ "GET",
230
+ "/search/site",
231
+ params=self._clean({"q": query, "site": site, "limit": num, "page": page}),
232
+ )
233
+
234
+ def advanced(
235
+ self,
236
+ query: str,
237
+ num: int = 10,
238
+ date_range: Optional[str] = None,
239
+ file_type: Optional[str] = None,
240
+ exact_terms: Optional[str] = None,
241
+ exclude_terms: Optional[str] = None,
242
+ site: Optional[str] = None,
243
+ ) -> Dict[str, Any]:
244
+ """Advanced search with dork-style operators (file type, exact terms, etc)."""
245
+ return self._request(
246
+ "GET",
247
+ "/search/advanced",
248
+ params=self._clean(
249
+ {
250
+ "q": query,
251
+ "limit": num,
252
+ "dateRange": date_range,
253
+ "fileType": file_type,
254
+ "exactTerms": exact_terms,
255
+ "excludeTerms": exclude_terms,
256
+ "site": site,
257
+ }
258
+ ),
259
+ )
260
+
261
+ def suggestions(self, query: str, limit: int = 10, hl: str = "en") -> Dict[str, Any]:
262
+ """Autocomplete suggestions for a partial query."""
263
+ return self._request(
264
+ "GET",
265
+ "/search/suggestions",
266
+ params={"q": query, "limit": limit, "hl": hl},
267
+ )
268
+
269
+ def trending(self, region: str = "US") -> Dict[str, Any]:
270
+ """Currently trending searches for a region. Does not consume credits."""
271
+ return self._request("GET", "/search/trending", params={"region": region})
272
+
273
+ def batch(self, queries: List[str]) -> Dict[str, Any]:
274
+ """Run up to 10 plain-text queries in a single request. 1 credit per query."""
275
+ if not queries or len(queries) > 10:
276
+ raise SearloError("batch() accepts 1-10 queries per call.")
277
+ return self._request("POST", "/search/batch", json={"queries": queries})
278
+
279
+ def shopping(
280
+ self, query: str, num: int = 20, gl: Optional[str] = None, hl: Optional[str] = None
281
+ ) -> Dict[str, Any]:
282
+ """Shopping results: product, price, merchant, rating and a link to buy."""
283
+ return self._request(
284
+ "GET",
285
+ "/search/shopping",
286
+ params=self._clean({"q": query, "limit": num, "gl": gl, "hl": hl}),
287
+ )
288
+
289
+ # ── Web data ──────────────────────────────────────────────────
290
+ # These run a real fetch against the open web, so they carry their own
291
+ # timeouts rather than the search default.
292
+
293
+ def scrape(self, url: str, **opts) -> Dict[str, Any]:
294
+ """Scrape one URL into the formats you ask for.
295
+
296
+ ``max_age`` is the freshness dial: 0 always fetches live, N serves a
297
+ cached answer only if it is younger than N seconds. A fetch your
298
+ freshness request forces costs double - a cache hit costs us nothing,
299
+ an origin fetch costs proxy egress and an exit identity.
300
+ """
301
+ return self._request("POST", "/scrape", timeout=90.0, json={"url": url, **self._camel(opts)})
302
+
303
+ def map(self, url: str, **opts) -> Dict[str, Any]:
304
+ """Discover a site's URLs without fetching their content."""
305
+ return self._request("POST", "/map", timeout=90.0, json={"url": url, **self._camel(opts)})
306
+
307
+ def extract(self, urls: List[str], schema: Dict[str, str], **opts) -> Dict[str, Any]:
308
+ """URLs plus a field schema, out comes structured data. Billed per URL."""
309
+ return self._request(
310
+ "POST", "/extract", timeout=120.0,
311
+ json={"urls": urls, "schema": schema, **self._camel(opts)},
312
+ )
313
+
314
+ def search_and_scrape(self, query: str, **opts) -> Dict[str, Any]:
315
+ """Search, then scrape the top results, in one call."""
316
+ return self._request(
317
+ "POST", "/search-and-scrape", timeout=120.0,
318
+ json={"q": query, **self._camel(opts)},
319
+ )
320
+
321
+ def screenshot(self, url: str, **opts) -> Dict[str, Any]:
322
+ """Rendered screenshot of a page."""
323
+ return self._request("POST", "/screenshot", timeout=90.0, json={"url": url, **self._camel(opts)})
324
+
325
+ def pdf(self, url: str, **opts) -> Dict[str, Any]:
326
+ """Rendered PDF of a page."""
327
+ return self._request("POST", "/pdf", timeout=90.0, json={"url": url, **self._camel(opts)})
328
+
329
+ def batch_scrape(self, urls: List[str], **opts) -> Dict[str, Any]:
330
+ """Scrape many URLs as one job. Returns immediately with a job id.
331
+
332
+ URLs are de-duplicated before queueing, so the same page written two
333
+ ways is one fetch and one credit - compare ``submitted`` with
334
+ ``urlCount`` in the response.
335
+ """
336
+ return self._request(
337
+ "POST", "/scrape/batch", timeout=60.0, json={"urls": urls, **self._camel(opts)}
338
+ )
339
+
340
+ def crawl(self, url: str, **opts) -> Dict[str, Any]:
341
+ """Start a crawl. Returns a job id; poll ``crawl_status`` or use a webhook."""
342
+ return self._request("POST", "/crawl", timeout=60.0, json={"url": url, **self._camel(opts)})
343
+
344
+ def crawl_status(self, job_id: str) -> Dict[str, Any]:
345
+ """Status and progress of a crawl or batch job."""
346
+ return self._request("GET", f"/crawl/{job_id}")
347
+
348
+ def crawl_results(
349
+ self, job_id: str, limit: int = 50, cursor: Optional[str] = None,
350
+ status: Optional[str] = None,
351
+ ) -> Dict[str, Any]:
352
+ """Cursor-paginated results of a crawl or batch job."""
353
+ return self._request(
354
+ "GET", f"/crawl/{job_id}/results",
355
+ params=self._clean({"limit": limit, "cursor": cursor, "status": status}),
356
+ )
357
+
358
+ def cancel_crawl(self, job_id: str) -> Dict[str, Any]:
359
+ """Cancel a running job. Pages already fetched are kept and stay billed."""
360
+ return self._request("DELETE", f"/crawl/{job_id}")
361
+
362
+ def crawls(self, limit: int = 20, status: Optional[str] = None) -> Dict[str, Any]:
363
+ """List this account's crawl and batch jobs."""
364
+ return self._request("GET", "/crawl", params=self._clean({"limit": limit, "status": status}))
365
+
366
+ # ── AI answers ────────────────────────────────────────────────
367
+
368
+ def ai(self, query: str, engine: Optional[str] = None, **opts) -> Dict[str, Any]:
369
+ """Ask an AI answer engine.
370
+
371
+ The answer comes back with the sources it cited (``citations``) and the
372
+ unique cited domains (``sources``). The price depends on the engine;
373
+ ``capabilities()`` lists them. Omit ``engine`` to use the API default.
374
+ """
375
+ params = self._clean({"q": query, "engine": engine, **opts})
376
+ return self._request("GET", "/search/ai", timeout=120.0, params=params)
377
+
378
+ # ── SERP and verticals ────────────────────────────────────────
379
+
380
+ def serp(self, query: str, **opts) -> Dict[str, Any]:
381
+ """The full results page: organic results plus the AI overview, ads,
382
+ related questions and knowledge panel."""
383
+ return self._request("GET", "/search/serp", timeout=60.0, params=self._clean({"q": query, **opts}))
384
+
385
+ def maps(self, query: str, **opts) -> Dict[str, Any]:
386
+ """Maps and local results: places with rating, address, phone and hours."""
387
+ return self._request("GET", "/search/maps", timeout=60.0, params=self._clean({"q": query, **opts}))
388
+
389
+ def scholar(self, query: str, **opts) -> Dict[str, Any]:
390
+ """Scholarly articles: authors, venue, year and citation counts."""
391
+ return self._request("GET", "/search/scholar", timeout=60.0, params=self._clean({"q": query, **opts}))
392
+
393
+ def patents(self, query: str, **opts) -> Dict[str, Any]:
394
+ """Patent search."""
395
+ return self._request("GET", "/search/patents", timeout=60.0, params=self._clean({"q": query, **opts}))
396
+
397
+ # ── Email ─────────────────────────────────────────────────────
398
+
399
+ def verify_email(self, email: str) -> Dict[str, Any]:
400
+ """Verify one mailbox by real SMTP probe.
401
+
402
+ ``accept_all`` means the server answers for every address, so the
403
+ mailbox itself is unconfirmed. That is distinct from ``unknown`` with
404
+ ``details.rcptUnreliable``, which means the RCPT stage proved nothing.
405
+ """
406
+ return self._request("POST", "/email-verifier/verify", timeout=60.0, json={"email": email})
407
+
408
+ def capabilities(self) -> Dict[str, Any]:
409
+ """What this deployment can currently serve, and at what price."""
410
+ return self._request("GET", "/search/capabilities")
411
+
412
+ # ── Account ───────────────────────────────────────────────────
413
+
414
+ def balance(self) -> Dict[str, Any]:
415
+ """Current credit balance for this API key's account."""
416
+ return self._request("GET", "/credit/balance")
searlo/exceptions.py ADDED
@@ -0,0 +1,24 @@
1
+ class SearloError(Exception):
2
+ """Base exception for all Searlo SDK errors."""
3
+
4
+
5
+ class SearloAPIError(SearloError):
6
+ """The API responded with an error (4xx/5xx)."""
7
+
8
+ def __init__(self, message, status_code=None, retryable=False, error_code=None):
9
+ super().__init__(message)
10
+ self.status_code = status_code
11
+ self.retryable = retryable
12
+ self.error_code = error_code
13
+
14
+
15
+ class SearloAuthError(SearloAPIError):
16
+ """Missing or invalid API key (401)."""
17
+
18
+
19
+ class SearloInsufficientCreditsError(SearloAPIError):
20
+ """Account balance too low to complete the request (402)."""
21
+
22
+
23
+ class SearloRateLimitError(SearloAPIError):
24
+ """Rate limit exceeded for this API key (429)."""
@@ -0,0 +1,67 @@
1
+ """Optional LangChain tool wrapper. Requires `pip install searlo[langchain]`."""
2
+
3
+ from typing import Optional, Type
4
+
5
+ from .client import Searlo
6
+
7
+
8
+ def _get_base_classes():
9
+ try:
10
+ from langchain_core.tools import BaseTool
11
+ from pydantic import BaseModel, Field
12
+ except ImportError as exc: # pragma: no cover
13
+ raise ImportError(
14
+ "SearloSearchTool requires langchain-core. Install with: "
15
+ "pip install searlo[langchain]"
16
+ ) from exc
17
+ return BaseTool, BaseModel, Field
18
+
19
+
20
+ class SearloSearchInput:
21
+ """Lazily built to avoid a hard pydantic/langchain import at module load."""
22
+
23
+
24
+ def _build_tool_class() -> Type:
25
+ BaseTool, BaseModel, Field = _get_base_classes()
26
+
27
+ class _SearloSearchInput(BaseModel):
28
+ query: str = Field(description="The web search query.")
29
+
30
+ class SearloSearchTool(BaseTool):
31
+ """LangChain tool that runs a live web search through Searlo."""
32
+
33
+ name: str = "searlo_search"
34
+ description: str = (
35
+ "Search the web for current, real-world information. Input should be "
36
+ "a search query. Returns the top results with title, link and snippet."
37
+ )
38
+ args_schema: Type[BaseModel] = _SearloSearchInput
39
+ client: Optional[Searlo] = None
40
+
41
+ def __init__(self, api_key: Optional[str] = None, **kwargs):
42
+ super().__init__(**kwargs)
43
+ self.client = Searlo(api_key=api_key)
44
+
45
+ def _run(self, query: str) -> str:
46
+ results = self.client.search(query, num=5)
47
+ organic = results.get("organic", [])
48
+ if not organic:
49
+ return "No results found."
50
+ lines = []
51
+ for item in organic[:5]:
52
+ lines.append(
53
+ f"{item.get('title', '')}\n{item.get('link', '')}\n"
54
+ f"{item.get('snippet', '')}"
55
+ )
56
+ return "\n\n".join(lines)
57
+
58
+ async def _arun(self, query: str) -> str:
59
+ return self._run(query)
60
+
61
+ return SearloSearchTool
62
+
63
+
64
+ def SearloSearchTool(api_key: Optional[str] = None, **kwargs): # noqa: N802
65
+ """Factory returning a LangChain-compatible Searlo search tool instance."""
66
+ cls = _build_tool_class()
67
+ return cls(api_key=api_key, **kwargs)
searlo/py.typed ADDED
File without changes
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: searlo
3
+ Version: 0.2.0
4
+ Summary: Official Python client for the Searlo API — search, web data, AI answers and email verification
5
+ Author-email: Searlo <hello@searlo.tech>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://searlo.tech
8
+ Project-URL: Documentation, https://searlo.tech/docs
9
+ Project-URL: Source, https://github.com/eCodeVoyager/searlo-python
10
+ Project-URL: Issues, https://github.com/eCodeVoyager/searlo-python/issues
11
+ Project-URL: Changelog, https://github.com/eCodeVoyager/searlo-python/blob/main/CHANGELOG.md
12
+ Keywords: searlo,search-api,serp,serp-api,web-search,news-search,maps,shopping,web-scraping,crawler,ai-answers,email-verification,langchain,ai-agents,llm,mcp
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.9
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: Topic :: Internet :: WWW/HTTP :: Indexing/Search
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: requests>=2.28
31
+ Provides-Extra: langchain
32
+ Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0; extra == "dev"
35
+ Requires-Dist: responses>=0.23; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # searlo
39
+
40
+ Official Python client for the [Searlo](https://searlo.tech) API: live search
41
+ results as clean JSON. Web, news, maps, shopping, full results pages, AI
42
+ answers, web data and email verification, with one API key and one credit pool.
43
+
44
+ ## Quick start
45
+
46
+ ```bash
47
+ pip install searlo
48
+ ```
49
+
50
+ ```python
51
+ from searlo import Searlo
52
+ searlo = Searlo(api_key="sk_...") # or set SEARLO_API_KEY
53
+ print(searlo.search("best crm for startups")["organic"])
54
+ ```
55
+
56
+ Get a free API key with 3,000 credits (no card required) at
57
+ [dashboard.searlo.tech](https://dashboard.searlo.tech).
58
+
59
+ ## Working with results
60
+
61
+ ```python
62
+ from searlo import Searlo
63
+
64
+ searlo = Searlo() # reads SEARLO_API_KEY
65
+
66
+ results = searlo.search("best crm for startups", gl="us", num=10)
67
+ for item in results["organic"]:
68
+ print(item["position"], item["title"], item["link"])
69
+ ```
70
+
71
+ ## Methods
72
+
73
+ ### Search
74
+
75
+ | Method | Endpoint | Notes |
76
+ |---|---|---|
77
+ | `search(query, **opts)` | `/search/web` | Organic results, knowledge panels, snippets |
78
+ | `images(query, **opts)` | `/search/images` | Image search |
79
+ | `news(query, **opts)` | `/search/news` | News search |
80
+ | `videos(query, **opts)` | `/search/videos` | Video search |
81
+ | `site_search(query, site, **opts)` | `/search/site` | `site:` operator |
82
+ | `advanced(query, **opts)` | `/search/advanced` | File type, exact/exclude terms |
83
+ | `suggestions(query, **opts)` | `/search/suggestions` | Autocomplete |
84
+ | `trending(region)` | `/search/trending` | Free, no credits charged |
85
+ | `batch(queries)` | `/search/batch` | Up to 10 queries per call |
86
+ | `shopping(query, **opts)` | `/search/shopping` | Products, prices, merchants |
87
+ | `serp(query, **opts)` | `/search/serp` | Full results page: AI overview, ads, related questions, knowledge panel |
88
+ | `maps(query, **opts)` | `/search/maps` | Maps and local results |
89
+ | `scholar(query, **opts)` | `/search/scholar` | Scholarly articles and citations |
90
+ | `patents(query, **opts)` | `/search/patents` | Patents |
91
+
92
+ ### Web data
93
+
94
+ | Method | Endpoint | Notes |
95
+ |---|---|---|
96
+ | `scrape(url, **opts)` | `/scrape` | One URL as markdown, html, links, tables, JSON-LD |
97
+ | `map(url, **opts)` | `/map` | Every URL a site publishes |
98
+ | `extract(urls, schema, **opts)` | `/extract` | URLs + field schema → structured data |
99
+ | `search_and_scrape(query, **opts)` | `/search-and-scrape` | Search, then fetch the top results |
100
+ | `batch_scrape(urls, **opts)` | `/scrape/batch` | Up to 1000 URLs as one job |
101
+ | `crawl(url, **opts)` | `/crawl` | Start a crawl job |
102
+ | `crawl_status(job_id)` | `/crawl/:id` | Job status and progress |
103
+ | `crawl_results(job_id, ...)` | `/crawl/:id/results` | Cursor-paginated results |
104
+ | `cancel_crawl(job_id)` | `/crawl/:id` | Cancel; fetched pages are kept |
105
+ | `crawls(...)` | `/crawl` | List your jobs |
106
+ | `screenshot(url, **opts)` | `/screenshot` | Rendered screenshot |
107
+ | `pdf(url, **opts)` | `/pdf` | Rendered PDF |
108
+
109
+ ### AI answers and email
110
+
111
+ | Method | Endpoint | Notes |
112
+ |---|---|---|
113
+ | `ai(query, engine=...)` | `/search/ai` | An AI answer engine's answer, with the sources it cited |
114
+ | `verify_email(email)` | `/email-verifier/verify` | Real SMTP probe |
115
+
116
+ ### Account
117
+
118
+ | Method | Endpoint | Notes |
119
+ |---|---|---|
120
+ | `capabilities()` | `/search/capabilities` | What this deployment serves, and its prices |
121
+ | `balance()` | `/credit/balance` | Current account credit balance |
122
+
123
+ Keyword arguments are written in Python and converted for you:
124
+ `only_main_content=True` is sent as `onlyMainContent`.
125
+
126
+ ## Freshness and cost
127
+
128
+ Web-data calls take `max_age`: the oldest cached answer you will accept, in
129
+ seconds. `0` always fetches live.
130
+
131
+ ```python
132
+ searlo.scrape("https://example.com/", max_age=300) # <= 5 minutes old
133
+ searlo.scrape("https://example.com/", max_age=0) # always live
134
+ ```
135
+
136
+ A cache hit costs 1 credit. A fetch **your freshness request forces** costs 2.
137
+ A plain cache miss, where you asked for no particular freshness, stays at 1.
138
+
139
+ ## Pages behind an interaction
140
+
141
+ `actions` runs an ordered sequence before the page is read. Every step is
142
+ best-effort and each one's outcome comes back with the content.
143
+
144
+ ```python
145
+ page = searlo.scrape(
146
+ "https://example.com/search",
147
+ actions=[
148
+ {"type": "click", "selector": "#accept-cookies"},
149
+ {"type": "type", "selector": "#q", "text": "coffee"},
150
+ {"type": "press", "selector": "#q", "key": "Enter"},
151
+ {"type": "waitForSelector", "selector": ".results"},
152
+ ],
153
+ )
154
+ print(page["actions"]) # [{"type": "click", "ok": True}, ...]
155
+ ```
156
+
157
+ ## AI answers
158
+
159
+ ```python
160
+ answer = searlo.ai("which crm do startups use", engine="gemini")
161
+ print(answer["answer"]) # the answer text
162
+ print(answer["citations"]) # each source it cited
163
+ print(answer["sources"]) # the unique cited domains
164
+ ```
165
+
166
+ Each engine has its own price per answer; `capabilities()` lists them.
167
+
168
+ ## LangChain
169
+
170
+ ```bash
171
+ pip install "searlo[langchain]"
172
+ ```
173
+
174
+ ```python
175
+ from langchain.agents import create_agent
176
+ from searlo import SearloSearchTool
177
+
178
+ search = SearloSearchTool(api_key="sk_...") # or set SEARLO_API_KEY
179
+ print(search.invoke({"query": "best crm for startups"}))
180
+
181
+ agent = create_agent(model="anthropic:claude-sonnet-4-6", tools=[search])
182
+ agent.invoke({"messages": [{"role": "user", "content": "Which CRMs do startups use?"}]})
183
+ ```
184
+
185
+ `create_agent` comes from the `langchain` package (1.0 or newer); the tool
186
+ itself only needs `langchain-core`.
187
+
188
+ ## Errors
189
+
190
+ All errors subclass `searlo.SearloError`. Specific subclasses:
191
+ `SearloAuthError` (bad key), `SearloInsufficientCreditsError` (402),
192
+ `SearloRateLimitError` (429), `SearloAPIError` (everything else, has
193
+ `.status_code` / `.retryable` / `.error_code`).
194
+
195
+ ## Requirements
196
+
197
+ Python 3.9+. The only runtime dependency is `requests`.
198
+
199
+ ## Links
200
+
201
+ - Docs: [searlo.tech/docs](https://searlo.tech/docs)
202
+ - MCP server for AI agents: [searlo.tech/mcp](https://searlo.tech/mcp)
203
+ - Changelog: [CHANGELOG.md](https://github.com/eCodeVoyager/searlo-python/blob/main/CHANGELOG.md)
204
+
205
+ ## License
206
+
207
+ MIT
208
+
209
+ Searlo is not affiliated with or endorsed by Google LLC or any other search
210
+ engine or AI provider. All trademarks belong to their owners.
@@ -0,0 +1,10 @@
1
+ searlo/__init__.py,sha256=ZDqbssg2tLSzmz279g8NeMm1MyCWMqRUNzWE1VdoGKc,656
2
+ searlo/client.py,sha256=Vcu6_hdodIO3djXxeBFcIJ_au-SkiWYqKhv37Oo0b0k,16440
3
+ searlo/exceptions.py,sha256=TAr_7uoZObjyE_VfMcTzryAVknj2Ch7e6xXirx3mGIM,709
4
+ searlo/langchain_tool.py,sha256=l4Qo88buZds9YNkkhDIdnlX2vJ6KLZjE-jolrPAK3go,2274
5
+ searlo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ searlo-0.2.0.dist-info/licenses/LICENSE,sha256=9Am80TATmMRaJzUudgJmphsYtHDteaDREVtVNxTobZA,1063
7
+ searlo-0.2.0.dist-info/METADATA,sha256=HEGOKyjtQktMPTYanQVLaVfIaPOam2c2HqiYyWN0470,8019
8
+ searlo-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
9
+ searlo-0.2.0.dist-info/top_level.txt,sha256=IWylyadV9ZDgeLil0FdpeSPLQFVp_czYmARA2qmbpXk,7
10
+ searlo-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Searlo
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.
@@ -0,0 +1 @@
1
+ searlo