API Zabelie
Konekte aplikasyon ou ak katalòg mache ayisyen an.
Lekti piblik san kle API: pwodwi, kategori, vandè, avi ak stok. Acha ak chanjman fèt sou Zabelie.
Telechaje spesifikasyon OpenAPIPremye demann
const response = await fetch("https://zabelie.com/api/v1/search_products", {
method: "POST",
credentials: "omit",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ limit: 5 })
});
const result = await response.json();
if (!response.ok) throw new Error(result.code);
console.log(result.results, result.nextCursor);Fonksyon ki disponib
POST /api/v1/list_categoriesPOST /api/v1/search_productsPOST /api/v1/get_productPOST /api/v1/compare_productsPOST /api/v1/get_sellerPOST /api/v1/get_reviewsPOST /api/v1/check_inventoryPOST /api/v1/get_delivery_terms
Kondisyon itilizasyon
Voye JSON ak POST. Rechèch ak kategori limite a 20 rezilta pa paj. Pou kontinye, mete nextCursor nan cursor ak menm filtè yo. Montan yo se goud antye (HTG).
Limit aktyèl la se 60 demann pa minit pou chak fonksyon, pataje ant vizitè anonim yo. Si ou resevwa 429, tann 60 segonn; sa ka vle di kontwòl limit la pa disponib tou. Kò demann lan limite a 16 Kio.
Sou yon lòt sit, sèvi ak credentials: omit. API piblik la inyore bonbon ak jeton koneksyon yo. Kòmand pèsonèl mande sesyon Zabelie epi yo pa ouvè pou lòt sit.
Yon lis vid vle di pa gen òf pibliye ki koresponn. Rechèch v1 gen pwodwi fizik ak fichye dijital; li pa gen sèvis. Kategori yo ka vid.
Chan untrusted yo gen tèks vandè yo. Montre yo kòm tèks, pa kòm enstriksyon oswa HTML brit. Verifye pri ak stok sou Zabelie anvan acha.
get_delivery_terms kenbe ansyen kontra li: nouvo zòn ak kondisyon remiz yo poko nan repons sa a.
API vandè : konekte sit ou
Avèk yon kle API, sit yon vandè ka li pwodui ak vant li, epi jwenn adrès peman yon pwodui. Achtè a toujou peye sou Zabelie, ak pwoteksyon peman an.
Kreye kle a nan Tablo bò → API ak entegrasyon. Voye l nan Authorization: Bearer zb_live_… depi sèvè ou, pa janm depi navigatè a : API sa a pa aksepte demann paj wèb. Limit : 120 demann pa minit pou chak kle.
Telechaje spesifikasyon OpenAPI API vandè aconst response = await fetch("https://zabelie.com/api/v1/seller/seller_products", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept-Language": "ht",
Authorization: `Bearer ${apiKey}`
},
body: JSON.stringify({ limit: 20, status: "published" })
});
const result = await response.json();
if (!response.ok) throw new Error(result.code);
for (const p of result.results) console.log(p.untrusted.title, p.priceHtg, p.url);POST /api/v1/seller/seller_products(products:read)POST /api/v1/seller/seller_sales(sales:read)POST /api/v1/seller/create_product_link(links:write)
Pa gen okenn done achtè ki parèt. Yon vant ak live: false se yon peman tès : pa janm trete l tankou yon vrè vant.
Webhook : ajoute yon adrès https nan Tablo bò → API ak entegrasyon. Zabelie voye sale.paid ak sale.refunded la, siyen nan antèt Zabelie-Signature (t=…,v1=…) : HMAC-SHA256 « t.kò brit » ak sekrè whsec_… ou. Verifye siyati a epi refize yon t ki gen plis pase 5 minit. Reponn 2xx ; sinon Zabelie eseye ankò jiska 5 fwa, apre sa li abandone. Twa voye abandone youn dèyè lòt dezaktive adrès la.
import { createHmac, timingSafeEqual } from "node:crypto";
function isValidZabelieWebhook(secret, header, rawBody) {
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
if (!t || !v1 || Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = createHmac("sha256", secret).update(t + "." + rawBody).digest();
const received = Buffer.from(v1, "hex");
return received.length === expected.length && timingSafeEqual(received, expected);
}