Backend API
Return a list of products.
Arguments
Supports filtering a single by a single top-level category with id, or also supports an array of categories and their sub-categories. For an array, notate category IDs within brackets: categories: [ ...ids ].
Filters keyed by ID, each with a value or array of values. price takes [min, max] and matches price, or sale_price on sale products. stock_status takes statuses such as in_stock. category takes category IDs or slugs. Any other ID matches that product attribute's values.
Expand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Returns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
Include one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.
The page number of results to return given the specified or default limit.
A text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
Expression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
An object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
Applies each product's price rules to the results. Set to true, a quantity, or an object with quantity, account_id or account_group, and optionally purchase_option, variant_id and options, to price each product as a cart item would be. price becomes the sale price or the lowest matching price rule, orig_price holds the price it replaces, prices keeps only the rules for the account group, and purchase options, plans and expanded variants are priced the same way.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/products', {
where: { active: true },
limit: 25,
page: 1,
});
Response
{
"count": 51,
"results": [
{
"id": "5ca24abb9c077817e5fe2b36",
"active": true,
"attributes": {},
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"delivery": "shipment",
"description": null,
"images": [],
"meta_description": null,
"meta_title": null,
"name": "T-Shirt",
"options": [],
"price": 9.99,
"slug": "swell-t-shirt",
"stock_level": 0,
"stock_status": "available",
"stock_tracking": true,
"tags": [],
"type": "standard"
},
{...},
{...}
],
"page": 1,
"page_count": 3,
"limit": 25,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"3": {
"start": 51,
"end": 51
}
}
}