@@ -17,12 +17,39 @@ more.
1717
1818### Node.js
1919
20- Ensure you're running at least Node.js v16.14.
20+ - Supports Node.js 7.10.1 and newer.
21+ - Refer to [ this example] ( examples/node/basic_js_node_7_up ) for help.
2122
2223``` bash
2324npm install serpapi
2425```
2526
27+ ``` js
28+ const { getJson } = require (" serpapi" );
29+ getJson (" google" , {
30+ api_key: API_KEY , // Get your API_KEY from https://serpapi.com/manage-api-key
31+ q: " coffee" ,
32+ location: " Austin, Texas" ,
33+ }, (json ) => {
34+ console .log (json[" organic_results" ]);
35+ });
36+ ```
37+
38+ ### Node.js with ES Modules (ESM) and top-level await
39+
40+ - If you prefer using the ` import ` syntax and top-level ` await ` , you need to use
41+ at least Node.js 14.8.0.
42+ - Refer to [ this example] ( examples/node/basic_js_node_14_up ) for help.
43+
44+ You will need to add ` "type": "module" ` to your ` package.json ` :
45+
46+ ``` js
47+ {
48+ " type" : " module" ,
49+ // rest of package.json
50+ }
51+ ```
52+
2653``` js
2754import { getJson } from " serpapi" ;
2855const response = await getJson (" google" , {
@@ -35,7 +62,9 @@ console.log(response);
3562
3663### Deno
3764
38- Import directly from deno.land. Usage is otherwise the same as above.
65+ - Import directly from deno.land.
66+ - Usage is otherwise the same as above.
67+ - Refer to [ this example] ( examples/deno/basic_ts ) for help.
3968
4069``` ts
4170import { getJson } from " https://deno.land/x/serpapi/mod.ts" ;
0 commit comments