Skip to content

Commit 0a80c85

Browse files
authored
Revert removal of Bulk API example
1 parent 7ce5ab1 commit 0a80c85

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,32 @@ pp client.account
153153

154154
It prints your account information.
155155

156+
### Bulk Search API
157+
158+
If you have high volume of searches (e.g., >= 1 million) and they don't need to be live, you can use our Bulk Search API. You just have to use the `async` parameter:
159+
160+
```ruby
161+
client = SerpApi::Client.new api_key: 'secret_api_key', async: true
162+
searches = [
163+
{ engine: "google", q: "coffee" },
164+
{ engine: "google", q: "tea" },
165+
{ engine: "google", q: "hot chocolate milk" },
166+
# ...
167+
]
168+
# Submit async searches
169+
async_searches = searches.map do |search|
170+
async_search = client.search search
171+
async_search
172+
end
173+
# Get an ETA using the last search scheduled time
174+
bulk_search_eta = async_search_results.last[:search_metadata][:scheduled_at]
175+
# After the searches are done processing (i.e., `bulk_search_eta`)
176+
async_search_results = async_searches.map do |search|
177+
results = client.search_archive search[:id]
178+
results
179+
end
180+
```
181+
156182
## Basic example per search engine
157183

158184
### Search bing

0 commit comments

Comments
 (0)