Skip to content

Commit a60cf28

Browse files
committed
Update docs
1 parent 0b49cf7 commit a60cf28

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ npm install serpapi
2525

2626
```js
2727
import { getJson } from "serpapi";
28-
const response = await getJson("google", {
28+
const response = await getJson({
29+
engine: "google",
2930
api_key: API_KEY, // Get your API_KEY from https://serpapi.com/manage-api-key
3031
q: "coffee",
3132
location: "Austin, Texas",
@@ -68,8 +69,8 @@ import { config, getJson } from "serpapi";
6869
config.api_key = API_KEY;
6970
config.timeout = 60000;
7071

71-
await getJson("google", { q: "coffee" }); // uses the API key defined in the config
72-
await getJson("google", { api_key: API_KEY_2, q: "coffee" }); // API_KEY_2 will be used
72+
await getJson({ engine: "google", q: "coffee" }); // uses the API key defined in the config
73+
await getJson({ engine: "google", api_key: API_KEY_2, q: "coffee" }); // API_KEY_2 will be used
7374
```
7475

7576
## Pagination
@@ -86,7 +87,7 @@ pagination is not supported for the search engine or there are no more pages to
8687
be retrieved.
8788

8889
```js
89-
const page1 = await getJson("google", { q: "coffee", start: 15 });
90+
const page1 = await getJson({ engine: "google", q: "coffee", start: 15 });
9091
const page2 = await page1.next?.();
9192
```
9293

docs/migrating_from_google_search_results_nodejs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ migrate over to the `serpapi` npm package.
1717

1818
// ✅ New way, import and use functions directly.
1919
import { getJson } from "serpapi";
20-
getJson("google", { api_key: API_KEY, ... })
20+
getJson({ engine: "google", api_key: API_KEY, ... })
2121
```
2222

2323
- The `search_archive` method is replaced by `getJsonBySearchId` and
@@ -63,15 +63,15 @@ migrate over to the `serpapi` npm package.
6363
engine.json({ q: "coffee", api_key: undefined });
6464

6565
// ✅ Now, no error is thrown when api_key is null
66-
getJson("google", { q: "coffee", api_key: null });
66+
getJson({ engine: "google", q: "coffee", api_key: null });
6767
```
6868

6969
## Added
7070

7171
- TypeScript types for supported parameters.
7272
- First-class Promises support.
7373
```js
74-
const json = await getJson("google", { q: "coffee" });
74+
const json = await getJson({ engine: "google", q: "coffee" });
7575
```
7676
- `config` object to configure global `api_key` and `timeout` values.
7777
```js
@@ -81,6 +81,6 @@ migrate over to the `serpapi` npm package.
8181
```
8282
- Error classes (`MissingApiKeyError` and `InvalidTimeoutError`).
8383
```js
84-
getJson("google", { api_key: "" }); // Throws `MissingApiKeyError`
84+
getJson({ engine: "google", api_key: "" }); // Throws `MissingApiKeyError`
8585
getAccount({ api_key: API_KEY, timeout: 0 }); // Throws `InvalidTimeoutError`
8686
```

0 commit comments

Comments
 (0)