shopsavvy-sdk 1.4.0 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 991ec78b558c31d845cf0bf81fd057034062700a72d9fe629501f43e9b7396d5
4
- data.tar.gz: fa4240edb2b6dd071cf70f74464dc691f310e0e083f21dc1c4f3053e548c22c7
3
+ metadata.gz: 1a5a482fa31fc11f8a776aff0f6c483468cfeb77afda4fde8889c7f0784baf09
4
+ data.tar.gz: 791841851c5b762f03d7d769caa3b1f808880e06db2a40d44320c128de2055cf
5
5
  SHA512:
6
- metadata.gz: 8fda9e5b4b3ce912020aa3d65e4d42d2491b88b5836c33d4bc4d5eb25e52e3ff5b775bc2db938bfbc1a1030d6a64d30c5b751b31d9b251a1faa48c17bb16f47c
7
- data.tar.gz: 8aeab34d7762693bf05a998f2a600c90390cf6dd097290dc5fab273e089a4df3953d5efe8755103eaff4df66dfdb8720adb573d2d10033551088b7dddb766370
6
+ metadata.gz: e228f45b8dc2c3686bd6a18b395b22896a6506fb4f02b586dba88ceb7bf605da94b19caebd97704e5f9509f8d8780a2ca8cc758ee1e7267ff66b8f6bab9040b1
7
+ data.tar.gz: 2dd4903ac9a490729e1dee436016a3c7a9ef5deb657b2392599523336daa311244808b977dd9cbb25f875b1692bb0ac0f27c7fd8a1b4e7ad1ad5cd271fb534ef
data/AGENTS.md ADDED
@@ -0,0 +1,64 @@
1
+ # AGENTS.md
2
+
3
+ Context for coding agents (Claude Code, Codex, Cursor, Copilot and others) working in this repository. Humans: see README.md and CONTRIBUTING.md if present.
4
+
5
+ ## Overview
6
+
7
+ The official SDK for the [ShopSavvy Data API](https://shopsavvy.com/data) in Ruby (2.6+). It wraps the REST API at `https://api.shopsavvy.com/v1`: look up products by barcode (UPC/EAN/ISBN), ASIN, URL, model number or MPN, and get current retailer offers, price history, scheduled refreshes and usage.
8
+
9
+ - Package: `shopsavvy-sdk` on RubyGems. Install: `gem install shopsavvy-sdk`
10
+ - API docs: https://shopsavvy.com/data/documentation
11
+ - OpenAPI spec (the contract this SDK follows): https://api.shopsavvy.com/v1/openapi.json
12
+ - Error codes: https://shopsavvy.com/data/documentation/errors
13
+ - This is one of 10 official SDKs (Python, TypeScript, Go, Rust, Java, Kotlin, Swift, PHP, Ruby, C#). They track the same API, so a new endpoint or field lands in all of them.
14
+
15
+ ## Layout
16
+
17
+ - `lib/shopsavvy_data_api/client.rb`: the client (Faraday)
18
+ - `lib/shopsavvy_data_api/models.rb`: response models
19
+ - `lib/shopsavvy_data_api/errors.rb`: error types
20
+ - `lib/shopsavvy_data_api/version.rb`: `VERSION`
21
+ - `spec/` + `spec/fixtures/`: RSpec suite
22
+ - `test_api.rb`: optional live smoke test, reads `SHOPSAVVY_API_KEY` from the environment
23
+ - `CHANGELOG.md`
24
+
25
+ ## Commands
26
+
27
+ ```bash
28
+ # setup
29
+ bundle install
30
+
31
+ # test (offline, no API key needed)
32
+ bundle exec rspec
33
+
34
+ # lint / build checks
35
+ bundle exec rubocop
36
+ ```
37
+
38
+ ## Code conventions
39
+
40
+ - Serialized field names (JSON tags, annotations, CodingKeys, model attributes) match the API JSON exactly (`shopsavvy`, `barcode`, `amazon`, `model`, `mpn`, `offers`, `retailer`, `price`, `availability`, `timestamp`, `history`, `meta.credits_used`, `meta.credits_remaining`, `meta.rate_limit_remaining`). Add a friendlier alias only alongside the real name, never instead of it.
41
+ - Identifiers go in the `ids` query parameter, comma-separated, up to 100 per request (`id` for reviews). The API does not read `barcode=`, `upc=` or `asin=`.
42
+ - `availability` is `"in"` or `"out"` and is absent when unknown. Treat absent as unknown, never as in stock. `currency` on a history point can be null; never assume USD for it.
43
+ - Map errors from `error_detail.code` (`ERR_AUTH_MISSING`, `ERR_RATE_LIMIT`, `ERR_CREDITS_EXHAUSTED`, ...), not from the HTTP status: two different codes share 429. Surface `Retry-After` on `ERR_RATE_LIMIT`. Implemented in `client.rb` (`build_api_error`) and `errors.rb`: every non-2xx raises `APIError` (or `AuthenticationError`, `NotFoundError`, `ValidationError`, `RateLimitError`, `CreditsExhaustedError`) with `status_code`, `code`, `action`, `docs_url`, `request_id`, `retry_after_seconds`. `CreditsExhaustedError` is not a `RateLimitError`.
44
+ - Authenticate with `Authorization: Bearer <key>`. Examples and docs read the key from the `SHOPSAVVY_API_KEY` environment variable.
45
+ - Predicate helpers like `in_stock?` must match the API values (`availability` is `"in"` or `"out"`).
46
+ - Version lives in `lib/shopsavvy_data_api/version.rb` plus a `CHANGELOG.md` entry. Bump it in the same change as any public API change.
47
+
48
+ ## Testing
49
+
50
+ - Unit tests must run offline: mock HTTP and use recorded fixtures. Use obviously fake keys (`ss_test_...`).
51
+ - Specs stub HTTP with fixture keys like `ss_test_fixturekey123`.
52
+ - Live check (optional, costs credits): `SHOPSAVVY_API_KEY=... ruby test_api.rb`.
53
+ - When adding an endpoint or field, add a fixture copied from a real response shape in the API docs or OpenAPI spec, and a test that parses it.
54
+ - Run the full test command above before committing.
55
+
56
+ ## What NOT to do
57
+
58
+ - **Never commit an API key, token or password.** Not in code, tests, examples, fixtures, `.env` files or build config. This repo is public. Publishing credentials (registry tokens, signing passwords) stay on the maintainer's machine. If you find one in the tree, remove it and tell a maintainer so it can be rotated.
59
+ - Never hardcode a key in an example; use `SHOPSAVVY_API_KEY`.
60
+ - Don't invent endpoints, parameters or response fields. If it isn't in the API docs or OpenAPI spec, it doesn't exist yet.
61
+ - Don't put plan prices, plan names, dollar amounts or credit costs in the README; link to https://shopsavvy.com/data and https://shopsavvy.com/data/documentation instead.
62
+ - Don't add claims about scale, uptime or customers (no "99.9% uptime", "trusted by", retailer or product counts). The approved wording is "tens of thousands of retailers" and "30M+ products".
63
+ - Don't publish a release (RubyGems) from an agent session. Prepare the version bump and changelog; a maintainer publishes.
64
+ - Don't change public method names or signatures without a deprecation path; other people's code depends on them.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to the `shopsavvy-sdk` gem are recorded here.
4
4
 
5
+ ## 1.6.0 - 2026-11-17
6
+
7
+ ### Added
8
+ - Every API error now carries `code`, `action`, `docs_url`, `request_id`, `status_code` and `retry_after_seconds` (parsed from the `Retry-After` header), read from the API's `error_detail` object.
9
+ - `CreditsExhaustedError` for `ERR_CREDITS_EXHAUSTED`.
10
+ - README section "Errors, rate limits and credits".
11
+
12
+ ### Changed
13
+ - Credits exhausted (`ERR_CREDITS_EXHAUSTED`, HTTP 429) is no longer raised as `RateLimitError`. Code that rescued every 429 as `RateLimitError` and retried should retry only `RateLimitError` and stop on `CreditsExhaustedError`. A 429 without a code (older server) is still a `RateLimitError`.
14
+ - Error messages are the API's own `error` text when the response has one (the old fixed strings remain only when it does not). HTTP 400 now raises `ValidationError` (422 still does).
15
+ - README quick start reads the key from `SHOPSAVVY_API_KEY` and prints the cheapest offer for a real barcode.
16
+
17
+ ## 1.5.0 - 2026-11-09
18
+
19
+ ### Added
20
+ - `in_store_prices` (user-collected receipt prices) on current offers and batch results.
21
+
5
22
  ## 1.4.0
6
23
 
7
24
  ### Changed (breaking for `get_price_history` callers)
data/CLAUDE.md ADDED
@@ -0,0 +1,5 @@
1
+ # CLAUDE.md
2
+
3
+ Instructions for Claude Code live in [AGENTS.md](AGENTS.md), shared with other coding agents.
4
+
5
+ @AGENTS.md
data/README.md CHANGED
@@ -5,19 +5,53 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![Documentation](https://img.shields.io/badge/docs-shopsavvy.com-blue)](https://shopsavvy.com/data/documentation)
7
7
 
8
- Official Ruby SDK for the [ShopSavvy Data API](https://shopsavvy.com/data). Access comprehensive product data, real-time pricing, and historical price trends across **thousands of retailers** and **millions of products**.
8
+ Official Ruby SDK for the [ShopSavvy Data API](https://shopsavvy.com/data). Access comprehensive product data, real-time pricing, and historical price trends across **tens of thousands of retailers** and **30M+ products**.
9
9
 
10
10
  ## ⚡ 30-Second Quick Start
11
11
 
12
- ```ruby
13
- # Install
12
+ ```bash
14
13
  gem install shopsavvy-sdk
14
+ export SHOPSAVVY_API_KEY=ss_live_... # get a key at shopsavvy.com/data/api-keys after starting a plan
15
+ ```
15
16
 
16
- # Use
17
+ ```ruby
17
18
  require 'shopsavvy_data_api'
18
- client = ShopsavvyDataApi.new(api_key: 'ss_live_your_api_key_here')
19
- product = client.get_product_details('012345678901')
20
- puts "#{product.data.name} - Best price: $#{client.get_current_offers('012345678901').data.min_by(&:price).price}"
19
+
20
+ client = ShopsavvyDataApi.new(api_key: ENV.fetch('SHOPSAVVY_API_KEY'))
21
+
22
+ # Keurig K-Mini, looked up by barcode
23
+ product = client.get_current_offers('611247373064').data.first
24
+ cheapest = product.offers.select(&:price).min_by(&:price)
25
+ puts "Cheapest: #{cheapest.price} #{cheapest.currency} at #{cheapest.retailer}"
26
+ ```
27
+
28
+ ## Errors, rate limits and credits
29
+
30
+ Every API error is raised as an `APIError` (or a subclass: `AuthenticationError`, `NotFoundError`,
31
+ `ValidationError`, `RateLimitError`, `CreditsExhaustedError`). Each carries `message` (the API's `error` text),
32
+ `status_code`, `code`, `action`, `docs_url`, `request_id` and `retry_after_seconds`. Rescue the class or branch on
33
+ `code`, not on the HTTP status: a rate limit and exhausted credits both arrive as HTTP 429.
34
+
35
+ - `RateLimitError` (`ERR_RATE_LIMIT`): wait `retry_after_seconds`, then retry.
36
+ - `CreditsExhaustedError` (`ERR_CREDITS_EXHAUSTED`): do not retry. Credits return when the billing period resets or the plan is upgraded. It is not a `RateLimitError`.
37
+
38
+ ```ruby
39
+ require 'shopsavvy_data_api'
40
+
41
+ client = ShopsavvyDataApi.new(api_key: ENV.fetch('SHOPSAVVY_API_KEY'))
42
+
43
+ begin
44
+ result = client.get_current_offers('611247373064')
45
+ rescue ShopsavvyDataApi::RateLimitError => e
46
+ sleep(e.retry_after_seconds || 1)
47
+ result = client.get_current_offers('611247373064') # retry once
48
+ rescue ShopsavvyDataApi::CreditsExhaustedError
49
+ puts 'Credits are used up. Retrying will not help; wait for the reset or upgrade the plan.'
50
+ rescue ShopsavvyDataApi::APIError => e
51
+ puts "#{e.code}: #{e.message}"
52
+ puts "Fix: #{e.action}"
53
+ puts "Docs: #{e.docs_url}"
54
+ end
21
55
  ```
22
56
 
23
57
  ## 🚀 Installation & Setup
@@ -36,9 +70,9 @@ gem install shopsavvy-sdk
36
70
 
37
71
  ### Get Your API Key
38
72
 
39
- 1. **Sign up**: Visit [shopsavvy.com/data](https://shopsavvy.com/data)
73
+ 1. **Start a plan**: Visit [shopsavvy.com/data](https://shopsavvy.com/data)
40
74
  2. **Choose plan**: Select based on your usage needs
41
- 3. **Get API key**: Copy from your dashboard
75
+ 3. **Get API key**: Create one at [shopsavvy.com/data/api-keys](https://shopsavvy.com/data/api-keys)
42
76
  4. **Test**: Run the 30-second example above
43
77
 
44
78
  ### Environment Setup
@@ -101,7 +135,7 @@ puts "Description: #{product.data.description}" if product.data.description
101
135
 
102
136
  #### Bulk Product Lookup
103
137
  ```ruby
104
- # Process up to 100 products at once (Pro plan)
138
+ # Process up to 100 products per request
105
139
  identifiers = [
106
140
  "012345678901", "B08N5WRWNW", "045496590048",
107
141
  "https://www.bestbuy.com/site/product/123456",
@@ -364,6 +398,17 @@ puts "Usage: #{usage.data.credits_percentage_used}%"
364
398
  puts "Billing period: #{usage.data.billing_period_start} to #{usage.data.billing_period_end}"
365
399
  ```
366
400
 
401
+ ### In-Store Prices (user-collected)
402
+
403
+ Each product from the current-offers call also carries `in_store_prices`: shelf prices physical stores charged, read from receipts ShopSavvy app users scanned. Every entry is labeled `source: "user-collected"` and has the retailer, the store's address and coordinates, the price and the receipt date (`observed_on`). It is a price on that day, not current stock, and says nothing about the shopper. Empty when none are on file.
404
+
405
+ ```ruby
406
+ result = client.get_current_offers("011110838360")
407
+ result.data.first.in_store_prices.each do |in_store|
408
+ puts "#{in_store.retailer} (#{in_store.address}): $#{in_store.price} on #{in_store.observed_on}"
409
+ end
410
+ ```
411
+
367
412
  ## 🔧 Advanced Usage
368
413
 
369
414
  ### Error Handling
@@ -916,6 +961,9 @@ end
916
961
  ## 📚 Additional Resources
917
962
 
918
963
  - **[ShopSavvy Data API Documentation](https://shopsavvy.com/data/documentation)** - Complete API reference
964
+ - **[Postman Collection](https://shopsavvy.com/templates/data-api-postman-collection)** - Every endpoint, ready to import
965
+ - **[API Evaluation Checklist](https://shopsavvy.com/templates/product-data-api-evaluation-checklist)** - Free template for comparing product data APIs
966
+ - **[Free UPC Lookup](https://shopsavvy.com/tools/upc-lookup)** - Look up any barcode in the browser, no code
919
967
  - **[API Dashboard](https://shopsavvy.com/data/dashboard)** - Manage your API keys and usage
920
968
  - **[GitHub Repository](https://github.com/shopsavvy/sdk-ruby)** - Source code and issues
921
969
  - **[RubyGems Page](https://rubygems.org/gems/shopsavvy-sdk)** - Gem releases and stats
@@ -935,24 +983,18 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
935
983
 
936
984
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
937
985
 
938
- ## 🏢 About ShopSavvy
986
+ ## About ShopSavvy
939
987
 
940
- **ShopSavvy** is the world's first mobile shopping app, helping consumers find the best deals since 2008. With over **40 million downloads** and millions of active users, ShopSavvy has saved consumers billions of dollars.
988
+ ShopSavvy has been comparing prices since 2008, and the app has 40M+ downloads. The ShopSavvy Data API serves the same product and price data over REST: send a barcode (UPC/EAN/ISBN), ASIN, product URL, model number or MPN, and get back the product record, current offers from tens of thousands of retailers, and price history back to 2011 (dense from 2019).
941
989
 
942
- ### Our Data API Powers:
943
- - 🛒 **E-commerce platforms** with competitive intelligence
944
- - 📊 **Market research** with real-time pricing data
945
- - 🏪 **Retailers** with inventory and pricing optimization
946
- - 📱 **Mobile apps** with product lookup and price comparison
947
- - 🤖 **Business intelligence** with automated price monitoring
990
+ - **Lookup by any identifier**: barcode, ASIN, URL, model number, MPN or ShopSavvy ID, up to 100 per request
991
+ - **Current offers**: price, availability, condition, seller and when each offer was last seen
992
+ - **Price history**: quality-filtered price points per retailer over any date range
993
+ - **Scheduled refreshes**: hourly, daily or weekly re-checks for the products you care about, at retailers that can be re-checked through an official retailer API (others update as ShopSavvy sees them)
994
+ - **JSON or CSV** responses, with credits used and remaining on every response
995
+ - **Open-source SDKs in 10 languages**: Python, TypeScript, Go, Rust, Java, Kotlin, Swift, PHP, Ruby and C#
948
996
 
949
- ### Why Choose ShopSavvy Data API?
950
- - ✅ **Trusted by millions** - Proven at scale since 2008
951
- - ✅ **Comprehensive coverage** - 1000+ retailers, millions of products
952
- - ✅ **Real-time accuracy** - Fresh data updated continuously
953
- - ✅ **Developer-friendly** - Easy integration, great documentation
954
- - ✅ **Reliable infrastructure** - 99.9% uptime, enterprise-grade
955
- - ✅ **Flexible pricing** - Plans for every use case and budget
997
+ Plans and the 14-day trial are at [shopsavvy.com/data](https://shopsavvy.com/data); full reference at [shopsavvy.com/data/documentation](https://shopsavvy.com/data/documentation).
956
998
 
957
999
  ---
958
1000
 
@@ -8,7 +8,7 @@ module ShopsavvyDataApi
8
8
  # Official Ruby client for ShopSavvy Data API
9
9
  #
10
10
  # Provides access to product data, pricing information, and price history
11
- # across thousands of retailers and millions of products.
11
+ # across tens of thousands of retailers and 30M+ products.
12
12
  #
13
13
  # @example Basic usage
14
14
  # client = ShopsavvyDataApi::Client.new(api_key: "ss_live_your_api_key_here")
@@ -359,46 +359,48 @@ module ShopsavvyDataApi
359
359
  end
360
360
 
361
361
  def handle_response(response)
362
- case response.status
363
- when 200..299
364
- response.body
365
- when 401
366
- raise AuthenticationError.new(
367
- "Authentication failed. Check your API key.",
368
- status_code: response.status,
369
- response_data: response.body
370
- )
371
- when 404
372
- raise NotFoundError.new(
373
- "Resource not found",
374
- status_code: response.status,
375
- response_data: response.body
376
- )
377
- when 422
378
- raise ValidationError.new(
379
- "Request validation failed. Check your parameters.",
380
- status_code: response.status,
381
- response_data: response.body
382
- )
383
- when 429
384
- raise RateLimitError.new(
385
- "Rate limit exceeded. Please slow down your requests.",
386
- status_code: response.status,
387
- response_data: response.body
388
- )
362
+ return response.body if (200..299).cover?(response.status)
363
+
364
+ raise build_api_error(response)
365
+ end
366
+
367
+ # Maps a non-2xx response onto the typed error family, from error_detail.code first.
368
+ def build_api_error(response)
369
+ body = response.body
370
+ data = body.is_a?(Hash) ? body : {}
371
+ detail = data["error_detail"].is_a?(Hash) ? data["error_detail"] : {}
372
+ meta = data["meta"].is_a?(Hash) ? data["meta"] : {}
373
+ code = detail["code"]
374
+ status = response.status
375
+ message = data["error"].is_a?(String) ? data["error"] : nil
376
+ fields = {
377
+ status_code: status,
378
+ response_data: body,
379
+ code: code,
380
+ action: detail["action"],
381
+ docs_url: detail["docs_url"],
382
+ request_id: meta["request_id"],
383
+ retry_after_seconds: parse_retry_after(response.headers["Retry-After"])
384
+ }
385
+
386
+ if code == "ERR_CREDITS_EXHAUSTED"
387
+ CreditsExhaustedError.new(message || "Credits exhausted", **fields)
388
+ elsif code == "ERR_RATE_LIMIT" || (code.nil? && status == 429)
389
+ RateLimitError.new(message || "Rate limit exceeded. Please slow down your requests.", **fields)
390
+ elsif status == 401
391
+ AuthenticationError.new(message || "Authentication failed. Check your API key.", **fields)
392
+ elsif status == 404
393
+ NotFoundError.new(message || "Resource not found", **fields)
394
+ elsif [400, 422].include?(status)
395
+ ValidationError.new(message || "Request validation failed. Check your parameters.", **fields)
389
396
  else
390
- error_message = if response.body.is_a?(Hash) && response.body["error"]
391
- response.body["error"]
392
- else
393
- "HTTP #{response.status}: #{response.reason_phrase}"
394
- end
395
-
396
- raise APIError.new(
397
- error_message,
398
- status_code: response.status,
399
- response_data: response.body
400
- )
397
+ APIError.new(message || "HTTP #{status}: #{response.reason_phrase}", **fields)
401
398
  end
402
399
  end
400
+
401
+ # Retry-After as whole seconds; nil when absent or an HTTP-date.
402
+ def parse_retry_after(value)
403
+ value.to_s.strip =~ /\A\d+\z/ ? value.to_s.strip.to_i : nil
404
+ end
403
405
  end
404
406
  end
@@ -1,30 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopsavvyDataApi
4
- # Base error class for all ShopSavvy API errors
4
+ # Base error class for all ShopSavvy API errors.
5
+ #
6
+ # API errors (APIError and subclasses) carry the API's structured detail. Branch on the
7
+ # class or on +code+, not on +status_code+: ERR_RATE_LIMIT and ERR_CREDITS_EXHAUSTED both
8
+ # arrive as HTTP 429.
5
9
  class Error < StandardError
6
- attr_reader :status_code, :response_data
10
+ # @return [Integer, nil] HTTP status
11
+ attr_reader :status_code
12
+ # @return [Hash, String, nil] decoded response body
13
+ attr_reader :response_data
14
+ # @return [String, nil] error_detail.code, e.g. "ERR_RATE_LIMIT"; nil when the server sent none
15
+ attr_reader :code
16
+ # @return [String, nil] one-line fix from error_detail.action
17
+ attr_reader :action
18
+ # @return [String, nil] link to the documentation for this code
19
+ attr_reader :docs_url
20
+ # @return [String, nil] meta.request_id; quote it in support requests
21
+ attr_reader :request_id
22
+ # @return [Integer, nil] seconds from the Retry-After header; only meaningful for ERR_RATE_LIMIT
23
+ attr_reader :retry_after_seconds
7
24
 
8
- def initialize(message, status_code: nil, response_data: nil)
25
+ # rubocop:disable Metrics/ParameterLists
26
+ def initialize(message, status_code: nil, response_data: nil, code: nil, action: nil,
27
+ docs_url: nil, request_id: nil, retry_after_seconds: nil)
9
28
  super(message)
10
29
  @status_code = status_code
11
30
  @response_data = response_data
31
+ @code = code
32
+ @action = action
33
+ @docs_url = docs_url
34
+ @request_id = request_id
35
+ @retry_after_seconds = retry_after_seconds
12
36
  end
37
+ # rubocop:enable Metrics/ParameterLists
13
38
  end
14
39
 
15
40
  # API-related errors
16
41
  class APIError < Error; end
17
42
 
18
- # Authentication failed (invalid API key, etc.)
43
+ # Authentication failed (ERR_AUTH_MISSING / ERR_AUTH_INVALID / ERR_AUTH_REVOKED, HTTP 401)
19
44
  class AuthenticationError < APIError; end
20
45
 
21
- # Rate limit exceeded
46
+ # ERR_RATE_LIMIT, or a 429 with no code (older server): wait retry_after_seconds, then retry
22
47
  class RateLimitError < APIError; end
23
48
 
24
- # Resource not found (product, etc.)
49
+ # ERR_CREDITS_EXHAUSTED (HTTP 429): do NOT retry. Credits come back when the billing period
50
+ # resets or the plan is upgraded. Deliberately not a RateLimitError.
51
+ class CreditsExhaustedError < APIError; end
52
+
53
+ # Resource not found (ERR_PRODUCT_NOT_FOUND / ERR_ENDPOINT_NOT_FOUND, HTTP 404)
25
54
  class NotFoundError < APIError; end
26
55
 
27
- # Request validation failed
56
+ # Request validation failed (ERR_INVALID_PARAMS / ERR_IDENTIFIER_REQUIRED, HTTP 400)
28
57
  class ValidationError < APIError; end
29
58
 
30
59
  # Request timeout
@@ -114,15 +114,50 @@ module ShopsavvyDataApi
114
114
 
115
115
  # Product with nested offers (returned by offers endpoint)
116
116
  class ProductWithOffers < ProductDetails
117
- attr_reader :offers
117
+ attr_reader :offers, :in_store_prices
118
118
 
119
119
  def initialize(data)
120
120
  super(data)
121
121
  @offers = (data["offers"] || []).map { |offer| Offer.new(offer) }
122
+ # User-collected shelf prices read from shoppers' scanned receipts (empty when none).
123
+ @in_store_prices = (data["in_store_prices"] || []).map { |in_store| InStorePrice.new(in_store) }
122
124
  end
123
125
 
124
126
  def to_h
125
- super.merge(offers: offers.map(&:to_h))
127
+ super.merge(offers: offers.map(&:to_h), in_store_prices: in_store_prices.map(&:to_h))
128
+ end
129
+ end
130
+
131
+ # A shelf price a physical store charged on a given day, read from a shopper's scanned
132
+ # receipt. `source` is always "user-collected". It says what the store sold the product for
133
+ # that day, not that it is in stock now; nothing about the shopper is included.
134
+ class InStorePrice
135
+ attr_reader :source, :retailer, :address, :latitude, :longitude, :price, :currency,
136
+ :observed_on, :timestamp
137
+
138
+ def initialize(data)
139
+ store = data["store"] || {}
140
+ @source = data["source"]
141
+ @retailer = data["retailer"]
142
+ @address = store["address"]
143
+ @latitude = store["latitude"]&.to_f
144
+ @longitude = store["longitude"]&.to_f
145
+ @price = data["price"]&.to_f
146
+ @currency = data["currency"]
147
+ @observed_on = data["observed_on"]
148
+ @timestamp = data["timestamp"]
149
+ end
150
+
151
+ def to_h
152
+ {
153
+ source: source,
154
+ retailer: retailer,
155
+ store: { address: address, latitude: latitude, longitude: longitude },
156
+ price: price,
157
+ currency: currency,
158
+ observed_on: observed_on,
159
+ timestamp: timestamp
160
+ }
126
161
  end
127
162
  end
128
163
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopsavvyDataApi
4
- VERSION = "1.4.0"
4
+ VERSION = "1.6.0"
5
5
  end
@@ -9,7 +9,7 @@ require_relative "shopsavvy_data_api/client"
9
9
  #
10
10
  # This gem provides a convenient interface to interact with the ShopSavvy Data API,
11
11
  # allowing you to access product data, pricing information, and price history
12
- # across thousands of retailers and millions of products.
12
+ # across tens of thousands of retailers and 30M+ products.
13
13
  #
14
14
  # @example Basic usage
15
15
  # client = ShopsavvyDataApi.new(api_key: "ss_live_your_api_key_here")
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["business@shopsavvy.com"]
10
10
 
11
11
  spec.summary = "Official Ruby SDK for ShopSavvy Data API"
12
- spec.description = "Access product data, pricing, and price history across thousands of retailers and millions of products with the ShopSavvy Data API."
12
+ spec.description = "Access product data, pricing, and price history across tens of thousands of retailers and 30M+ products with the ShopSavvy Data API."
13
13
  spec.homepage = "https://shopsavvy.com/data"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.6.0"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopsavvy-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShopSavvy by Monolith Technologies, Inc.
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-09-28 00:00:00.000000000 Z
10
+ date: 2026-11-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday
@@ -163,15 +163,17 @@ dependencies:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0.9'
166
- description: Access product data, pricing, and price history across thousands of retailers
167
- and millions of products with the ShopSavvy Data API.
166
+ description: Access product data, pricing, and price history across tens of thousands
167
+ of retailers and 30M+ products with the ShopSavvy Data API.
168
168
  email:
169
169
  - business@shopsavvy.com
170
170
  executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
+ - AGENTS.md
174
175
  - CHANGELOG.md
176
+ - CLAUDE.md
175
177
  - CONTRIBUTING.md
176
178
  - LICENSE
177
179
  - README.md