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.
By default, you can make API calls if you are an authenticated user with the
To make a request to the API, set a Bearer Authentication header with the Spree API key:
curl --header "Authorization: Bearer <key>" http://yourstore.com/api/products/1
Note that for Solidus versions 2.7 and below a custom
X-Spree-Token: <key> header is used.
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.
401and no content.
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.
/api/productsrequest) are paginated and display 25 records per page by default.
You can customize the responses from the API in two ways:
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.