serpex 2.0.2__tar.gz → 2.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.
serpex-2.2.0/PKG-INFO ADDED
@@ -0,0 +1,326 @@
1
+ Metadata-Version: 2.4
2
+ Name: serpex
3
+ Version: 2.2.0
4
+ Summary: Official Python SDK for Serpex Search API - Fetch search results in JSON format
5
+ Home-page: https://github.com/divyeshradadiya/serp-frontend
6
+ Author: Serpex Team
7
+ Author-email: Serpex Team <support@serpex.dev>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/divyeshradadiya/serpex-sdk-python
10
+ Project-URL: Repository, https://github.com/divyeshradadiya/serpex-sdk-python
11
+ Project-URL: Bug Reports, https://github.com/divyeshradadiya/serpex-sdk-python/issues
12
+ Project-URL: Documentation, https://github.com/divyeshradadiya/serpex-sdk-python#readme
13
+ Keywords: serp,search,api,google,search-results,seo,python,sdk
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: requests>=2.25.0
30
+ Requires-Dist: typing-extensions>=4.0.0; python_version < "3.10"
31
+ Dynamic: author
32
+ Dynamic: home-page
33
+ Dynamic: license-file
34
+ Dynamic: requires-python
35
+
36
+ # serpex
37
+
38
+ Official Python SDK for the Serpex SERP API - Fetch search results in JSON format.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install serpex
44
+ ```
45
+
46
+ Or with poetry:
47
+
48
+ ```bash
49
+ poetry add serpex
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ```python
55
+ from serpex import SerpexClient
56
+
57
+ # Initialize the client with your API key
58
+ client = SerpexClient('your-api-key-here')
59
+
60
+ # Search with auto-routing (recommended for simple use cases)
61
+ results = client.search({
62
+ 'q': 'python tutorial',
63
+ 'engine': 'auto'
64
+ })
65
+
66
+ # Or using SearchParams object for type safety
67
+ from serpex import SearchParams
68
+
69
+ params = SearchParams(q='python tutorial', engine='auto')
70
+ results = client.search(params)
71
+
72
+ print(results.results[0].title)
73
+ ```
74
+
75
+ ## API Reference
76
+
77
+ ### SerpexClient
78
+
79
+ #### Constructor
80
+
81
+ ```python
82
+ SerpexClient(api_key: str, base_url: str = "https://api.serpex.dev")
83
+ ```
84
+
85
+ - `api_key`: Your API key from the Serpex dashboard
86
+ - `base_url`: Optional base URL (defaults to 'https://api.serpex.dev')
87
+
88
+ #### Methods
89
+
90
+ ##### `extract(params: ExtractParams | Dict[str, Any]) -> ExtractResponse`
91
+
92
+ Extract content from web pages and convert them to LLM-ready markdown data. Accepts up to 10 URLs per request.
93
+
94
+ ```python
95
+ # Using dictionary (simple approach)
96
+ results = client.extract({
97
+ 'urls': [
98
+ 'https://example.com',
99
+ 'https://httpbin.org'
100
+ ]
101
+ })
102
+
103
+ # Using ExtractParams object (type-safe approach)
104
+ from serpex import ExtractParams
105
+
106
+ params = ExtractParams(urls=[
107
+ 'https://example.com',
108
+ 'https://httpbin.org'
109
+ ])
110
+ results = client.extract(params)
111
+ ```
112
+
113
+ ## Extract Parameters
114
+
115
+ The `ExtractParams` dataclass supports extraction parameters:
116
+
117
+ ```python
118
+ @dataclass
119
+ class ExtractParams:
120
+ # Required: URLs to extract (max 10)
121
+ urls: List[str]
122
+ ```
123
+
124
+ ## Extract Response Format
125
+
126
+ ```python
127
+ @dataclass
128
+ class ExtractResponse:
129
+ success: bool
130
+ results: List[ExtractResult]
131
+ metadata: ExtractMetadata
132
+
133
+ @dataclass
134
+ class ExtractResult:
135
+ url: str
136
+ success: bool
137
+ markdown: Optional[str] = None
138
+ error: Optional[str] = None
139
+ status_code: Optional[int] = None
140
+
141
+ @dataclass
142
+ class ExtractMetadata:
143
+ total_urls: int
144
+ processed_urls: int
145
+ successful_crawls: int
146
+ failed_crawls: int
147
+ credits_used: int
148
+ response_time: int
149
+ timestamp: str
150
+ ```
151
+
152
+ ## Search Parameters
153
+
154
+ The `SearchParams` dataclass supports all search parameters:
155
+
156
+ ```python
157
+ @dataclass
158
+ class SearchParams:
159
+ # Required: search query
160
+ q: str
161
+
162
+ # Optional: Engine selection (defaults to 'auto')
163
+ engine: Optional[str] = 'auto'
164
+
165
+ # Optional: Search category (currently only 'web' supported)
166
+ category: Optional[str] = 'web'
167
+
168
+ # Optional: Time range filter
169
+ time_range: Optional[str] = 'all'
170
+
171
+ # Optional: Response format
172
+ format: Optional[str] = 'json'
173
+ ```
174
+
175
+ ## Supported Engines
176
+
177
+ - **auto**: Automatically routes to the best available search engine
178
+ - **google**: Google's primary search engine
179
+ - **bing**: Microsoft's search engine
180
+ - **duckduckgo**: Privacy-focused search engine
181
+ - **brave**: Privacy-first search engine
182
+ - **yahoo**: Yahoo search engine
183
+ - **yandex**: Russian search engine
184
+
185
+ ## Response Format
186
+
187
+ ```python
188
+ @dataclass
189
+ class SearchResponse:
190
+ metadata: SearchMetadata
191
+ id: str
192
+ query: str
193
+ engines: List[str]
194
+ results: List[SearchResult]
195
+ answers: List[Any]
196
+ corrections: List[str]
197
+ infoboxes: List[Any]
198
+ suggestions: List[str]
199
+ ```
200
+
201
+ ## Error Handling
202
+
203
+ The SDK raises `SerpApiException` for API errors:
204
+
205
+ ```python
206
+ from serpex import SerpexClient, SerpApiException
207
+
208
+ try:
209
+ results = client.search(SearchParams(q='test query'))
210
+ except SerpApiException as e:
211
+ print(f"API error: {e}")
212
+ print(f"Status code: {e.status_code}")
213
+ print(f"Details: {e.details}")
214
+ ```
215
+
216
+ ## Examples
217
+
218
+ ### Basic Search
219
+ ```python
220
+ results = client.search({
221
+ 'q': 'coffee shops near me'
222
+ })
223
+ ```
224
+
225
+ ### Advanced Search with Filters
226
+ ```python
227
+ results = client.search({
228
+ 'q': 'latest AI news',
229
+ 'engine': 'google',
230
+ 'time_range': 'day',
231
+ 'category': 'web'
232
+ })
233
+ ```
234
+
235
+ ### Using SearchParams Object
236
+ ```python
237
+ from serpex import SearchParams
238
+
239
+ params = SearchParams(
240
+ q='machine learning',
241
+ engine='auto',
242
+ time_range='month'
243
+ )
244
+ results = client.search(params)
245
+ ```
246
+
247
+ ### Extract Web Content to LLM-Ready Data
248
+
249
+ #### Extract from a Single URL
250
+ ```python
251
+ # Extract content from one website
252
+ result = client.extract({
253
+ 'urls': ['https://example.com']
254
+ })
255
+
256
+ if result.results[0].success:
257
+ print(f"✅ Extracted {len(result.results[0].markdown)} characters")
258
+ print("Markdown content:", result.results[0].markdown[:200] + "...")
259
+ ```
260
+
261
+ #### Extract from Multiple URLs (up to 10 at once)
262
+ ```python
263
+ # Extract content from multiple websites (up to 10 URLs)
264
+ extract_results = client.extract({
265
+ 'urls': [
266
+ 'https://example.com',
267
+ 'https://httpbin.org',
268
+ 'https://github.com'
269
+ ]
270
+ })
271
+
272
+ print(f"Successfully extracted {extract_results.metadata.successful_crawls} pages")
273
+ print(f"Total credits used: {extract_results.metadata.credits_used}")
274
+
275
+ for result in extract_results.results:
276
+ if result.success:
277
+ print(f"✅ {result.url}: {len(result.markdown)} characters")
278
+ # Use result.markdown for LLM processing
279
+ else:
280
+ print(f"❌ {result.url}: {result.error}")
281
+ ```
282
+
283
+ #### Sample Response
284
+ ```python
285
+ # Example response structure
286
+ {
287
+ 'success': True,
288
+ 'results': [
289
+ {
290
+ 'url': 'https://example.com',
291
+ 'success': True,
292
+ 'markdown': '# Example Domain\n\nThis domain is for use in...',
293
+ 'status_code': 200
294
+ }
295
+ ],
296
+ 'metadata': {
297
+ 'total_urls': 1,
298
+ 'processed_urls': 1,
299
+ 'successful_crawls': 1,
300
+ 'failed_crawls': 0,
301
+ 'credits_used': 3,
302
+ 'response_time': 255,
303
+ 'timestamp': '2025-11-13T10:30:00.000Z'
304
+ }
305
+ }
306
+ ```
307
+
308
+ ### Using ExtractParams Object
309
+ ```python
310
+ from serpex import ExtractParams
311
+
312
+ params = ExtractParams(urls=[
313
+ 'https://example.com',
314
+ 'https://httpbin.org'
315
+ ])
316
+ results = client.extract(params)
317
+ ```
318
+
319
+ ## Requirements
320
+
321
+ - Python 3.8+
322
+ - requests
323
+
324
+ ## License
325
+
326
+ MIT
serpex-2.2.0/README.md ADDED
@@ -0,0 +1,291 @@
1
+ # serpex
2
+
3
+ Official Python SDK for the Serpex SERP API - Fetch search results in JSON format.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install serpex
9
+ ```
10
+
11
+ Or with poetry:
12
+
13
+ ```bash
14
+ poetry add serpex
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```python
20
+ from serpex import SerpexClient
21
+
22
+ # Initialize the client with your API key
23
+ client = SerpexClient('your-api-key-here')
24
+
25
+ # Search with auto-routing (recommended for simple use cases)
26
+ results = client.search({
27
+ 'q': 'python tutorial',
28
+ 'engine': 'auto'
29
+ })
30
+
31
+ # Or using SearchParams object for type safety
32
+ from serpex import SearchParams
33
+
34
+ params = SearchParams(q='python tutorial', engine='auto')
35
+ results = client.search(params)
36
+
37
+ print(results.results[0].title)
38
+ ```
39
+
40
+ ## API Reference
41
+
42
+ ### SerpexClient
43
+
44
+ #### Constructor
45
+
46
+ ```python
47
+ SerpexClient(api_key: str, base_url: str = "https://api.serpex.dev")
48
+ ```
49
+
50
+ - `api_key`: Your API key from the Serpex dashboard
51
+ - `base_url`: Optional base URL (defaults to 'https://api.serpex.dev')
52
+
53
+ #### Methods
54
+
55
+ ##### `extract(params: ExtractParams | Dict[str, Any]) -> ExtractResponse`
56
+
57
+ Extract content from web pages and convert them to LLM-ready markdown data. Accepts up to 10 URLs per request.
58
+
59
+ ```python
60
+ # Using dictionary (simple approach)
61
+ results = client.extract({
62
+ 'urls': [
63
+ 'https://example.com',
64
+ 'https://httpbin.org'
65
+ ]
66
+ })
67
+
68
+ # Using ExtractParams object (type-safe approach)
69
+ from serpex import ExtractParams
70
+
71
+ params = ExtractParams(urls=[
72
+ 'https://example.com',
73
+ 'https://httpbin.org'
74
+ ])
75
+ results = client.extract(params)
76
+ ```
77
+
78
+ ## Extract Parameters
79
+
80
+ The `ExtractParams` dataclass supports extraction parameters:
81
+
82
+ ```python
83
+ @dataclass
84
+ class ExtractParams:
85
+ # Required: URLs to extract (max 10)
86
+ urls: List[str]
87
+ ```
88
+
89
+ ## Extract Response Format
90
+
91
+ ```python
92
+ @dataclass
93
+ class ExtractResponse:
94
+ success: bool
95
+ results: List[ExtractResult]
96
+ metadata: ExtractMetadata
97
+
98
+ @dataclass
99
+ class ExtractResult:
100
+ url: str
101
+ success: bool
102
+ markdown: Optional[str] = None
103
+ error: Optional[str] = None
104
+ status_code: Optional[int] = None
105
+
106
+ @dataclass
107
+ class ExtractMetadata:
108
+ total_urls: int
109
+ processed_urls: int
110
+ successful_crawls: int
111
+ failed_crawls: int
112
+ credits_used: int
113
+ response_time: int
114
+ timestamp: str
115
+ ```
116
+
117
+ ## Search Parameters
118
+
119
+ The `SearchParams` dataclass supports all search parameters:
120
+
121
+ ```python
122
+ @dataclass
123
+ class SearchParams:
124
+ # Required: search query
125
+ q: str
126
+
127
+ # Optional: Engine selection (defaults to 'auto')
128
+ engine: Optional[str] = 'auto'
129
+
130
+ # Optional: Search category (currently only 'web' supported)
131
+ category: Optional[str] = 'web'
132
+
133
+ # Optional: Time range filter
134
+ time_range: Optional[str] = 'all'
135
+
136
+ # Optional: Response format
137
+ format: Optional[str] = 'json'
138
+ ```
139
+
140
+ ## Supported Engines
141
+
142
+ - **auto**: Automatically routes to the best available search engine
143
+ - **google**: Google's primary search engine
144
+ - **bing**: Microsoft's search engine
145
+ - **duckduckgo**: Privacy-focused search engine
146
+ - **brave**: Privacy-first search engine
147
+ - **yahoo**: Yahoo search engine
148
+ - **yandex**: Russian search engine
149
+
150
+ ## Response Format
151
+
152
+ ```python
153
+ @dataclass
154
+ class SearchResponse:
155
+ metadata: SearchMetadata
156
+ id: str
157
+ query: str
158
+ engines: List[str]
159
+ results: List[SearchResult]
160
+ answers: List[Any]
161
+ corrections: List[str]
162
+ infoboxes: List[Any]
163
+ suggestions: List[str]
164
+ ```
165
+
166
+ ## Error Handling
167
+
168
+ The SDK raises `SerpApiException` for API errors:
169
+
170
+ ```python
171
+ from serpex import SerpexClient, SerpApiException
172
+
173
+ try:
174
+ results = client.search(SearchParams(q='test query'))
175
+ except SerpApiException as e:
176
+ print(f"API error: {e}")
177
+ print(f"Status code: {e.status_code}")
178
+ print(f"Details: {e.details}")
179
+ ```
180
+
181
+ ## Examples
182
+
183
+ ### Basic Search
184
+ ```python
185
+ results = client.search({
186
+ 'q': 'coffee shops near me'
187
+ })
188
+ ```
189
+
190
+ ### Advanced Search with Filters
191
+ ```python
192
+ results = client.search({
193
+ 'q': 'latest AI news',
194
+ 'engine': 'google',
195
+ 'time_range': 'day',
196
+ 'category': 'web'
197
+ })
198
+ ```
199
+
200
+ ### Using SearchParams Object
201
+ ```python
202
+ from serpex import SearchParams
203
+
204
+ params = SearchParams(
205
+ q='machine learning',
206
+ engine='auto',
207
+ time_range='month'
208
+ )
209
+ results = client.search(params)
210
+ ```
211
+
212
+ ### Extract Web Content to LLM-Ready Data
213
+
214
+ #### Extract from a Single URL
215
+ ```python
216
+ # Extract content from one website
217
+ result = client.extract({
218
+ 'urls': ['https://example.com']
219
+ })
220
+
221
+ if result.results[0].success:
222
+ print(f"✅ Extracted {len(result.results[0].markdown)} characters")
223
+ print("Markdown content:", result.results[0].markdown[:200] + "...")
224
+ ```
225
+
226
+ #### Extract from Multiple URLs (up to 10 at once)
227
+ ```python
228
+ # Extract content from multiple websites (up to 10 URLs)
229
+ extract_results = client.extract({
230
+ 'urls': [
231
+ 'https://example.com',
232
+ 'https://httpbin.org',
233
+ 'https://github.com'
234
+ ]
235
+ })
236
+
237
+ print(f"Successfully extracted {extract_results.metadata.successful_crawls} pages")
238
+ print(f"Total credits used: {extract_results.metadata.credits_used}")
239
+
240
+ for result in extract_results.results:
241
+ if result.success:
242
+ print(f"✅ {result.url}: {len(result.markdown)} characters")
243
+ # Use result.markdown for LLM processing
244
+ else:
245
+ print(f"❌ {result.url}: {result.error}")
246
+ ```
247
+
248
+ #### Sample Response
249
+ ```python
250
+ # Example response structure
251
+ {
252
+ 'success': True,
253
+ 'results': [
254
+ {
255
+ 'url': 'https://example.com',
256
+ 'success': True,
257
+ 'markdown': '# Example Domain\n\nThis domain is for use in...',
258
+ 'status_code': 200
259
+ }
260
+ ],
261
+ 'metadata': {
262
+ 'total_urls': 1,
263
+ 'processed_urls': 1,
264
+ 'successful_crawls': 1,
265
+ 'failed_crawls': 0,
266
+ 'credits_used': 3,
267
+ 'response_time': 255,
268
+ 'timestamp': '2025-11-13T10:30:00.000Z'
269
+ }
270
+ }
271
+ ```
272
+
273
+ ### Using ExtractParams Object
274
+ ```python
275
+ from serpex import ExtractParams
276
+
277
+ params = ExtractParams(urls=[
278
+ 'https://example.com',
279
+ 'https://httpbin.org'
280
+ ])
281
+ results = client.extract(params)
282
+ ```
283
+
284
+ ## Requirements
285
+
286
+ - Python 3.8+
287
+ - requests
288
+
289
+ ## License
290
+
291
+ MIT
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "serpex"
7
- version = "2.0.2"
8
- description = "Official Python SDK for Serpex SERP API - Fetch search results in JSON format"
7
+ version = "2.2.0"
8
+ description = "Official Python SDK for Serpex Search API - Fetch search results in JSON format"
9
9
  authors = [
10
10
  {name = "Serpex Team", email = "support@serpex.dev"}
11
11
  ]
@@ -33,10 +33,10 @@ dependencies = [
33
33
  ]
34
34
 
35
35
  [project.urls]
36
- Homepage = "https://github.com/divyeshradadiya/serp-frontend"
37
- Repository = "https://github.com/divyeshradadiya/serp-frontend"
38
- "Bug Reports" = "https://github.com/divyeshradadiya/serp-frontend/issues"
39
- Documentation = "https://github.com/divyeshradadiya/serp-frontend#readme"
36
+ Homepage = "https://github.com/divyeshradadiya/serpex-sdk-python"
37
+ Repository = "https://github.com/divyeshradadiya/serpex-sdk-python"
38
+ "Bug Reports" = "https://github.com/divyeshradadiya/serpex-sdk-python/issues"
39
+ Documentation = "https://github.com/divyeshradadiya/serpex-sdk-python#readme"
40
40
 
41
41
  [tool.setuptools.packages.find]
42
42
  where = ["src"]
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="serpex",
8
- version="2.0.2",
8
+ version="2.2.0",
9
9
  author="Serpex Team",
10
10
  author_email="support@serpex.dev",
11
11
  description="Official Python SDK for Serpex SERP API - Fetch search results in JSON format",