orangeslice 1.6.0 → 1.6.1
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/README.md +65 -0
- package/dist/serp.d.ts +4 -1
- package/dist/serp.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,35 @@ All calls are rate-limited automatically.
|
|
|
56
56
|
npm install orangeslice
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### TypeScript Setup
|
|
60
|
+
|
|
61
|
+
If running `.ts` files directly with `ts-node` or `tsx`, you may need:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install -D typescript @types/node tsx
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Recommended `tsconfig.json`:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"compilerOptions": {
|
|
72
|
+
"target": "ES2020",
|
|
73
|
+
"module": "NodeNext",
|
|
74
|
+
"moduleResolution": "NodeNext",
|
|
75
|
+
"esModuleInterop": true,
|
|
76
|
+
"strict": false,
|
|
77
|
+
"skipLibCheck": true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then run with:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx tsx your-script.ts
|
|
86
|
+
```
|
|
87
|
+
|
|
59
88
|
## Usage
|
|
60
89
|
|
|
61
90
|
```typescript
|
|
@@ -135,6 +164,42 @@ const result = await orangeslice.b2b.query("SELECT * FROM linkedin_company LIMIT
|
|
|
135
164
|
// result.rows, result.rowCount, result.duration_ms
|
|
136
165
|
```
|
|
137
166
|
|
|
167
|
+
### `orangeslice.serp.search(query: string, options?): Promise<SerpResponse>`
|
|
168
|
+
|
|
169
|
+
Search Google and return results.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const response = await orangeslice.serp.search("Stripe funding 2024");
|
|
173
|
+
// response.results = [{ title, link, snippet }, ...]
|
|
174
|
+
|
|
175
|
+
// With options
|
|
176
|
+
const filtered = await orangeslice.serp.search("site:linkedin.com CEO", {
|
|
177
|
+
tbs: "qdr:m", // Past month
|
|
178
|
+
page: 1
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### `orangeslice.firecrawl.scrape(url: string, limit?): Promise<FirecrawlResponse>`
|
|
183
|
+
|
|
184
|
+
Scrape a website and get markdown + social URLs.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
const page = await orangeslice.firecrawl.scrape("https://stripe.com/about");
|
|
188
|
+
// page.markdown, page.socialUrls
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `orangeslice.browser.execute(code: string, options?): Promise<BrowserResponse>`
|
|
192
|
+
|
|
193
|
+
Execute Playwright code with `page` in scope.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const response = await orangeslice.browser.execute(`
|
|
197
|
+
await page.goto("https://example.com", { waitUntil: 'domcontentloaded' });
|
|
198
|
+
return await page.evaluate(() => document.title);
|
|
199
|
+
`);
|
|
200
|
+
// response.success, response.result
|
|
201
|
+
```
|
|
202
|
+
|
|
138
203
|
## Note on Concurrency
|
|
139
204
|
|
|
140
205
|
The rate limit is **per-process**. If you run multiple scripts simultaneously, each has its own queue. For most AI agent use cases (single script), this is fine.
|
package/dist/serp.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export interface SerpResult {
|
|
|
5
5
|
position?: number;
|
|
6
6
|
}
|
|
7
7
|
export interface SerpResponse {
|
|
8
|
+
/** Search results (primary field from API) */
|
|
9
|
+
results?: SerpResult[];
|
|
10
|
+
/** @deprecated Use `results` instead */
|
|
8
11
|
organic_results?: SerpResult[];
|
|
9
12
|
related_questions?: Array<{
|
|
10
13
|
question: string;
|
|
@@ -32,7 +35,7 @@ export interface SerpOptions {
|
|
|
32
35
|
*/
|
|
33
36
|
export declare function search(query: string, options?: SerpOptions): Promise<SerpResponse>;
|
|
34
37
|
/**
|
|
35
|
-
* Search and return just the
|
|
38
|
+
* Search and return just the results array
|
|
36
39
|
*/
|
|
37
40
|
export declare function organic(query: string, options?: SerpOptions): Promise<SerpResult[]>;
|
|
38
41
|
export declare const serp: {
|
package/dist/serp.js
CHANGED
|
@@ -57,11 +57,11 @@ async function search(query, options = {}) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* Search and return just the
|
|
60
|
+
* Search and return just the results array
|
|
61
61
|
*/
|
|
62
62
|
async function organic(query, options = {}) {
|
|
63
63
|
const data = await search(query, options);
|
|
64
|
-
return data.organic_results || [];
|
|
64
|
+
return data.results || data.organic_results || [];
|
|
65
65
|
}
|
|
66
66
|
// Export as namespace
|
|
67
67
|
exports.serp = {
|