Solidus's REST API (the
) is designed to let you
access data contained within your store.
The API uses a standard read/write interface that returns JSON. This means that you can easily create third-party applications that can consume your Solidus store data. The API is implemented using controllers and Jbuilder views.
It is also possible to build more sophisticated middleware applications that bridge between your store and a warehouse or inventory system.
Make an API call
By default, you can make API calls if you are an authenticated user with the
To make a request to the API, pass a
X-Spree-Token header and a Spree API key
along with the request:
curl --header "X-Spree-Token: <key>" http://yourstore.com/api/products/1
Alternatively, you can pass through the token as a URL parameter if you are unable to pass it through a header:
token parameter allows the request to assume the same level of permissions
as the actual user to whom the token belongs.
Any user with a
admin has an API key generated for them when
their account is created.You can get the key value from the user table's
For example, if you use the
Spree::User model provided by the
, you can access the user's API
key in your Rails console with a command like this:
Store administrators can view or regenerate API keys from the
interface from the Users page by editing a user with the admin role.
The Solidus API endpoints comply with the following rules:
GETrequests always return a status of
UPDATErequests result a status of
DELETErequests return a status of
204and no content.
- Unauthorized requests return a status of
401and no content.
- When a resource cannot be found, the API returns a status of
UPDATErequests return a status of
422with a hash containing an
errorkey and an
errorsvalue contains all of the ActiveRecord validation errors encountered when saving the record.
- Requests that list collections (like an
/api/productsrequest) are paginated and display 25 records per page by default.
You can customize the responses from the API in two ways:
- Override a view from the
- Provide a new view with your custom template in your application.
For example, if you wanted to override the default
template, you could
place a file with the same path and file name in your application. In this case,
your custom template should be created at the path
Solidus is an open source platform supported by the community. We encourage everyone using Solius to contribute back to the documentation and the code.