synoppy 1.0.0 → 1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -2
  3. data/lib/synoppy.rb +27 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65693e5a2c5e7bef8b207227c4d606efb03adeff7780cee0963d145b5eeebb32
4
- data.tar.gz: a4e650761ee1432f0c49e3dd9de39bcbf469c224ee28b792891f1e8d16a735bc
3
+ metadata.gz: 1d9a80fac3891cb8133f9cffbc7097d6160999fa7e36b39343ede041e2aa8956
4
+ data.tar.gz: e91fbe09040f73b89c4533452cd6ddfa551e15bd01d66d1ab084dc571ef3cfbd
5
5
  SHA512:
6
- metadata.gz: 34f4c23fdd06970a58d5d57c7b78409bacc1e29050edfb2fe1de44c84fd9e6cb6e18b0b335d91a3a51e803182de6a7b8427f231b5eeff864828ed5b2ff2b304e
7
- data.tar.gz: 2966d35ea34895a70f7079d2e1a1480de70cbbc603113846b786f05cd49208969f52eec971cc27c770169841c8a40226be5edc1e95ee1533b2bf04d0d7591f01
6
+ metadata.gz: a74f7f2ec4e4c75e90c843aa8775f8ab85f7eb89da746d00ea7e837ba114a0fa02870b2a9f99f7bc4ae555d86393adf02cef9807314f3ee11f06d0a9dfed09da
7
+ data.tar.gz: f5545ca85edaa51aa2035582528f3d03ff6388e04c7c89c61469cf09252256a026c25f7134617c97326d6c0fe1cf2a6f30b1ba9416757ca9c21b72246e7eb131
data/README.md CHANGED
@@ -98,9 +98,20 @@ m["source"] # "sitemap" | "links"
98
98
  m["domain"]
99
99
  ```
100
100
 
101
- ### `extract(url, prompt:)`
101
+ ### `search(query, ...)`
102
102
 
103
- `POST /api/extract`. AI-structured JSON extraction (requires a key). `instruction:` is accepted as an alias for `prompt:`.
103
+ `POST /api/search`. Search the live web ranked results with clean source URLs (requires a key).
104
+
105
+ ```ruby
106
+ found = client.search("best open-weight LLMs 2026", max_results: 5, markdown: true)
107
+ found["results"] # [{ "title", "url", "snippet", "markdown"? }]
108
+ found["count"]
109
+ # Also: include_domains:, exclude_domains:, fanout:
110
+ ```
111
+
112
+ ### `extract(url, prompt:, schema:)`
113
+
114
+ `POST /api/extract`. AI-structured JSON extraction (requires a key). `instruction:` is accepted as an alias for `prompt:`; pass `schema:` (a JSON Schema as a Hash) to constrain the output to that exact shape (typed output).
104
115
 
105
116
  ```ruby
106
117
  result = client.extract("https://news.ycombinator.com", prompt: "Return { title, summary, topics }")
@@ -109,6 +120,13 @@ result["model"]
109
120
  result["metadata"]
110
121
  result["truncated"]
111
122
  result["usage"] # { "inputTokens", "outputTokens" }
123
+
124
+ # Typed output — data matches the schema exactly
125
+ typed = client.extract("https://stripe.com/pricing", schema: {
126
+ type: "object",
127
+ properties: { plans: { type: "array", items: { type: "object",
128
+ properties: { name: { type: "string" }, price: { type: "string" } } } } }
129
+ })
112
130
  ```
113
131
 
114
132
  ### `classify(url, labels:)`
data/lib/synoppy.rb CHANGED
@@ -6,7 +6,7 @@ require "uri"
6
6
 
7
7
  # Official Ruby SDK for the Synoppy web-data API.
8
8
  module Synoppy
9
- VERSION = "1.0.0"
9
+ VERSION = "1.1.1"
10
10
  DEFAULT_BASE_URL = "https://synoppy.com"
11
11
 
12
12
  # Raised when the API returns an error response.
@@ -93,13 +93,16 @@ module Synoppy
93
93
  #
94
94
  # prompt: natural-language instruction describing the JSON to return.
95
95
  # `instruction:` is accepted as an alias for `prompt:`.
96
+ # schema: optional JSON Schema (a Hash) to constrain the output shape.
97
+ # When provided, `data` conforms to it.
96
98
  #
97
99
  # Returns { success, url, model, data, metadata, truncated,
98
100
  # usage:{ inputTokens, outputTokens }, latencyMs, creditsUsed, creditsRemaining }.
99
- def extract(url, prompt: nil, instruction: nil)
101
+ def extract(url, prompt: nil, instruction: nil, schema: nil)
100
102
  body = { url: url }
101
103
  prompt ||= instruction
102
104
  body[:prompt] = prompt unless prompt.nil?
105
+ body[:schema] = schema unless schema.nil?
103
106
  request("/api/extract", body)
104
107
  end
105
108
 
@@ -146,6 +149,28 @@ module Synoppy
146
149
  request("/api/images", { url: url })
147
150
  end
148
151
 
152
+ # Web search -> clean, ranked results (requires a key).
153
+ #
154
+ # query : the search query (required).
155
+ # max_results : number of results to return (1-15).
156
+ # markdown : also read each result to clean markdown, in one trip (boolean).
157
+ # include_domains: only return results from these domains (array of strings).
158
+ # exclude_domains: never return results from these domains (array of strings).
159
+ # fanout : expand the query into variations for higher recall (boolean,
160
+ # costs more).
161
+ #
162
+ # Returns { success, query, results:[{ title, url, snippet, markdown? }],
163
+ # latencyMs, creditsUsed, creditsRemaining }.
164
+ def search(query, max_results: nil, markdown: nil, include_domains: nil, exclude_domains: nil, fanout: nil)
165
+ body = { query: query }
166
+ body[:maxResults] = max_results unless max_results.nil?
167
+ body[:markdown] = markdown unless markdown.nil?
168
+ body[:includeDomains] = include_domains unless include_domains.nil?
169
+ body[:excludeDomains] = exclude_domains unless exclude_domains.nil?
170
+ body[:fanout] = fanout unless fanout.nil?
171
+ request("/api/search", body)
172
+ end
173
+
149
174
  # Take actions on a page (click, type, navigate). Coming soon —
150
175
  # /api/act is not live yet.
151
176
  def act(*)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synoppy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saanora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-21 00:00:00.000000000 Z
11
+ date: 2026-07-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Scrape, screenshot, crawl, map, extract, classify, enrich, and images
14
14
  — one key for the whole web.