searchapi 1.0.0 → 1.1.0
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 +33 -33
- data/lib/searchapi/error_result.rb +3 -3
- data/lib/searchapi/google_finance_options.rb +1 -1
- data/lib/searchapi/google_finance_request.rb +1 -1
- data/lib/searchapi/google_finance_result.rb +1 -1
- data/lib/searchapi/google_flights_options.rb +1 -1
- data/lib/searchapi/google_flights_request.rb +1 -1
- data/lib/searchapi/google_flights_result.rb +1 -1
- data/lib/searchapi/google_images_options.rb +1 -1
- data/lib/searchapi/google_images_request.rb +1 -1
- data/lib/searchapi/google_images_result.rb +1 -1
- data/lib/searchapi/google_light_options.rb +1 -1
- data/lib/searchapi/google_light_request.rb +1 -1
- data/lib/searchapi/google_light_result.rb +1 -1
- data/lib/searchapi/google_local_options.rb +1 -1
- data/lib/searchapi/google_local_request.rb +1 -1
- data/lib/searchapi/google_local_result.rb +1 -1
- data/lib/searchapi/google_news_light_options.rb +1 -1
- data/lib/searchapi/google_news_light_request.rb +1 -1
- data/lib/searchapi/google_news_light_result.rb +1 -1
- data/lib/searchapi/google_news_options.rb +1 -1
- data/lib/searchapi/google_news_portal_options.rb +1 -1
- data/lib/searchapi/google_news_portal_request.rb +1 -1
- data/lib/searchapi/google_news_portal_result.rb +1 -1
- data/lib/searchapi/google_news_request.rb +1 -1
- data/lib/searchapi/google_news_result.rb +1 -1
- data/lib/searchapi/google_scholar_options.rb +1 -1
- data/lib/searchapi/google_scholar_request.rb +1 -1
- data/lib/searchapi/google_scholar_result.rb +1 -1
- data/lib/searchapi/google_search_options.rb +1 -1
- data/lib/searchapi/google_search_request.rb +1 -1
- data/lib/searchapi/google_search_result.rb +1 -1
- data/lib/searchapi/helpers.rb +1 -1
- data/lib/searchapi/instagram_profile_options.rb +1 -1
- data/lib/searchapi/instagram_profile_request.rb +1 -1
- data/lib/searchapi/instagram_profile_result.rb +1 -1
- data/lib/searchapi/module_methods.rb +1 -1
- data/lib/searchapi/request.rb +4 -4
- data/lib/searchapi/response_methods.rb +1 -1
- data/lib/searchapi/tiktok_profile_options.rb +1 -1
- data/lib/searchapi/tiktok_profile_request.rb +1 -1
- data/lib/searchapi/tiktok_profile_result.rb +1 -1
- data/lib/searchapi/version.rb +2 -2
- data/lib/searchapi/youtube_search_options.rb +1 -1
- data/lib/searchapi/youtube_search_request.rb +1 -1
- data/lib/searchapi/youtube_search_result.rb +1 -1
- data/lib/searchapi.rb +1 -1
- data/searchapi.gemspec +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bade0e59fb4fc3764856d1cd4a5fed0eef7f06c6b5ce512ff4802d9848269154
|
|
4
|
+
data.tar.gz: 5ebb00269d7e4b1c01efe107d4082157b513644352674bde9282de28e6975043
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f39465a4dbcfe4869e45aec36807fa5e4af2ad6ffc4dd9d974982a9f8d65fa1a49347f8a5a1265876003198af0155052426c14ad77da99ceb1afb3255c60c1a
|
|
7
|
+
data.tar.gz: 0fab4b542de5214aeb387bdf0530ca2791667b74c8d21e47322d5341cad1dfdd8f095aad1faa7d9879bdbdf051dc684f971d206b29a70a692fa27d9c080bad6a
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SearchApi Ruby Gem
|
|
2
2
|
|
|
3
|
-
A Ruby client for the [
|
|
3
|
+
A Ruby client for the [SearchApi.io](https://searchapi.io) API, providing access to Google Search, YouTube, Instagram, TikTok, and more.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -21,33 +21,33 @@ gem install searchapi
|
|
|
21
21
|
```ruby
|
|
22
22
|
require 'searchapi'
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
SearchApi.api_key ENV['SEARCH_API_KEY']
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Available APIs
|
|
28
28
|
|
|
29
29
|
| API | Method | Description |
|
|
30
30
|
|-----|--------|-------------|
|
|
31
|
-
| Google Search | `
|
|
32
|
-
| Google Light | `
|
|
33
|
-
| Google News | `
|
|
34
|
-
| Google News Portal | `
|
|
35
|
-
| Google News Light | `
|
|
36
|
-
| Google Images | `
|
|
37
|
-
| Google Local | `
|
|
38
|
-
| Google Scholar | `
|
|
39
|
-
| Google Finance | `
|
|
40
|
-
| Google Flights | `
|
|
41
|
-
| YouTube | `
|
|
42
|
-
| Instagram | `
|
|
43
|
-
| TikTok | `
|
|
31
|
+
| Google Search | `SearchApi.google(query)` | Full Google search with all features |
|
|
32
|
+
| Google Light | `SearchApi.google_light(query)` | Fast, lightweight Google search |
|
|
33
|
+
| Google News | `SearchApi.news(query)` | Google News articles |
|
|
34
|
+
| Google News Portal | `SearchApi.news_portal(query)` | Google News Portal with topics |
|
|
35
|
+
| Google News Light | `SearchApi.news_light(query)` | Fast, lightweight news search |
|
|
36
|
+
| Google Images | `SearchApi.images(query)` | Google Image search |
|
|
37
|
+
| Google Local | `SearchApi.local(query)` | Local business search |
|
|
38
|
+
| Google Scholar | `SearchApi.scholar(query)` | Academic papers and citations |
|
|
39
|
+
| Google Finance | `SearchApi.finance(symbol)` | Stock quotes and financial data |
|
|
40
|
+
| Google Flights | `SearchApi.flights(options)` | Flight search and booking |
|
|
41
|
+
| YouTube | `SearchApi.youtube(query)` | YouTube video search |
|
|
42
|
+
| Instagram | `SearchApi.instagram(username)` | Instagram profile data |
|
|
43
|
+
| TikTok | `SearchApi.tiktok(username)` | TikTok profile data |
|
|
44
44
|
|
|
45
45
|
## Quick Examples
|
|
46
46
|
|
|
47
47
|
### Google Search
|
|
48
48
|
|
|
49
49
|
```ruby
|
|
50
|
-
response =
|
|
50
|
+
response = SearchApi.google('ruby programming')
|
|
51
51
|
response.result.organic_results.each do |result|
|
|
52
52
|
puts "#{ result.title } - #{ result.link }"
|
|
53
53
|
end
|
|
@@ -56,7 +56,7 @@ end
|
|
|
56
56
|
### Google News
|
|
57
57
|
|
|
58
58
|
```ruby
|
|
59
|
-
response =
|
|
59
|
+
response = SearchApi.news('technology', time_period: :last_week)
|
|
60
60
|
response.result.each do |article|
|
|
61
61
|
puts "#{ article.title } (#{ article.source })"
|
|
62
62
|
end
|
|
@@ -65,7 +65,7 @@ end
|
|
|
65
65
|
### Google Images
|
|
66
66
|
|
|
67
67
|
```ruby
|
|
68
|
-
response =
|
|
68
|
+
response = SearchApi.images('sunset', size: :large, color: :orange)
|
|
69
69
|
response.result.each do |image|
|
|
70
70
|
puts "#{ image.title } - #{ image.original.link }"
|
|
71
71
|
end
|
|
@@ -74,28 +74,28 @@ end
|
|
|
74
74
|
### Google Finance
|
|
75
75
|
|
|
76
76
|
```ruby
|
|
77
|
-
response =
|
|
77
|
+
response = SearchApi.finance('AAPL:NASDAQ')
|
|
78
78
|
puts "#{ response.result.summary.title }: $#{ response.result.summary.price }"
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
### Google Flights
|
|
82
82
|
|
|
83
83
|
```ruby
|
|
84
|
-
options =
|
|
84
|
+
options = SearchApi::GoogleFlightsOptions.build do
|
|
85
85
|
departure_id 'JFK'
|
|
86
86
|
arrival_id 'LAX'
|
|
87
87
|
outbound_date '2026-06-15'
|
|
88
88
|
flight_type :one_way
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
response =
|
|
91
|
+
response = SearchApi.flights(options)
|
|
92
92
|
puts "Cheapest: $#{ response.result.cheapest&.price }"
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
### YouTube Search
|
|
96
96
|
|
|
97
97
|
```ruby
|
|
98
|
-
response =
|
|
98
|
+
response = SearchApi.youtube('ruby tutorial')
|
|
99
99
|
response.result.videos.each do |video|
|
|
100
100
|
puts "#{ video.title } by #{ video.channel.title }"
|
|
101
101
|
end
|
|
@@ -105,11 +105,11 @@ end
|
|
|
105
105
|
|
|
106
106
|
```ruby
|
|
107
107
|
# Instagram
|
|
108
|
-
response =
|
|
108
|
+
response = SearchApi.instagram('instagram')
|
|
109
109
|
puts "#{ response.result.profile.username }: #{ response.result.followers } followers"
|
|
110
110
|
|
|
111
111
|
# TikTok
|
|
112
|
-
response =
|
|
112
|
+
response = SearchApi.tiktok('tiktok')
|
|
113
113
|
puts "#{ response.result.profile.name }: #{ response.result.hearts } hearts"
|
|
114
114
|
```
|
|
115
115
|
|
|
@@ -119,25 +119,25 @@ Each API supports options via a block or hash:
|
|
|
119
119
|
|
|
120
120
|
```ruby
|
|
121
121
|
# Block syntax
|
|
122
|
-
options =
|
|
122
|
+
options = SearchApi::GoogleSearchOptions.build do
|
|
123
123
|
device :mobile
|
|
124
124
|
gl 'us'
|
|
125
125
|
hl 'en'
|
|
126
126
|
time_period :last_week
|
|
127
127
|
end
|
|
128
|
-
response =
|
|
128
|
+
response = SearchApi.google('news', options)
|
|
129
129
|
|
|
130
130
|
# Hash syntax
|
|
131
|
-
response =
|
|
131
|
+
response = SearchApi.google('news', { device: :mobile, gl: 'us' })
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
Options are case-insensitive and normalized automatically:
|
|
135
135
|
|
|
136
136
|
```ruby
|
|
137
137
|
# These are equivalent
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
SearchApi::GoogleFinanceOptions.build { window :'1d' } # => '1D'
|
|
139
|
+
SearchApi::GoogleFinanceOptions.build { window :'1D' } # => '1D'
|
|
140
|
+
SearchApi::GoogleFinanceOptions.build { window :MAX } # => 'MAX'
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
## Response Structure
|
|
@@ -145,7 +145,7 @@ SearchAPI::GoogleFinanceOptions.build { window :MAX } # => 'MAX'
|
|
|
145
145
|
All responses return a Faraday response with a `result` accessor:
|
|
146
146
|
|
|
147
147
|
```ruby
|
|
148
|
-
response =
|
|
148
|
+
response = SearchApi.google('test')
|
|
149
149
|
response.success? # HTTP success
|
|
150
150
|
response.result.success? # API success (no error field)
|
|
151
151
|
response.result.search_metadata
|
|
@@ -156,7 +156,7 @@ response.result.organic_results
|
|
|
156
156
|
Results are enumerable where it makes sense:
|
|
157
157
|
|
|
158
158
|
```ruby
|
|
159
|
-
response =
|
|
159
|
+
response = SearchApi.google('ruby')
|
|
160
160
|
response.result.each { |r| puts r.title } # Iterates organic_results
|
|
161
161
|
response.result.first # First organic result
|
|
162
162
|
response.result.count # Number of organic results
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module SearchApi
|
|
2
2
|
class ErrorResult
|
|
3
3
|
|
|
4
4
|
attr_reader :error_type, :error_description
|
|
@@ -39,10 +39,10 @@ module SearchAPI
|
|
|
39
39
|
"The rate limit has been exceeded." ]
|
|
40
40
|
when 500..599
|
|
41
41
|
[ :server_error,
|
|
42
|
-
"The
|
|
42
|
+
"The SearchApi server encountered an error while processing the request." ]
|
|
43
43
|
else
|
|
44
44
|
[ :unknown_error,
|
|
45
|
-
"The
|
|
45
|
+
"The SearchApi service returned an unexpected status code: '#{ status_code }'." ]
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
data/lib/searchapi/helpers.rb
CHANGED
data/lib/searchapi/request.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
module
|
|
1
|
+
module SearchApi
|
|
2
2
|
class Request
|
|
3
3
|
|
|
4
4
|
BASE_URI = 'https://www.searchapi.io/api/v1'
|
|
5
5
|
|
|
6
6
|
def initialize( connection: nil, api_key: nil )
|
|
7
|
-
@connection = connection ||
|
|
8
|
-
@api_key = api_key ||
|
|
7
|
+
@connection = connection || SearchApi.connection
|
|
8
|
+
@api_key = api_key || SearchApi.api_key
|
|
9
9
|
raise ArgumentError,
|
|
10
10
|
"The API key is required but was not provided; configure it using " \
|
|
11
|
-
"'
|
|
11
|
+
"'SearchApi.api_key' or pass it directly." unless @api_key
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
protected
|
data/lib/searchapi/version.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module
|
|
2
|
-
VERSION = '1.
|
|
1
|
+
module SearchApi
|
|
2
|
+
VERSION = '1.1.0'
|
|
3
3
|
end
|
data/lib/searchapi.rb
CHANGED
data/searchapi.gemspec
CHANGED
|
@@ -3,15 +3,15 @@ require_relative 'lib/searchapi/version'
|
|
|
3
3
|
Gem::Specification.new do | spec |
|
|
4
4
|
|
|
5
5
|
spec.name = 'searchapi'
|
|
6
|
-
spec.version =
|
|
6
|
+
spec.version = SearchApi::VERSION
|
|
7
7
|
spec.authors = [ 'Kristoph Cichocki-Romanov' ]
|
|
8
8
|
spec.email = [ 'rubygems.org@kristoph.net' ]
|
|
9
9
|
|
|
10
10
|
spec.summary =
|
|
11
|
-
"A Ruby client for the
|
|
11
|
+
"A Ruby client for the SearchApi.io API, supporting various services including " \
|
|
12
12
|
"Google Search, YouTube, Instagram, and others."
|
|
13
13
|
spec.description =
|
|
14
|
-
"A Ruby client for the
|
|
14
|
+
"A Ruby client for the SearchApi.io API. Supports various services including " \
|
|
15
15
|
"Google Search, YouTube, Instagram, TikTok, Google Finance, Google Flights, " \
|
|
16
16
|
"Google News, Google Images, Google Scholar, and more."
|
|
17
17
|
spec.license = 'MIT'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: searchapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kristoph Cichocki-Romanov
|
|
@@ -79,7 +79,7 @@ dependencies:
|
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
81
|
version: '6.3'
|
|
82
|
-
description: A Ruby client for the
|
|
82
|
+
description: A Ruby client for the SearchApi.io API. Supports various services including
|
|
83
83
|
Google Search, YouTube, Instagram, TikTok, Google Finance, Google Flights, Google
|
|
84
84
|
News, Google Images, Google Scholar, and more.
|
|
85
85
|
email:
|
|
@@ -159,6 +159,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
159
159
|
requirements: []
|
|
160
160
|
rubygems_version: 3.6.7
|
|
161
161
|
specification_version: 4
|
|
162
|
-
summary: A Ruby client for the
|
|
162
|
+
summary: A Ruby client for the SearchApi.io API, supporting various services including
|
|
163
163
|
Google Search, YouTube, Instagram, and others.
|
|
164
164
|
test_files: []
|