File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,39 @@ await getJson({ engine: "google", q: "coffee" }); // uses the API key defined in
114114await getJson ({ engine: " google" , api_key: API_KEY_2 , q: " coffee" }); // API_KEY_2 will be used
115115```
116116
117+ ### Using a Proxy
118+
119+ You can use a proxy by passing ` requestOptions ` with an ` HttpsProxyAgent `
120+ instance. This can be done either globally through the config object or
121+ per-request in the parameters.
122+
123+ First, install the required package:
124+
125+ ``` bash
126+ npm install https-proxy-agent
127+ ```
128+
129+ Then use it in your code:
130+
131+ ``` js
132+ import { config , getJson } from " serpapi" ;
133+ import { HttpsProxyAgent } from " https-proxy-agent" ;
134+
135+ // Global configuration
136+ config .requestOptions = {
137+ agent: new HttpsProxyAgent (" http://proxy-server:port" ),
138+ };
139+
140+ // Or per-request configuration
141+ await getJson ({
142+ engine: " google" ,
143+ q: " coffee" ,
144+ requestOptions: {
145+ agent: new HttpsProxyAgent (" http://proxy-server:port" ),
146+ },
147+ });
148+ ```
149+
117150## Pagination
118151
119152Built-in pagination is not supported. Please refer to our pagination examples
You can’t perform that action at this time.
0 commit comments