outscraper 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/examples/Businesses.md +208 -0
- data/lib/outscraper/version.rb +1 -1
- data/lib/outscraper.rb +85 -14
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97c677370f1667c0a830e12a858fc1aa0a830182c145830205151cbf2a0719a3
|
|
4
|
+
data.tar.gz: 541a28805f574e7ad9d57df8a7d90bb43ee7b03128cc3ca33c45e5d7f0c93a76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f67f131e3546b2628c35679312655d725fb18f9fa905d41030ca7744269b9508dc0f6dcba83d0ab30355ad43b4f7858a9b9209f08cbeada6ac7047bca57a8a32
|
|
7
|
+
data.tar.gz: 5d3d36c762fd24e04266b0bb4249ae9b3183de35bd27a77c39be630ccc2af243d4055d2bdac60a69814f80b7eca812d5be1d51af59a17d646805f517a767ae7a
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@ require 'Outscraper'
|
|
|
22
22
|
|
|
23
23
|
client = Outscraper::Client.new('SECRET_API_KEY')
|
|
24
24
|
```
|
|
25
|
-
[Link to the
|
|
25
|
+
[Link to the account page to create the API key](https://app.outscraper.com/account/api)
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Businesses Search With Ruby
|
|
2
|
+
|
|
3
|
+
The library provides real-time access to business records via the [Outscraper API](https://app.outscraper.com/api-docs).
|
|
4
|
+
It supports classic structured filters and AI-powered plain-text queries for flexible search.
|
|
5
|
+
|
|
6
|
+
- Structured search using `filters`, `fields`, `limit`, and other parameters
|
|
7
|
+
- AI-powered search using the `query` parameter
|
|
8
|
+
- Combined mode where structured params and `query` are merged by the server
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install the gem and add it to the application's Gemfile by executing:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bundle add outscraper
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
gem install outscraper
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
[Link to the Ruby package page](https://rubygems.org/gems/outscraper)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Initialization
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
require "outscraper"
|
|
34
|
+
|
|
35
|
+
client = Outscraper::Client.new("SECRET_API_KEY")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
[Link to the profile page to create the API key](https://app.outscraper.com/profile)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Search businesses with structured filters
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
results = client.businessesSearch(
|
|
48
|
+
filters: {
|
|
49
|
+
country_code: "US",
|
|
50
|
+
states: ["NY"],
|
|
51
|
+
cities: ["New York", "Buffalo"],
|
|
52
|
+
types: ["restaurant", "cafe"],
|
|
53
|
+
has_website: true,
|
|
54
|
+
has_phone: true,
|
|
55
|
+
business_statuses: ["operational"]
|
|
56
|
+
},
|
|
57
|
+
limit: 50,
|
|
58
|
+
include_total: false,
|
|
59
|
+
fields: ["name", "phone", "website", "address", "rating", "reviews"]
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
puts results
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Search businesses with AI plain-text query
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
results = client.businessesSearch(
|
|
69
|
+
query: "Find cafes in New York, NY. Limit 25. Return name, address, phone, website, rating and reviews."
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
puts results
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Combine structured params and plain-text query
|
|
76
|
+
|
|
77
|
+
```ruby
|
|
78
|
+
results = client.businessesSearch(
|
|
79
|
+
filters: {
|
|
80
|
+
country_code: "US",
|
|
81
|
+
states: ["CA"],
|
|
82
|
+
types: ["restaurant"]
|
|
83
|
+
},
|
|
84
|
+
fields: ["name", "phone"],
|
|
85
|
+
limit: 15,
|
|
86
|
+
query: "Add cafes too. Return address and reviews. Limit 20. Include total."
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
puts results
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
When both structured params and `query` are provided:
|
|
93
|
+
|
|
94
|
+
- `filters` and `fields` are merged
|
|
95
|
+
- for `limit`, `cursor`, and `include_total`, plain-text values take priority when present
|
|
96
|
+
- if a value is not specified, API defaults are used
|
|
97
|
+
|
|
98
|
+
### Search businesses with enrichments
|
|
99
|
+
|
|
100
|
+
`enrichments` can be provided in three formats:
|
|
101
|
+
|
|
102
|
+
- **Hash (recommended)** — send a structured object with options per enrichment
|
|
103
|
+
- **Array** — enable enrichments without options
|
|
104
|
+
- **String** — enable a single enrichment without options
|
|
105
|
+
|
|
106
|
+
#### Enrichments as Hash (recommended)
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
results = client.businessesSearch(
|
|
110
|
+
filters: {
|
|
111
|
+
country_code: "US",
|
|
112
|
+
states: ["CA", "NY"],
|
|
113
|
+
types: ["restaurant", "cafe"]
|
|
114
|
+
},
|
|
115
|
+
limit: 10,
|
|
116
|
+
fields: ["name", "phone", "website", "rating", "reviews"],
|
|
117
|
+
enrichments: {
|
|
118
|
+
"contacts_n_leads" => {
|
|
119
|
+
"contacts_per_company" => 4,
|
|
120
|
+
"emails_per_contact" => 2
|
|
121
|
+
},
|
|
122
|
+
"company_insights" => {}
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
puts results
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Enrichments as Array
|
|
130
|
+
|
|
131
|
+
```ruby
|
|
132
|
+
results = client.businessesSearch(
|
|
133
|
+
filters: { country_code: "US", states: ["NY"] },
|
|
134
|
+
limit: 10,
|
|
135
|
+
enrichments: ["contacts_n_leads", "company_insights"]
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
puts results
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Enrichments as String
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
results = client.businessesSearch(
|
|
145
|
+
filters: { country_code: "US", states: ["NY"] },
|
|
146
|
+
limit: 10,
|
|
147
|
+
enrichments: "contacts_n_leads"
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
puts results
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Full JSON-style parameters example
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
params = {
|
|
157
|
+
filters: {
|
|
158
|
+
country_code: "US",
|
|
159
|
+
states: ["CA", "NY"],
|
|
160
|
+
types: ["restaurant", "cafe"]
|
|
161
|
+
},
|
|
162
|
+
limit: 900,
|
|
163
|
+
cursor: nil,
|
|
164
|
+
include_total: false,
|
|
165
|
+
fields: [
|
|
166
|
+
"name", "types", "address", "country", "website",
|
|
167
|
+
"phone", "rating", "reviews"
|
|
168
|
+
],
|
|
169
|
+
enrichments: {
|
|
170
|
+
"contacts_n_leads" => {
|
|
171
|
+
"contacts_per_company" => 4,
|
|
172
|
+
"emails_per_contact" => 2
|
|
173
|
+
},
|
|
174
|
+
"company_insights" => {}
|
|
175
|
+
},
|
|
176
|
+
query: "Find hotels in California and Illinois with rating 4.2+ and status operational. Return fields: name, address, rating and reviews. Limit results to 6. Enrich data with contacts_n_leads. Contact per company set to 8"
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
results = client.businessesSearch(**params)
|
|
180
|
+
puts results
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Iterate through all results (auto-pagination)
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
items = client.businessesIterSearch(
|
|
187
|
+
filters: {
|
|
188
|
+
country_code: "US",
|
|
189
|
+
states: ["NY"],
|
|
190
|
+
business_statuses: ["operational"]
|
|
191
|
+
},
|
|
192
|
+
limit: 100,
|
|
193
|
+
fields: ["name", "phone", "address", "rating", "reviews"]
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
puts items.length
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Get business details by ID
|
|
200
|
+
|
|
201
|
+
```ruby
|
|
202
|
+
business = client.businessesGet(
|
|
203
|
+
"YOUR_BUSINESS_ID",
|
|
204
|
+
fields: ["name", "phone", "website", "address", "rating", "reviews"]
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
puts business
|
|
208
|
+
```
|
data/lib/outscraper/version.rb
CHANGED
data/lib/outscraper.rb
CHANGED
|
@@ -378,7 +378,7 @@ module Outscraper
|
|
|
378
378
|
async: async_request
|
|
379
379
|
}).parsed_response['data']
|
|
380
380
|
end
|
|
381
|
-
|
|
381
|
+
|
|
382
382
|
def yellowpages_search(query, location: 'New York, NY', limit: 100, region: nil, enrichment: [], fields: '', async_request: false, ui: nil, webhook: nil)
|
|
383
383
|
enrichment_array = enrichment.is_a?(Array) ? enrichment : [enrichment]
|
|
384
384
|
response = self.class.get('/yellowpages-search', query: {
|
|
@@ -412,25 +412,92 @@ module Outscraper
|
|
|
412
412
|
include_total: false,
|
|
413
413
|
cursor: nil,
|
|
414
414
|
fields: nil,
|
|
415
|
+
enrichments: nil,
|
|
416
|
+
contacts_per_company: nil,
|
|
417
|
+
emails_per_contact: nil,
|
|
415
418
|
async_request: false,
|
|
416
419
|
ui: false,
|
|
417
|
-
webhook: nil
|
|
420
|
+
webhook: nil,
|
|
421
|
+
query: nil
|
|
418
422
|
)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
423
|
+
if contacts_per_company && contacts_per_company < 1
|
|
424
|
+
raise ArgumentError, 'contacts_per_company must be >= 1'
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
if emails_per_contact && emails_per_contact < 1
|
|
428
|
+
raise ArgumentError, 'emails_per_contact must be >= 1'
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
enrichments_normalized = nil
|
|
432
|
+
|
|
433
|
+
if enrichments.is_a?(Hash)
|
|
434
|
+
enrichments_normalized = enrichments
|
|
435
|
+
elsif enrichments.is_a?(Array)
|
|
436
|
+
enrichments_normalized = enrichments
|
|
437
|
+
elsif enrichments.is_a?(String) || enrichments.is_a?(Symbol)
|
|
438
|
+
enrichments_normalized = enrichments.to_s
|
|
439
|
+
elsif !enrichments.nil?
|
|
440
|
+
enrichments_normalized = Array(enrichments)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
if !contacts_per_company.nil? || !emails_per_contact.nil?
|
|
444
|
+
cpp = contacts_per_company || 3
|
|
445
|
+
epc = emails_per_contact || 1
|
|
446
|
+
|
|
447
|
+
case enrichments_normalized
|
|
448
|
+
when nil
|
|
449
|
+
enrichments_normalized = { 'contacts_n_leads' => { 'contacts_per_company' => cpp, 'emails_per_contact' => epc } }
|
|
450
|
+
when Hash
|
|
451
|
+
enrichments_normalized['contacts_n_leads'] ||= {}
|
|
452
|
+
enrichments_normalized['contacts_n_leads']['contacts_per_company'] = cpp
|
|
453
|
+
enrichments_normalized['contacts_n_leads']['emails_per_contact'] = epc
|
|
454
|
+
when Array
|
|
455
|
+
unless enrichments_normalized.map(&:to_s).include?('contacts_n_leads')
|
|
456
|
+
raise ArgumentError, 'contacts_per_company and emails_per_contact require enrichments to include "contacts_n_leads"'
|
|
457
|
+
end
|
|
458
|
+
# Expand array to object so we can include options
|
|
459
|
+
expanded = {}
|
|
460
|
+
enrichments_normalized.each { |name| expanded[name.to_s] = {} }
|
|
461
|
+
expanded['contacts_n_leads']['contacts_per_company'] = cpp
|
|
462
|
+
expanded['contacts_n_leads']['emails_per_contact'] = epc
|
|
463
|
+
enrichments_normalized = expanded
|
|
464
|
+
when String
|
|
465
|
+
unless enrichments_normalized == 'contacts_n_leads'
|
|
466
|
+
raise ArgumentError, 'contacts_per_company and emails_per_contact require enrichments to include "contacts_n_leads"'
|
|
467
|
+
end
|
|
468
|
+
enrichments_normalized = { 'contacts_n_leads' => { 'contacts_per_company' => cpp, 'emails_per_contact' => epc } }
|
|
469
|
+
else
|
|
470
|
+
raise ArgumentError, 'Invalid enrichments type'
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
payload = {
|
|
475
|
+
filters: (filters || {}),
|
|
476
|
+
limit: limit,
|
|
477
|
+
include_total: include_total,
|
|
478
|
+
cursor: cursor,
|
|
479
|
+
fields: fields ? Array(fields) : nil,
|
|
480
|
+
enrichments: enrichments_normalized,
|
|
481
|
+
query: query,
|
|
482
|
+
async: async_request,
|
|
483
|
+
ui: ui,
|
|
484
|
+
webhook: webhook
|
|
485
|
+
}.compact
|
|
486
|
+
|
|
487
|
+
postAPIRequest('/businesses', payload)
|
|
429
488
|
|
|
430
|
-
postAPIRequest('/businesses', payload)
|
|
431
489
|
end
|
|
432
490
|
|
|
433
|
-
def businessesIterSearch(
|
|
491
|
+
def businessesIterSearch(
|
|
492
|
+
filters: {},
|
|
493
|
+
limit: 10,
|
|
494
|
+
fields: nil,
|
|
495
|
+
include_total: false,
|
|
496
|
+
enrichments: nil,
|
|
497
|
+
contacts_per_company: nil,
|
|
498
|
+
emails_per_contact: nil,
|
|
499
|
+
query: nil
|
|
500
|
+
)
|
|
434
501
|
cursor = nil
|
|
435
502
|
all_items = []
|
|
436
503
|
|
|
@@ -441,6 +508,10 @@ module Outscraper
|
|
|
441
508
|
include_total: include_total,
|
|
442
509
|
cursor: cursor,
|
|
443
510
|
fields: fields,
|
|
511
|
+
enrichments: enrichments,
|
|
512
|
+
contacts_per_company: contacts_per_company,
|
|
513
|
+
emails_per_contact: emails_per_contact,
|
|
514
|
+
query: query,
|
|
444
515
|
async_request: false
|
|
445
516
|
)
|
|
446
517
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: outscraper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Outscraper
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -39,6 +39,7 @@ files:
|
|
|
39
39
|
- LICENSE.txt
|
|
40
40
|
- README.md
|
|
41
41
|
- Rakefile
|
|
42
|
+
- examples/Businesses.md
|
|
42
43
|
- examples/Company Insights.md
|
|
43
44
|
- examples/Company Website Finder.md
|
|
44
45
|
- examples/Contacts And Leads.md
|