
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
swell-storefront
Advanced tools
Client-side applications can use the Swell Storefront API to retrieve public data including products, shopping carts, and account information.
npm install swell-storefront --save
Basic example:
import swell from 'swell-storefront';
swell.auth('my-store', 'pk_...');
swell.products.get({
category: 't-shirts',
limit: 25,
page: 1,
}).then((products) => {
console.log(products);
});
swell.products.get({
limit: 25,
page: 1,
});
swell.products.get({
category: 't-shirts',
limit: 25,
page: 1,
});
swell.products.get({
search: 'blue jeans',
limit: 25,
page: 1,
});
swell.products.get('5c15505200c7d14d851e510f');
swell.products.get('pink-shoes');
swell.products.get('pink-shoes', {
expand: ['variants'],
});
swell.categories.get({
limit: 25,
page: 1,
});
swell.categories.get('mens-shoes');
swell.categories.get('5c15505200c7d14d851e510f');
This request will return null if nothing has been added to the cart yet.
swell.cart.get();
This request will return null if nothing has been added to the cart yet.
swell.cart.addItem({
product_id: '5c15505200c7d14d851e510f',
quantity: 1,
options: [{
id: 'color',
value: 'Blue',
}],
});
swell.cart.updateItem('5c15505200c7d14d851e510f', {
quantity: 2,
});
swell.cart.updateItems([{
quantity: 2,
}, {
quantity: 3,
}, {
quantity: 4,
}]);
swell.cart.removeItem('5c15505200c7d14d851e510f');
swell.cart.removeItems();
This is typically used with an abandoned cart recovery email. Your email may have a link to your store with a checkout_id identifying the cart that was abandoned. Making this request will add the cart to the current session and mark it as recovered.
swell.cart.recover('878663b2fb4175b128e40de428cd7b0c');
If the email/password is correct, the account will be added to the session and make other related endpoints available to the client.
swell.account.login('customer@example.com', 'password');
This will remove the account from the current session and shopping cart.
swell.account.logout();
swell.account.get();
swell.account.create({
email: 'customer@example.com',
first_name: 'John',
last_name: 'Doe',
email_optin: true,
});
swell.account.update({
email: 'updated@example.com',
first_name: 'Jane',
last_name: 'Doe',
email_optin: false,
});
swell.account.recover({
email: 'customer@example.com',
});
swell.account.recover({
reset_key: '...',
password: 'new password',
});
swell.account.getAddresses();
swell.account.createAddress({
name: 'Ship to name',
address1: '...',
address2: '...',
city: '...',
state: '...',
zip: '...',
country: '...',
phone: '...',
});
swell.account.deleteAddress('5c15505200c7d14d851e510f');
swell.account.getCards();
Credit card tokens can be created using Schema.js or Stripe.js.
swell.account.createCard({
token: 't_...',
});
swell.account.deleteCard('5c15505200c7d14d851e510f');
FAQs
Swell storefront API for client-side JavaScript
The npm package swell-storefront receives a total of 9 weekly downloads. As such, swell-storefront popularity was classified as not popular.
We found that swell-storefront demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.