Shop API Reference
The Bagisto Shop API provides all necessary endpoints for customer-facing e-commerce operations including product browsing, shopping cart management, and checkout functionality.
Overview
The Shop API is designed for:
- Headless Commerce: Frontend frameworks (React, Vue, Angular, Next.js)
- Mobile Applications: iOS and Android apps
- Third-party Integrations: External marketplace apps
- Progressive Web Apps (PWA): Mobile-web hybrids
Categories
Organize and browse products by category.
Get Category Tree
Retrieve the hierarchical category structure.
query {
treeCategories(parentId: 1) {
id
position
status
displayMode
logoUrl
bannerUrl
translation {
name
slug
urlPath
metaTitle
metaDescription
metaKeywords
}
children {
edges {
node {
id
position
status
translation { name slug }
children {
edges {
node {
id
translation { name slug }
}
}
}
}
}
}
}
}Parameters:
parentId: Parent category ID (default: 1 for root)
Response Example:
{
"data": {
"treeCategories": {
"id": "1",
"position": 0,
"status": true,
"translation": {
"name": "Root",
"slug": "root",
"urlPath": ""
},
"children": {
"edges": [
{
"node": {
"id": "2",
"position": 1,
"translation": {
"name": "Electronics",
"slug": "electronics"
},
"children": {
"edges": [
{
"node": {
"id": "3",
"translation": {
"name": "Smartphones",
"slug": "smartphones"
}
}
}
]
}
}
}
]
}
}
}
}Get Products by Category
query {
products(
channel: "default"
categoryId: 2
first: 20
filters: {
status: [1]
}
) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
cursor
node {
id
name
sku
description
shortDescription
price
productFlat {
id
url
new
featured
status
}
}
}
}
}Products
Browse, search, and filter products with advanced capabilities.
Get All Products
query {
products(
channel: "default"
first: 50
after: "cursor"
) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
name
sku
type
shortDescription
description
price
cost
status
weight
images {
edges {
node {
id
type
path
url
}
}
}
videos {
edges {
node {
id
type
path
url
}
}
}
attributes {
edges {
node {
id
code
label
value
}
}
}
productFlat {
id
url
metaTitle
metaDescription
metaKeywords
new
featured
status
}
}
}
}
}Get Product by ID
query {
product(id: "1") {
id
name
sku
type
description
shortDescription
price
cost
weight
status
created_at
updated_at
images {
edges {
node {
id
url
alt
type
}
}
}
attributes {
edges {
node {
id
code
label
value
}
}
}
reviews {
pageInfo { hasNextPage }
edges {
node {
id
title
rating
comment
customerName
createdAt
}
}
}
}
}Get Product by SKU
query {
productBySkU(sku: "PROD-001") {
id
name
sku
description
price
availability
status
}
}Get Product by URL Key
query {
productByUrl(url: "awesome-product-name") {
id
name
sku
description
price
productFlat {
url
metaTitle
metaDescription
}
}
}Search Products
query {
products(
channel: "default"
search: "laptop"
first: 20
) {
edges {
node {
id
name
sku
price
description
}
}
}
}Filter & Sort Products
query {
products(
channel: "default"
first: 20
sort: "name"
order: "DESC"
filters: {
price: { from: 100, to: 500 }
status: [1]
brand: ["Apple", "Samsung"]
rating: { from: 4 }
}
) {
edges {
node {
id
name
price
rating {
rate
count
}
}
}
}
}Available Sorting Options:
name: Product name A-Zprice: Price ascendingrating: Customer ratingsnewest: Recently addedpopularity: Most viewed
Available Filters:
search: Text searchprice: Price rangestatus: Product statusbrand: Brand filterrating: Star rating
Get Configurable Products
For products with multiple variants (e.g., size, color).
query {
product(id: "1") {
id
name
type
variants {
edges {
node {
id
sku
price
weight
images {
edges {
node { url }
}
}
attributes {
edges {
node {
code
value
}
}
}
}
}
}
superAttributes {
edges {
node {
id
code
label
options {
edges {
node {
id
label
value
}
}
}
}
}
}
}
}Get Product Attributes
query {
attribute(code: "color") {
id
code
label
type
options {
edges {
node {
id
label
value
swatchValue
}
}
}
}
}Shopping Cart
Manage shopping cart operations for both guest and authenticated customers.
Create Cart
For Guest Users:
mutation {
createCartToken(input: {}) {
cartToken
}
}For Authenticated Customers:
mutation {
createCart(input: {}) {
cart {
id
itemsCount
itemsQty
grandTotal
}
}
}Add Product to Cart
mutation {
addProductsToCart(input: {
cartId: "your-cart-id"
items: [
{
productId: "1"
quantity: 2
superAttributeSelection: {
color: "red"
size: "L"
}
}
]
}) {
cart {
id
itemsCount
items {
edges {
node {
id
productId
quantity
product {
id
name
price
}
}
}
}
}
}
}Update Cart Item
mutation {
updateCart(input: {
cartId: "your-cart-id"
items: [
{
cartItemId: "1"
quantity: 5
}
]
}) {
cart {
id
itemsCount
items {
edges {
node {
id
quantity
}
}
}
}
}
}Remove Item from Cart
mutation {
removeCartItem(input: {
cartId: "your-cart-id"
cartItemId: "1"
}) {
cart {
id
itemsCount
items {
edges {
node { id }
}
}
}
}
}Get Cart
query {
cart(id: "your-cart-id") {
id
itemsCount
itemsQty
grandTotal
subtotal
taxTotal
shippingTotal
discountAmount
couponCode
items {
edges {
node {
id
productId
quantity
basePrice
totalPrice
product {
id
name
sku
images {
edges {
node { url }
}
}
}
}
}
}
address {
firstName
lastName
address
city
state
country
zipCode
}
}
}Apply Coupon
mutation {
applyCoupon(input: {
cartId: "your-cart-id"
couponCode: "SUMMER2024"
}) {
cart {
id
couponCode
discountAmount
grandTotal
}
}
}Remove Coupon
mutation {
removeCoupon(input: {
cartId: "your-cart-id"
}) {
cart {
id
couponCode
discountAmount
grandTotal
}
}
}Estimate Shipping
mutation {
estimateShipping(input: {
cartId: "your-cart-id"
country: "US"
state: "CA"
zipCode: "90210"
}) {
shippingMethods {
edges {
node {
id
code
title
description
price
basePrice
}
}
}
}
}Move to Wishlist
mutation {
moveToWishlist(input: {
cartId: "your-cart-id"
cartItemId: "1"
}) {
status
message
}
}Checkout
Complete the checkout process and create orders.
Save Address
mutation {
saveCustomerAddress(input: {
firstName: "John"
lastName: "Doe"
email: "[email protected]"
address: "123 Main Street"
city: "New York"
country: "US"
state: "NY"
zipCode: "10001"
phoneNumber: "2125551234"
defaultAddress: true
}) {
address {
id
firstName
lastName
address
city
state
country
zipCode
}
}
}Set Shipping Method
mutation {
saveShippingMethod(input: {
cartId: "your-cart-id"
shippingMethodCode: "flatrate_flatrate"
}) {
cart {
id
shippingMethodCode
shippingTotal
grandTotal
}
}
}Get Payment Methods
query {
paymentMethods(cartId: "your-cart-id") {
edges {
node {
code
title
description
image
sortOrder
}
}
}
}Save Payment Method
mutation {
savePaymentMethod(input: {
cartId: "your-cart-id"
method: "paypal"
}) {
status
message
}
}Create Order
For Authenticated Customers:
mutation {
createOrder(input: {
cartId: "your-cart-id"
billingAddressId: "1"
shippingAddressId: "1"
shippingMethod: "flatrate_flatrate"
paymentMethod: "paypal"
}) {
order {
id
incrementId
status
grandTotal
shippingTotal
taxTotal
discountAmount
createdAt
items {
edges {
node {
id
productId
quantity
price
}
}
}
}
}
}For Guest Users:
mutation {
createGuestOrder(input: {
cartId: "your-cart-id"
billingAddress: {
firstName: "John"
lastName: "Doe"
email: "[email protected]"
address: "123 Main Street"
city: "New York"
country: "US"
state: "NY"
zipCode: "10001"
phoneNumber: "2125551234"
}
shippingMethod: "flatrate_flatrate"
paymentMethod: "paypal"
}) {
order {
id
incrementId
status
grandTotal
createdAt
}
}
}Customers
Manage customer profiles and accounts.
Customer Registration
mutation {
createCustomer(input: {
firstName: "John"
lastName: "Doe"
email: "[email protected]"
password: "SecurePassword123!"
passwordConfirmation: "SecurePassword123!"
}) {
customer {
id
firstName
lastName
email
createdAt
}
}
}Customer Login
mutation {
createLogin(input: {
email: "[email protected]"
password: "SecurePassword123!"
}) {
accessToken
customer {
id
firstName
lastName
email
}
}
}Get Customer Profile
query {
customer {
id
firstName
lastName
email
gender
dateOfBirth
createdAt
addresses {
edges {
node {
id
firstName
lastName
address
city
state
country
zipCode
defaultBilling
defaultShipping
}
}
}
}
}Update Customer Profile
mutation {
updateCustomer(input: {
firstName: "Jane"
lastName: "Smith"
email: "[email protected]"
gender: "Female"
dateOfBirth: "1990-05-15"
}) {
customer {
id
firstName
lastName
email
}
}
}Change Password
mutation {
changeCustomerPassword(input: {
oldPassword: "OldPassword123!"
newPassword: "NewPassword456!"
passwordConfirmation: "NewPassword456!"
}) {
status
message
}
}Add Customer Address
mutation {
addCustomerAddress(input: {
firstName: "John"
lastName: "Doe"
address: "456 Oak Avenue"
city: "Los Angeles"
state: "CA"
country: "US"
zipCode: "90001"
phoneNumber: "2105551234"
defaultBilling: false
defaultShipping: true
}) {
address {
id
firstName
address
city
defaultShipping
}
}
}Update Customer Address
mutation {
updateCustomerAddress(input: {
addressId: "1"
firstName: "Jane"
lastName: "Smith"
address: "789 Pine Road"
city: "San Francisco"
state: "CA"
country: "US"
zipCode: "94102"
}) {
address {
id
firstName
address
city
}
}
}Delete Customer Address
mutation {
deleteCustomerAddress(input: {
addressId: "1"
}) {
status
message
}
}Forgot Password
mutation {
forgotPassword(input: {
email: "[email protected]"
}) {
status
message
}
}Reset Password
mutation {
resetPassword(input: {
token: "reset-token-from-email"
email: "[email protected]"
password: "NewPassword123!"
passwordConfirmation: "NewPassword123!"
}) {
status
message
}
}Customer Logout
mutation {
createLogout(input: {}) {
status
message
}
}Orders
Retrieve order information and history.
Get Customer Orders
query {
customerOrders(first: 20) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
incrementId
status
grandTotal
itemsCount
createdAt
shippingMethod
paymentMethod
items {
edges {
node {
id
productId
quantity
price
productName
}
}
}
}
}
}
}Get Order Details
query {
order(id: "1") {
id
incrementId
status
grandTotal
subtotal
taxTotal
shippingTotal
discountAmount
couponCode
createdAt
billingAddress {
firstName
lastName
address
city
state
country
zipCode
}
shippingAddress {
firstName
lastName
address
city
state
country
zipCode
}
items {
edges {
node {
id
productId
productName
sku
quantity
price
totalPrice
}
}
}
shipments {
edges {
node {
id
status
carrierTitle
trackNumber
createdAt
items {
edges {
node {
id
quantity
}
}
}
}
}
}
}
}Reviews
Browse and manage product reviews.
Get Product Reviews
query {
reviews(productId: "1", first: 20) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
title
rating
comment
customerName
email
status
createdAt
productId
}
}
}
}Create Product Review
mutation {
createReview(input: {
productId: "1"
title: "Great Product!"
rating: 5
comment: "Excellent quality and fast shipping."
name: "John Doe"
email: "[email protected]"
}) {
review {
id
title
rating
comment
status
createdAt
}
}
}Wishlist
Manage customer wishlists.
Add to Wishlist
mutation {
addToWishlist(input: {
productId: "1"
}) {
status
message
wishlist {
id
items {
edges {
node {
id
productId
product {
id
name
price
}
}
}
}
}
}
}Get Wishlist
query {
wishlist {
id
items {
edges {
node {
id
productId
addedAt
product {
id
name
sku
price
images {
edges {
node { url }
}
}
}
}
}
}
}
}Remove from Wishlist
mutation {
removeFromWishlist(input: {
wishlistItemId: "1"
}) {
status
message
}
}Utilities
Get Countries and States
query {
countries {
edges {
node {
id
code
name
states {
edges {
node {
id
code
defaultName
}
}
}
}
}
}
}Get Default Channel
query {
channel(code: "default") {
id
code
name
currencyCode
localeCode
rootCategoryId
}
}Get Available Locales
query {
locales {
edges {
node {
id
code
name
}
}
}
}💡 Pro Tips:
- Use pagination for large result sets
- Cache category trees for faster navigation
- Implement optimistic UI updates for cart changes
- Load high-resolution product images only when needed
📚 Related Documentation:

