Skip to content

Products

Fetch all products

fetch('https://dummyapi.online/api/products')
.then((response) => response.json())
.then((json) => console.log(json));
Output
[
{
"id": 1,
"productCategory": "Smartphone",
"name": "iPhone 12 Pro",
"brand": "Apple",
"description": "The iPhone 12 Pro features a new design and edge-to-edge Super Retina XDR display.",
"basePrice": 999,
"inStock": true,
"stock": 43,
"featuredImage": "https://placehold.co/800x600?text=iPhone+12+Pro",
"thumbnailImage": "https://placehold.co/400x300?text=iPhone+12+Pro",
"storageOptions": ["128GB", "256GB", "512GB"],
"colorOptions": ["Graphite", "Silver", "Gold", "Pacific Blue"],
"display": "6.1-inch Super Retina XDR display",
"CPU": "A14 Bionic chip",
"camera": {
"rearCamera": "Pro 12MP camera system: Ultra Wide, Wide, and Telephoto cameras",
"frontCamera": "12MP TrueDepth front camera"
}
},
// More products...
]

Fetch a single product

Getting a single product by ID. In this example, we use the /api/products/1 route.

fetch('https://dummyapi.online/api/products/1')
.then((response) => response.json())
.then((json) => console.log(json));
Output
{
"id": 1,
"productCategory": "Smartphone",
"name": "iPhone 12 Pro",
"brand": "Apple",
"description": "The iPhone 12 Pro features a new design and edge-to-edge Super Retina XDR display.",
"basePrice": 999,
"inStock": true,
"stock": 43,
"featuredImage": "https://placehold.co/800x600?text=iPhone+12+Pro",
"thumbnailImage": "https://placehold.co/400x300?text=iPhone+12+Pro",
"storageOptions": ["128GB", "256GB", "512GB"],
"colorOptions": ["Graphite", "Silver", "Gold", "Pacific Blue"],
"display": "6.1-inch Super Retina XDR display",
"CPU": "A14 Bionic chip",
"camera": {
"rearCamera": "Pro 12MP camera system: Ultra Wide, Wide, and Telephoto cameras",
"frontCamera": "12MP TrueDepth front camera"
}
}

Show All Available Products

To view all available products, you can open the Products Endpoint in your browser.