Skip to main content
This page documents API v2, which Spree 5 and earlier serve. Spree 6, the current version, serves the Store API and the Admin API instead. To move a client over, see Migrating from Storefront API v2.
Spree APIs allow you to fetch multiple associated resources in one API call, both for singular resources and collections, eg. we can fetch a Product with all of its variants and images:
This will return a JSON response with data[relationships] node (links to what resources connects to which) and included node (images and variants JSON responses). This way you can easily control what resources you want to include in the response and avoid making multiple API calls.

Nested resources

You can also nest resources, eg. fetching Product Variants with their Option Values:

Open source libraries to transform JSONApi to a flat JSON response

As you probably noticed the JSON response can sometimes be quite big and hard to follow. To ease working with included resources we recommend checking out one of the open-source libraries that can help deserialize responses.