You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* `persistent` → Keep socket connection open to save on SSL handshake / reconnection (2x faster). [Search at scale](#Search-At-Scale)
35
+
* `async` → Support non-blocking job submission. [Search Asynchronous](#Search-Asynchronous)
36
+
* extensive documentation → easy to follow
37
+
* real world examples → included throughout
39
38
40
39
## Installation
41
40
42
-
To achieve optimal performance, it is essential to have Ruby 3.x (preferably version 3.4) installed.
41
+
To achieve optimal performance, it is essential to have Ruby 3.1+ (preferably version 3.4) installed.
43
42
44
43
| Older versions such as Ruby 1.9, 2.x, and JRuby are compatible with [serpapi older library](https://github.com/serpapi/google-search-results-ruby), which continues to function effectively.
45
44
@@ -67,8 +66,12 @@ pp results
67
66
This example runs a search for "coffee" on Google. It then returns the results as a regular Ruby Hash.
68
67
See the [playground](https://serpapi.com/playground) to generate your own code.
69
68
70
-
The `SERPAPI_KEY` should be replaced with your actual API key obtained from
71
-
https://serpapi.com/users/sign_up?plan=free.
69
+
The SerpApi key can be obtained from [serpapi.com/signup](https://serpapi.com/users/sign_up?plan=free).
70
+
71
+
Environment variables are a secure, safe, and easy way to manage secrets.
72
+
Set `export SERPAPI_KEY=<secret_serpapi_key>` in your shell.
73
+
Ruby accesses these variables from `ENV['SERPAPI_KEY']`.
74
+
72
75
73
76
## Search API advanced Usage
74
77
@@ -80,10 +83,10 @@ require 'serpapi'
80
83
client = SerpApi::Client.new(
81
84
engine: 'google',
82
85
api_key: ENV['SERPAPI_KEY'],
83
-
# HTTP client behavior
84
-
async: false, # non blocking HTTP request see [Search Asynchronous](#Search-Asynchronous)
85
-
persistent: true, # leave socket connection open for faster response time [Search at scale](#Search-At-Scale)
86
-
timeout: 5, # HTTP timeout in seconds on the client side only.
0 commit comments