outscraper 0.3.4 → 0.3.6
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 +123 -0
- data/lib/outscraper/version.rb +1 -1
- data/lib/outscraper.rb +88 -0
- 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: 36bc03b48faddd06287b3c11a0c457a80412221cc752e19834419b66791eb83b
|
|
4
|
+
data.tar.gz: 2d46d01a94f94ffd1cbd39d8718ecf6c31172ae9a274f9380f365295a5115454
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c359daeb150ec3e8c527b3d1e25cde39decf289215f17d47707089ca0d4e61de61a2ae8e837686bd3521e22f44c9746b5d0a73454dc3bf5ee4b6ddc06fa076e4
|
|
7
|
+
data.tar.gz: 715e674806c05bf2daf94f153b5c30c04639b4a6452178b82adb361cddca5c8e97d32783b5dc72f78569f541149f8ed2099fca624f75381346736c9363c433fb
|
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,123 @@
|
|
|
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
|
+
### Iterate through all results (auto-pagination)
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
items = client.businessesIterSearch(
|
|
102
|
+
filters: {
|
|
103
|
+
country_code: "US",
|
|
104
|
+
states: ["NY"],
|
|
105
|
+
business_statuses: ["operational"]
|
|
106
|
+
},
|
|
107
|
+
limit: 100,
|
|
108
|
+
fields: ["name", "phone", "address", "rating", "reviews"]
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
puts items.length
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Get business details by ID
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
business = client.businessesGet(
|
|
118
|
+
"YOUR_BUSINESS_ID",
|
|
119
|
+
fields: ["name", "phone", "website", "address", "rating", "reviews"]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
puts business
|
|
123
|
+
```
|
data/lib/outscraper/version.rb
CHANGED
data/lib/outscraper.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "httparty"
|
|
4
|
+
require "cgi"
|
|
5
|
+
require "json"
|
|
4
6
|
|
|
5
7
|
require_relative "outscraper/version"
|
|
6
8
|
|
|
@@ -391,5 +393,91 @@ module Outscraper
|
|
|
391
393
|
webhook: webhook
|
|
392
394
|
}).parsed_response['data']
|
|
393
395
|
end
|
|
396
|
+
|
|
397
|
+
def postAPIRequest(path, parameters = {})
|
|
398
|
+
payload = parameters || {}
|
|
399
|
+
|
|
400
|
+
response = self.class.post(
|
|
401
|
+
path,
|
|
402
|
+
headers: { 'Content-Type' => 'application/json' },
|
|
403
|
+
body: payload.to_json
|
|
404
|
+
).parsed_response
|
|
405
|
+
|
|
406
|
+
response.is_a?(Hash) && response.key?('data') ? response['data'] : response
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def businessesSearch(
|
|
410
|
+
filters: {},
|
|
411
|
+
limit: 10,
|
|
412
|
+
include_total: false,
|
|
413
|
+
cursor: nil,
|
|
414
|
+
fields: nil,
|
|
415
|
+
async_request: false,
|
|
416
|
+
ui: false,
|
|
417
|
+
webhook: nil,
|
|
418
|
+
query: nil
|
|
419
|
+
)
|
|
420
|
+
payload = {
|
|
421
|
+
filters: (filters || {}),
|
|
422
|
+
limit: limit,
|
|
423
|
+
include_total: include_total,
|
|
424
|
+
cursor: cursor,
|
|
425
|
+
fields: fields ? Array(fields) : nil,
|
|
426
|
+
query: query,
|
|
427
|
+
async: async_request,
|
|
428
|
+
ui: ui,
|
|
429
|
+
webhook: webhook
|
|
430
|
+
}.compact
|
|
431
|
+
|
|
432
|
+
postAPIRequest('/businesses', payload)
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
def businessesIterSearch(filters: {}, limit: 10, fields: nil, include_total: false)
|
|
436
|
+
cursor = nil
|
|
437
|
+
all_items = []
|
|
438
|
+
|
|
439
|
+
loop do
|
|
440
|
+
page = businessesSearch(
|
|
441
|
+
filters: filters,
|
|
442
|
+
limit: limit,
|
|
443
|
+
include_total: include_total,
|
|
444
|
+
cursor: cursor,
|
|
445
|
+
fields: fields,
|
|
446
|
+
async_request: false
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
items = page.is_a?(Hash) ? (page['items'] || []) : []
|
|
450
|
+
break if !items.is_a?(Array) || items.empty?
|
|
451
|
+
|
|
452
|
+
all_items.concat(items)
|
|
453
|
+
|
|
454
|
+
has_more = !!(page['has_more'])
|
|
455
|
+
next_cursor = page['next_cursor']
|
|
456
|
+
break if !has_more || next_cursor.nil? || next_cursor.to_s.strip.empty?
|
|
457
|
+
|
|
458
|
+
cursor = next_cursor.to_s
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
all_items
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def businessesGet(business_id, fields: nil, async_request: false, ui: false, webhook: nil)
|
|
465
|
+
raise ArgumentError, 'business_id is required' if business_id.nil? || business_id.to_s.strip.empty?
|
|
466
|
+
|
|
467
|
+
fields_param =
|
|
468
|
+
if fields.is_a?(Array)
|
|
469
|
+
fields.map(&:to_s).join(',')
|
|
470
|
+
else
|
|
471
|
+
fields
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
response = self.class.get("/businesses/#{CGI.escape(business_id.to_s)}", query: {
|
|
475
|
+
fields: fields_param,
|
|
476
|
+
async: async_request,
|
|
477
|
+
ui: ui,
|
|
478
|
+
webhook: webhook
|
|
479
|
+
}.compact).parsed_response
|
|
480
|
+
response.is_a?(Hash) && response.key?('data') ? response['data'] : response
|
|
481
|
+
end
|
|
394
482
|
end
|
|
395
483
|
end
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Outscraper
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-20 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
|