Product feed for custom websites
Your client wants to bring the products of their own website into LazyDokan. Add one read-only endpoint to the website that lists products as JSON in the format below. The shop owner pastes its address (and an API key) into LazyDokan, tests the connection, and every product, variant, price, photo and stock count is imported. Nothing is written to your website.
1. The request
GET https://yourshop.com/api/lazydokan/products?page=1&per_page=100
Authorization: Bearer <api-key>- The address can be any path on your site. It must be public and use HTTPS.
pagestarts at 1.per_pageis 100.- The API key is optional but recommended. LazyDokan sends it as
Authorization: Bearer …and does not keep it after reading.
2. The response
{
"products": [
{
"id": "123",
"name": "Floral Kurti",
"description": "<p>Soft cotton kurti</p>",
"category": "Women > Kurti",
"status": "active",
"images": ["https://yourshop.com/images/kurti-1.jpg"],
"price": 1290,
"sale_price": 990,
"sku": "KUR-01",
"stock": 12,
"variants": [
{
"options": { "Size": "M", "Color": "Red" },
"price": 1290,
"sale_price": 990,
"sku": "KUR-01-M-RED",
"stock": 5,
"image": "https://yourshop.com/images/kurti-red.jpg"
}
]
}
],
"page": 1,
"has_more": true
}- idRequired
- Your product id. Keep it the same between calls.
- nameRequired
- Product name.
- priceRequired
- Regular price in taka, e.g. 1290. *Or give a price on every variant.
- sale_priceOptional
- Discounted price. Used only when it is lower than price.
- stockOptional
- Units in stock. With variants, give stock on each variant.
- imagesOptional
- Full https image URLs; the first is the cover. Up to 10.
- categoryOptional
- "Parent > Child" text, or ["Parent", "Child"].
- descriptionOptional
- HTML or plain text.
- statusOptional
- "active" (default) or "draft".
- sku, barcodeOptional
- Used to match products the shop already has in LazyDokan.
- variantsOptional
- List of sizes / colours: options, price, sale_price, sku, stock, image.
- variants[].optionsRequired
- { "Size": "M", "Color": "Red" } or [{ "name": "Size", "value": "M" }].
| Field | Required | Notes |
|---|---|---|
| id | Yes | Your product id. Keep it the same between calls. |
| name | Yes | Product name. |
| price | Yes* | Regular price in taka, e.g. 1290. *Or give a price on every variant. |
| sale_price | No | Discounted price. Used only when it is lower than price. |
| stock | No | Units in stock. With variants, give stock on each variant. |
| images | No | Full https image URLs; the first is the cover. Up to 10. |
| category | No | "Parent > Child" text, or ["Parent", "Child"]. |
| description | No | HTML or plain text. |
| status | No | "active" (default) or "draft". |
| sku, barcode | No | Used to match products the shop already has in LazyDokan. |
| variants | No | List of sizes / colours: options, price, sale_price, sku, stock, image. |
| variants[].options | Yes | { "Size": "M", "Color": "Red" } or [{ "name": "Size", "value": "M" }]. |
The list may also be named data or items, or be the whole response.
3. Pages
Tell LazyDokan whether more pages follow with any one of these:
"has_more": trueorfalse"next_page": 2, or a full next URL on the same site"total_pages": 5
With none of them, reading continues until a page is empty or has fewer than 100 products. Up to 2,000 products are read per import; a product can have up to 4 option types (20 values each) and 100 variants.
4. Examples
// routes/api.php
Route::get('/lazydokan/products', function (Request $request) {
abort_unless($request->bearerToken() === config('services.lazydokan.key'), 401);
$perPage = min((int) $request->query('per_page', 100), 100);
$page = Product::with(['images', 'variants', 'category'])
->orderBy('id')
->paginate($perPage);
return [
'products' => $page->getCollection()->map(fn ($p) => [
'id' => (string) $p->id,
'name' => $p->name,
'description' => $p->description,
'category' => $p->category?->name,
'status' => $p->is_active ? 'active' : 'draft',
'images' => $p->images->pluck('url'),
'price' => $p->price,
'sale_price' => $p->sale_price,
'sku' => $p->sku,
'stock' => $p->stock,
'variants' => $p->variants->map(fn ($v) => [
'options' => ['Size' => $v->size, 'Color' => $v->color],
'price' => $v->price,
'sku' => $v->sku,
'stock' => $v->stock,
]),
]),
'page' => $page->currentPage(),
'has_more' => $page->hasMorePages(),
];
});// Node.js + Express
app.get('/api/lazydokan/products', async (req, res) => {
if (req.get('Authorization') !== `Bearer ${process.env.LAZYDOKAN_KEY}`) {
return res.status(401).json({ error: 'Invalid key' });
}
const page = Math.max(1, Number(req.query.page) || 1);
const perPage = Math.min(100, Number(req.query.per_page) || 100);
const rows = await db.products.findMany({
skip: (page - 1) * perPage,
take: perPage + 1, // one extra row tells whether there is a next page
include: { images: true, variants: true, category: true },
orderBy: { id: 'asc' },
});
res.json({
products: rows.slice(0, perPage).map((p) => ({
id: String(p.id),
name: p.name,
price: p.price,
sale_price: p.salePrice,
stock: p.stock,
images: p.images.map((image) => image.url),
category: p.category?.name,
variants: p.variants.map((v) => ({
options: { Size: v.size, Color: v.color },
price: v.price,
sku: v.sku,
stock: v.stock,
})),
})),
page,
has_more: rows.length > perPage,
});
});5. Test it
- In LazyDokan, the shop owner opens Products → Import → Custom website, pastes the address and key, and clicks Test connection.
- The first products are shown with their price and stock, or the exact problem with the response.
- Problems reported: key refused (401 / 403), address not found (404), not JSON, no
productslist, or an empty first page. - The shop owner then reviews every product before anything is created.
Questions: hello@lazysoftbd.tech
