serqo 0.1.0 → 0.1.1
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 +19 -2
- data/lib/serqo.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b1f6dfc22dfeca951912e2a15cba7ab9c9edb20642aa0c1fed0a389262f0d33
|
|
4
|
+
data.tar.gz: f377dbaa075e2027b66a753e881971866ac6327f5718f443dca83cdd1e5eec7f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a045e3a7d592d0304a6838e14de39bf757bc055e398630a2a805f89b17d48dad958227d7cd7a975db6f686f1b6a48e7784c9a4515291748244413d6de8c9c56
|
|
7
|
+
data.tar.gz: 0ec273a69b9560614c0e7f0ccc3e66ea7c99884fd3b6dc9f7474dda1183726462b308940a967537d2ba60ffa7933276f22f279bb070f7d09e89d2fe038918233
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Serqo Ruby SDK
|
|
2
2
|
|
|
3
|
-
Official Ruby client for the Serqo Search API.
|
|
3
|
+
Official Ruby client for the [Serqo Search API](https://serqo.io). Serqo provides real-time, low-latency Google, Bing, Baidu, and multi-engine SERP data. New accounts get 100 free requests on [serqo.io](https://serqo.io).
|
|
4
|
+
|
|
5
|
+
Requires Ruby 3.1 or later and uses the standard library without external dependencies.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -14,6 +16,8 @@ gem install serqo
|
|
|
14
16
|
require "serqo"
|
|
15
17
|
|
|
16
18
|
client = Serqo::Client.new(api_key: ENV.fetch("SERQO_API_KEY"))
|
|
19
|
+
|
|
20
|
+
# Web Search
|
|
17
21
|
response = client.search({
|
|
18
22
|
"q" => "espresso machines",
|
|
19
23
|
"engine" => "google",
|
|
@@ -24,6 +28,18 @@ response = client.search({
|
|
|
24
28
|
|
|
25
29
|
puts response.dig("data", "results")
|
|
26
30
|
puts "Request ID: #{response.fetch('requestId')}"
|
|
31
|
+
|
|
32
|
+
# Autocomplete / Search Suggestions
|
|
33
|
+
suggestions = client.autocomplete({
|
|
34
|
+
"q" => "artificial intell",
|
|
35
|
+
"engine" => "google",
|
|
36
|
+
"gl" => "us",
|
|
37
|
+
"hl" => "en"
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
suggestions.dig("data", "suggestions")&.each do |item|
|
|
41
|
+
puts item["text"]
|
|
42
|
+
end
|
|
27
43
|
```
|
|
28
44
|
|
|
29
45
|
Keep the API key in server-side configuration. Methods return the full response envelope as hashes.
|
|
@@ -31,7 +47,8 @@ Keep the API key in server-side configuration. Methods return the full response
|
|
|
31
47
|
## Methods and errors
|
|
32
48
|
|
|
33
49
|
- `search(query, idempotency_key: nil)` sends `POST /v1/search`.
|
|
50
|
+
- `autocomplete(query, idempotency_key: nil)` sends `POST /v1/autocomplete` for real-time query suggestions or expansion.
|
|
34
51
|
- `engines`, `me`, and `health` call the corresponding endpoints.
|
|
35
52
|
- API failures raise `Serqo::Error` with `status`, `code`, `request_id`, `retryable`, `retry_after_ms`, and `details`.
|
|
36
53
|
- The client never retries searches automatically. Reuse an idempotency key only with identical parameters.
|
|
37
|
-
- See the [shared API reference](API.md) for all search parameters, response fields, and pagination behavior.
|
|
54
|
+
- See the [Serqo API Documentation](https://serqo.io/docs) and [shared API reference](API.md) for all search parameters, response fields, and pagination behavior.
|
data/lib/serqo.rb
CHANGED
|
@@ -42,6 +42,13 @@ module Serqo
|
|
|
42
42
|
request("POST", "/v1/search", body: query, headers: headers)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# Fetch real-time search suggestions or run multi-round keyword expansion.
|
|
46
|
+
def autocomplete(query, idempotency_key: nil)
|
|
47
|
+
headers = {}
|
|
48
|
+
headers["Idempotency-Key"] = idempotency_key if idempotency_key
|
|
49
|
+
request("POST", "/v1/autocomplete", body: query, headers: headers)
|
|
50
|
+
end
|
|
51
|
+
|
|
45
52
|
# Return the current engine and search-type capability list.
|
|
46
53
|
def engines
|
|
47
54
|
request("GET", "/v1/engines")
|