/spree-commerce:spree-legacy-api-v2from spree-commerce
Helps maintain and migrate from Spree's legacy v2 APIs (Storefront and Platform), including Doorkeeper OAuth2 auth flows and the spree_legacy_api_v2 gem for v5.4+ compatibility.
Ships in spree-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch live docs:
app/controllers/spree/api/v2/.API v2 was the canonical Spree API across v4.x and v5.0–5.3. Two surfaces:
| API | Path | Auth | Audience |
|---|---|---|---|
| Storefront API | /api/v2/storefront/* | Doorkeeper password grant + publishable X-Spree-Order-Token | Customer-facing |
| Platform API | /api/v2/platform/* | Doorkeeper client_credentials grant + admin scope | Admin/operations |
Style: JSON:API 1.0 — { data: { id, type, attributes, relationships } } envelope.
spree umbrella through v5.3.spree_legacy_api_v2 gem from v5.4+ — not in the umbrella by default.Apps built between 2020 and 2025 use v2. The gem keeps those clients working while you migrate to v3.
# Gemfile
gem 'spree_legacy_api_v2'
# Then
bundle install
bin/rails g spree_legacy_api_v2:install # if a generator is shipped — verify
Mounts /api/v2/storefront/* and /api/v2/platform/*.
Password grant (verify current OAuth2 grant types accepted):
POST /spree_oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=password&[email protected]&password=...
Response:
{ "access_token": "...", "token_type": "Bearer", "expires_in": 7200, "refresh_token": "..." }
For guest carts, use X-Spree-Order-Token header. Some v2 endpoints accept anonymous access with just an order token.
Client credentials grant with admin scope:
POST /spree_oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=...&client_secret=...&scope=admin
Doorkeeper applications are managed in admin → Settings → OAuth Applications.
{
"data": {
"id": "1",
"type": "product",
"attributes": {
"name": "Classic Tee",
"description": "100% cotton",
"created-at": "2025-04-15T10:00:00Z",
"price": "19.99"
},
"relationships": {
"variants": { "data": [{ "id": "2", "type": "variant" }] },
"default-variant": { "data": { "id": "2", "type": "variant" } }
}
},
"included": [
{ "id": "2", "type": "variant", "attributes": { ... } }
]
}
Compare with v3's flat JSON — different fundamental shape.
GET /api/v2/storefront/products?include=default_variant,images&fields[product]=name,price
include pulls related resources into included; fields[type] filters attributes per type.
JSON:API style:
GET /api/v2/storefront/products?page=2&per_page=25
Returns links.first, links.next, links.prev, links.last + meta.total_count, meta.total_pages.
GET /api/v2/platform/orders?filter[state]=complete&filter[created_at_gteq]=2025-01-01
Filters use Ransack syntax (_eq, _gteq, _lteq, _in, _not_eq, etc.). Powerful but verbose.
{
"errors": [
{
"status": "422",
"code": "invalid_email",
"title": "Invalid email",
"detail": "Email is not valid",
"source": { "pointer": "/data/attributes/email" }
}
]
}
Always v3 unless:
In v5.4+, gem-installing spree_legacy_api_v2 mounts v2 endpoints without conflict — v3 lives at /api/v3/, v2 at /api/v2/. Same Doorkeeper applications can serve both.
require 'net/http'
require 'json'
# Get a token
res = Net::HTTP.post(
URI('https://your-spree.com/spree_oauth/token'),
{ grant_type: 'password', username: email, password: pwd }.to_query,
'Content-Type' => 'application/x-www-form-urlencoded'
)
token = JSON.parse(res.body)['access_token']
# Use it
req = Net::HTTP::Get.new('/api/v2/storefront/account')
req['Authorization'] = "Bearer #{token}"
res = Net::HTTP.post(
URI('https://your-spree.com/spree_oauth/token'),
{ grant_type: 'client_credentials',
client_id: ENV['CLIENT_ID'],
client_secret: ENV['CLIENT_SECRET'],
scope: 'admin' }.to_query,
'Content-Type' => 'application/x-www-form-urlencoded'
)
admin_token = JSON.parse(res.body)['access_token']
Field-level changes:
| v2 (JSON:API) | v3 (flat JSON) |
|---|---|
data.id ("1") | id ("prod_…") |
data.attributes.name | name |
data.attributes.created-at (kebab) | created_at (snake) |
data.relationships.variants.data[] | variants (array of IDs) |
included[] | inline via ?expand= |
| OAuth2 password grant | Publishable key + JWT |
| OAuth2 client_credentials + admin | Per-user API key OR OAuth2 |
Migration strategy:
spree_legacy_api_v2 in v5.4+ — your v2 clients silently 404.include — relationships still show as null references; you need to also include them.ransackable_attributes per model in production.Always cross-check the legacy gem's README for the Spree version it currently supports — the gem can lag the umbrella by minor releases.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin spree-commerce22 skills in this plugin
/spree-admin-customizationCustomize the Spree v5 Admin Dashboard — Tailwind 4 + Hotwire/Turbo/Stimulus stack, the `Spree.admin.navigation` declarative API (v5.2+) for menu items, partial injection slots (`store_nav_partials`, `store_products_nav_partials`, `store_orders_nav_partials`, `settings_nav_partials`), the Admin SDK components + form builder, custom dashboard reports, the Page Builder for storefront editing, and theme management. Use when adding admin pages, injecting UI into existing screens, or building admin extensions./spree-api-v3Build with Spree's v3 APIs (v5.4+) — Store API at `/api/v3/store/*` (publishable key + per-user JWT, customer-facing) and Admin API at `/api/v3/admin/*` (per-user API keys + OAuth2 Doorkeeper, admin/operations). Covers the flat-JSON Stripe-like envelope, `?expand=` / `?include=` parameters, prefixed IDs (`prod_…`, `ord_…`), OpenAPI 3.0 spec, rate limiting, idempotency, and migration from v2 JSON:API. Use when building API clients, SDKs, or extending API endpoints in a Spree v5.4+ deployment./spree-catalogBuild and customize Spree's catalog — Products with Variants and OptionTypes/OptionValues, Taxonomies and Taxons (nested set), Properties, Images via ActiveStorage, multi-currency Prices, the v5.3+ PriceList feature for customer/segment overrides, MeiliSearch faceted search (v5.4+), product archiving/activation, CSV import/export, and SEO. Use when modeling products, customizing the catalog UI, indexing search, or importing inventory.Other plugins' skills for the same job