Skip to content

Commit 75c3137

Browse files
committed
Remove pagination support
1 parent ecea6dc commit 75c3137

32 files changed

+20
-2412
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to
2626
- Remove all types for engine parameters and responses. SerpApi's
2727
[documentation](https://serpapi.com/search-api) should be the only source of
2828
truth for valid engines and their parameters.
29+
- Remove pagination support.
2930

3031
## [1.1.1] - 2023-02-15
3132

README.md

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ import { getJson } from "https://deno.land/x/serpapi/mod.ts";
8080
- Promises and async/await support.
8181
- Callbacks support.
8282
- [Examples in JavaScript/TypeScript on Node.js/Deno using ESM/CommonJS, and more](https://github.com/serpapi/serpapi-javascript/tree/master/examples).
83-
- [Pagination support](#pagination).
8483
- (Planned) More error classes.
8584

8685
## Configuration
@@ -103,33 +102,6 @@ await getJson({ engine: "google", q: "coffee" }); // uses the API key defined in
103102
await getJson({ engine: "google", api_key: API_KEY_2, q: "coffee" }); // API_KEY_2 will be used
104103
```
105104

106-
## Pagination
107-
108-
Search engines handle pagination in several different ways. Some rely on an
109-
"offset" value to return results starting from a specific index, while some
110-
others rely on the typical notion of a "page". These are often combined with a
111-
"size" value to define how many results are returned in a search.
112-
113-
This module helps you handle pagination easily. After receiving search results
114-
from `getJson`, simply call the `next()` method on the returned object to
115-
retrieve the next page of results. If there is no `next()` method, then either
116-
pagination is not supported for the search engine or there are no more pages to
117-
be retrieved.
118-
119-
```js
120-
const page1 = await getJson({ engine: "google", q: "coffee", start: 15 });
121-
const page2 = await page1.next?.();
122-
```
123-
124-
You may pass in the engine's supported pagination parameters as per normal. In
125-
the above example, the first page contains the 15th to the 24th result while the
126-
second page contains the 25th to the 34th result.
127-
128-
Note that if you set `no_cache` to `true`, all subsequent `next()` calls will
129-
not return cached results.
130-
131-
Refer to the [`getJson` definition below](#getjson) for more examples.
132-
133105
## Functions
134106

135107
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
@@ -159,10 +131,6 @@ Refer to the [`getJson` definition below](#getjson) for more examples.
159131

160132
Get a JSON response based on search parameters.
161133

162-
- Accepts an optional callback.
163-
- Get the next page of results by calling the `.next()` method on the returned
164-
response object.
165-
166134
#### Parameters
167135

168136
- `parameters`
@@ -180,43 +148,6 @@ const json = await getJson({ engine: "google", api_key: API_KEY, q: "coffee" });
180148
getJson({ engine: "google", api_key: API_KEY, q: "coffee" }, console.log);
181149
```
182150

183-
```javascript
184-
// pagination (async/await)
185-
const page1 = await getJson({ engine: "google", q: "coffee", start: 15 });
186-
const page2 = await page1.next?.();
187-
```
188-
189-
```javascript
190-
// pagination (callback)
191-
getJson({ engine: "google", q: "coffee", start: 15 }, (page1) => {
192-
page1.next?.((page2) => {
193-
console.log(page2);
194-
});
195-
});
196-
```
197-
198-
```javascript
199-
// pagination loop (async/await)
200-
const organicResults = [];
201-
let page = await getJson({ engine: "google", api_key: API_KEY, q: "coffee" });
202-
while (page) {
203-
organicResults.push(...page.organic_results);
204-
if (organicResults.length >= 30) break;
205-
page = await page.next?.();
206-
}
207-
```
208-
209-
```javascript
210-
// pagination loop (callback)
211-
const organicResults = [];
212-
getJson({ engine: "google", api_key: API_KEY, q: "coffee" }, (page) => {
213-
organicResults.push(...page.organic_results);
214-
if (organicResults.length < 30 && page.next) {
215-
page.next();
216-
}
217-
});
218-
```
219-
220151
### getHtml
221152

222153
Get a HTML response based on search parameters.

examples/deno/pagination_ts/.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/deno/pagination_ts/README.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

examples/deno/pagination_ts/example.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

examples/node/pagination_js_node_14_up/.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/node/pagination_js_node_14_up/README.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/node/pagination_js_node_14_up/example.js

Lines changed: 0 additions & 79 deletions
This file was deleted.

examples/node/pagination_js_node_14_up/package.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/node/pagination_js_node_7_up/.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)