1. Get Storefront Token
Open Shopify Admin
Settings → Apps and sales channels → Develop apps
Create App
Create an app → Name it “Shoppy”
Configure Storefront API
Configuration → Storefront API integration → ConfigureEnable scopes:
unauthenticated_read_product_listings
unauthenticated_read_collection_listings
unauthenticated_read_customers
unauthenticated_write_customers
unauthenticated_read_customer_tags
Get Token
API credentials → Install app → Copy Storefront API access token
Use the Storefront token, not Admin. Storefront tokens are safe for
client-side use.
2. Add Script
<script src="https://cdn.shoppy.azwedo.com"></script>
3. Initialize
shoppy.init({
token: 'your-storefront-access-token',
storeDomain: 'your-store.myshopify.com'
})
4. Query Data
// List products
const { items } = await shoppy.products.list()
// Products from collection
const { items } = await shoppy.products.collection('sale').list()
// Single product
const product = await shoppy.products.get('product-handle')
// With options
const { items } = await shoppy.products
.limit(12)
.select(['title', 'handle', 'priceRange', 'featuredImage'])
.list()
5. Customer Authentication
// Initialize customer session on page load
const customer = await shoppy.customer.init()
// Login
const customer = await shoppy.customer.login('[email protected]', 'password')
// Register new customer
const customer = await shoppy.customer.register({
email: '[email protected]',
password: 'password123',
firstName: 'John',
lastName: 'Doe'
})
// Get order history
const { orders } = await shoppy.customer.orders()
// Logout
await shoppy.customer.logout()
Next