serpex 2.0.0
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.
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Serpex
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# serpex
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the Serpex SERP API - Fetch search results in JSON format.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install serpex
|
|
9
|
+
# or
|
|
10
|
+
yarn add serpex
|
|
11
|
+
# or
|
|
12
|
+
pnpm add serpex
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { SerpApiClient } from 'serpex';
|
|
19
|
+
|
|
20
|
+
// Initialize the client with your API key
|
|
21
|
+
const client = new SerpApiClient('your-api-key-here');
|
|
22
|
+
|
|
23
|
+
// Search with Google
|
|
24
|
+
const googleResults = await client.search({
|
|
25
|
+
q: 'typescript tutorial',
|
|
26
|
+
engine: 'google',
|
|
27
|
+
hl: 'en'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Search with Bing
|
|
31
|
+
const bingResults = await client.search({
|
|
32
|
+
q: 'typescript tutorial',
|
|
33
|
+
engine: 'bing',
|
|
34
|
+
mkt: 'en-US'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log(googleResults.results[0].title);
|
|
38
|
+
console.log(bingResults.results[0].title);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API Reference
|
|
42
|
+
|
|
43
|
+
### SerpApiClient
|
|
44
|
+
|
|
45
|
+
#### Constructor
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
new SerpApiClient(apiKey: string, baseUrl?: string)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- `apiKey`: Your API key from the Serpex dashboard
|
|
52
|
+
- `baseUrl`: Optional base URL (defaults to 'https://api.serpex.dev')
|
|
53
|
+
|
|
54
|
+
#### Methods
|
|
55
|
+
|
|
56
|
+
##### `search(params: SearchParams): Promise<SearchResponse>`
|
|
57
|
+
|
|
58
|
+
Search using the SERP API with flexible parameters. Engine parameter is required.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const results = await client.search({
|
|
62
|
+
q: 'javascript frameworks',
|
|
63
|
+
engine: 'duckduckgo',
|
|
64
|
+
region: 'us-en',
|
|
65
|
+
safesearch: 1
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Search using the SERP API with flexible parameters.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const results = await client.search({
|
|
73
|
+
q: 'javascript frameworks',
|
|
74
|
+
engines: ['google', 'duckduckgo'],
|
|
75
|
+
language: 'en',
|
|
76
|
+
country: 'us',
|
|
77
|
+
safesearch: 1,
|
|
78
|
+
time_range: 'year',
|
|
79
|
+
pageno: 1,
|
|
80
|
+
// Google-specific parameters
|
|
81
|
+
hl: 'en',
|
|
82
|
+
lr: 'lang_en',
|
|
83
|
+
// Bing-specific parameters
|
|
84
|
+
mkt: 'en-US'
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Search Parameters
|
|
89
|
+
|
|
90
|
+
The `SearchParams` interface supports all search parameters:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
interface SearchParams {
|
|
94
|
+
// Required: query (use either q or query)
|
|
95
|
+
q?: string;
|
|
96
|
+
query?: string;
|
|
97
|
+
|
|
98
|
+
// Engine selection (only one engine allowed)
|
|
99
|
+
engine?: string;
|
|
100
|
+
|
|
101
|
+
// Common parameters
|
|
102
|
+
language?: string;
|
|
103
|
+
pageno?: number;
|
|
104
|
+
page?: number;
|
|
105
|
+
time_range?: string;
|
|
106
|
+
safesearch?: number;
|
|
107
|
+
|
|
108
|
+
// Google specific
|
|
109
|
+
hl?: string; // language
|
|
110
|
+
lr?: string; // language restrict
|
|
111
|
+
cr?: string; // country restrict
|
|
112
|
+
|
|
113
|
+
// Bing specific
|
|
114
|
+
mkt?: string; // market
|
|
115
|
+
|
|
116
|
+
// DuckDuckGo specific
|
|
117
|
+
region?: string;
|
|
118
|
+
|
|
119
|
+
// Brave specific
|
|
120
|
+
category?: string;
|
|
121
|
+
spellcheck?: boolean;
|
|
122
|
+
ui_lang?: string;
|
|
123
|
+
country?: string;
|
|
124
|
+
|
|
125
|
+
// Legacy support
|
|
126
|
+
maxResults?: number;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Response Format
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
interface SearchResponse {
|
|
134
|
+
metadata: {
|
|
135
|
+
number_of_results: number;
|
|
136
|
+
response_time: number;
|
|
137
|
+
timestamp: string;
|
|
138
|
+
credits_used: number;
|
|
139
|
+
};
|
|
140
|
+
id: string;
|
|
141
|
+
query: string;
|
|
142
|
+
engines: string[];
|
|
143
|
+
results: Array<{
|
|
144
|
+
title: string;
|
|
145
|
+
url: string;
|
|
146
|
+
snippet: string;
|
|
147
|
+
position: number;
|
|
148
|
+
engine: string;
|
|
149
|
+
published_date: string | null;
|
|
150
|
+
img_src?: string;
|
|
151
|
+
duration?: string;
|
|
152
|
+
score?: number;
|
|
153
|
+
}>;
|
|
154
|
+
answers: any[];
|
|
155
|
+
corrections: string[];
|
|
156
|
+
infoboxes: any[];
|
|
157
|
+
suggestions: string[];
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Error Handling
|
|
162
|
+
|
|
163
|
+
The SDK throws `SerpApiException` for API errors:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { SerpApiClient, SerpApiException } from 'serpex';
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const results = await client.search({ q: 'test query' });
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (error instanceof SerpApiException) {
|
|
172
|
+
console.log('API Error:', error.message);
|
|
173
|
+
console.log('Status Code:', error.statusCode);
|
|
174
|
+
console.log('Details:', error.details);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SearchResponse, SearchParams, SerpApiException } from './types';
|
|
2
|
+
export { SearchResponse, SearchParams, SerpApiException };
|
|
3
|
+
export declare class SerpApiClient {
|
|
4
|
+
private baseUrl;
|
|
5
|
+
private apiKey;
|
|
6
|
+
/**
|
|
7
|
+
* Create a new SerpApiClient instance
|
|
8
|
+
* @param apiKey - Your API key from the Serpex dashboard
|
|
9
|
+
* @param baseUrl - Base URL for the API (optional, defaults to production)
|
|
10
|
+
*/
|
|
11
|
+
constructor(apiKey: string, baseUrl?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Make an authenticated request to the API
|
|
14
|
+
*/
|
|
15
|
+
private makeRequest;
|
|
16
|
+
/**
|
|
17
|
+
* Search using the SERP API
|
|
18
|
+
* @param params - Search parameters including query, engine, and engine-specific options
|
|
19
|
+
* @returns Search results
|
|
20
|
+
*/
|
|
21
|
+
search(params: SearchParams): Promise<SearchResponse>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAE1D,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAiC;IAStE;;OAEG;YACW,WAAW;IA6CzB;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;CA4B5D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerpApiClient = exports.SerpApiException = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
Object.defineProperty(exports, "SerpApiException", { enumerable: true, get: function () { return types_1.SerpApiException; } });
|
|
6
|
+
class SerpApiClient {
|
|
7
|
+
/**
|
|
8
|
+
* Create a new SerpApiClient instance
|
|
9
|
+
* @param apiKey - Your API key from the Serpex dashboard
|
|
10
|
+
* @param baseUrl - Base URL for the API (optional, defaults to production)
|
|
11
|
+
*/
|
|
12
|
+
constructor(apiKey, baseUrl = 'https://api.serpex.dev') {
|
|
13
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
14
|
+
throw new Error('API key is required and must be a string');
|
|
15
|
+
}
|
|
16
|
+
this.apiKey = apiKey;
|
|
17
|
+
this.baseUrl = baseUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Make an authenticated request to the API
|
|
21
|
+
*/
|
|
22
|
+
async makeRequest(endpoint, params = {}) {
|
|
23
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
24
|
+
const headers = {
|
|
25
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
26
|
+
'Content-Type': 'application/json'
|
|
27
|
+
};
|
|
28
|
+
// Build query string from params
|
|
29
|
+
const searchParams = new URLSearchParams();
|
|
30
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
31
|
+
if (value !== undefined && value !== null) {
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
value.forEach(v => searchParams.append(key, v.toString()));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
searchParams.append(key, value.toString());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const finalUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
|
|
41
|
+
const response = await fetch(finalUrl, {
|
|
42
|
+
method: 'GET',
|
|
43
|
+
headers
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
let errorData = {};
|
|
47
|
+
try {
|
|
48
|
+
errorData = await response.json();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// If we can't parse the error response, use the status text
|
|
52
|
+
errorData = { error: response.statusText };
|
|
53
|
+
}
|
|
54
|
+
throw new types_1.SerpApiException(errorData.error || 'API request failed', response.status, errorData);
|
|
55
|
+
}
|
|
56
|
+
return response.json();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Search using the SERP API
|
|
60
|
+
* @param params - Search parameters including query, engine, and engine-specific options
|
|
61
|
+
* @returns Search results
|
|
62
|
+
*/
|
|
63
|
+
async search(params) {
|
|
64
|
+
if (!params.q && !params.query) {
|
|
65
|
+
throw new Error('Query parameter (q or query) is required');
|
|
66
|
+
}
|
|
67
|
+
const searchQuery = params.q || params.query;
|
|
68
|
+
if (typeof searchQuery !== 'string' || searchQuery.trim().length === 0) {
|
|
69
|
+
throw new Error('Query must be a non-empty string');
|
|
70
|
+
}
|
|
71
|
+
if (searchQuery.length > 500) {
|
|
72
|
+
throw new Error('Query too long (max 500 characters)');
|
|
73
|
+
}
|
|
74
|
+
// Prepare request parameters
|
|
75
|
+
const requestParams = { ...params };
|
|
76
|
+
// Ensure we have a query parameter
|
|
77
|
+
requestParams.q = searchQuery;
|
|
78
|
+
// Handle engine parameter - must be specified
|
|
79
|
+
if (!params.engine) {
|
|
80
|
+
throw new Error('Engine parameter is required (google, bing, duckduckgo, or brave)');
|
|
81
|
+
}
|
|
82
|
+
requestParams.engine = params.engine;
|
|
83
|
+
return this.makeRequest('/api/search', requestParams);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.SerpApiClient = SerpApiClient;
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,WAAW,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,6BAA6B;QAC7B,MAAM,aAAa,GAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;QAEzD,mCAAmC;QACnC,aAAa,CAAC,CAAC,GAAG,WAAW,CAAC;QAE9B,8CAA8C;QAC9C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;QACvF,CAAC;QACD,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAErC,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACF;AAnGD,sCAmGC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface SearchResult {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
snippet: string;
|
|
5
|
+
position: number;
|
|
6
|
+
engine: string;
|
|
7
|
+
published_date: string | null;
|
|
8
|
+
img_src?: string;
|
|
9
|
+
duration?: string;
|
|
10
|
+
score?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SearchMetadata {
|
|
13
|
+
number_of_results: number;
|
|
14
|
+
response_time: number;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
credits_used: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SearchResponse {
|
|
19
|
+
metadata: SearchMetadata;
|
|
20
|
+
id: string;
|
|
21
|
+
query: string;
|
|
22
|
+
engines: string[];
|
|
23
|
+
results: SearchResult[];
|
|
24
|
+
answers: any[];
|
|
25
|
+
corrections: string[];
|
|
26
|
+
infoboxes: any[];
|
|
27
|
+
suggestions: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface SearchParams {
|
|
30
|
+
q?: string;
|
|
31
|
+
query?: string;
|
|
32
|
+
engine?: string;
|
|
33
|
+
language?: string;
|
|
34
|
+
pageno?: number;
|
|
35
|
+
page?: number;
|
|
36
|
+
time_range?: string;
|
|
37
|
+
safesearch?: number;
|
|
38
|
+
hl?: string;
|
|
39
|
+
lr?: string;
|
|
40
|
+
cr?: string;
|
|
41
|
+
mkt?: string;
|
|
42
|
+
region?: string;
|
|
43
|
+
category?: string;
|
|
44
|
+
spellcheck?: boolean;
|
|
45
|
+
ui_lang?: string;
|
|
46
|
+
country?: string;
|
|
47
|
+
maxResults?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface SerpApiError {
|
|
50
|
+
error: string;
|
|
51
|
+
details?: string;
|
|
52
|
+
invalid_engines?: string[];
|
|
53
|
+
supported_engines?: string[];
|
|
54
|
+
retryAfter?: number;
|
|
55
|
+
}
|
|
56
|
+
export declare class SerpApiException extends Error {
|
|
57
|
+
readonly statusCode?: number;
|
|
58
|
+
readonly details?: any;
|
|
59
|
+
constructor(message: string, statusCode?: number, details?: any);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACt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AAC;CACrB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,OAAO,CAAC,EAAE,GAAG,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAMhE"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TypeScript SDK for Serpex SERP API
|
|
3
|
+
// Types and interfaces
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SerpApiException = void 0;
|
|
6
|
+
class SerpApiException extends Error {
|
|
7
|
+
constructor(message, statusCode, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'SerpApiException';
|
|
10
|
+
this.statusCode = statusCode;
|
|
11
|
+
this.details = details;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.SerpApiException = SerpApiException;
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,qCAAqC;AACrC,uBAAuB;;;AA6EvB,MAAa,gBAAiB,SAAQ,KAAK;IAIzC,YAAY,OAAe,EAAE,UAAmB,EAAE,OAAa;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,4CAUC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "serpex",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Official TypeScript SDK for Serpex SERP API - Fetch search results in JSON format",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"lint": "eslint src/**/*.ts",
|
|
19
|
+
"format": "prettier --write src/**/*.ts"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"serp",
|
|
23
|
+
"search",
|
|
24
|
+
"api",
|
|
25
|
+
"google",
|
|
26
|
+
"search-results",
|
|
27
|
+
"seo",
|
|
28
|
+
"typescript",
|
|
29
|
+
"sdk"
|
|
30
|
+
],
|
|
31
|
+
"author": "Serpex Team",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/divyeshradadiya/serp-frontend.git",
|
|
36
|
+
"directory": "sdk/typescript"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/divyeshradadiya/serp-frontend/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/divyeshradadiya/serp-frontend#readme",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/jest": "^29.5.0",
|
|
49
|
+
"@types/node": "^20.0.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
51
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
52
|
+
"eslint": "^8.0.0",
|
|
53
|
+
"jest": "^29.5.0",
|
|
54
|
+
"prettier": "^3.0.0",
|
|
55
|
+
"ts-jest": "^29.1.0",
|
|
56
|
+
"typescript": "^5.0.0"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=16.0.0"
|
|
60
|
+
}
|
|
61
|
+
}
|