@noorkaru/prisma-client
v0.0.3
Published
TypeScript SDK for Prisma Market API - product browsing, search, and category navigation
Downloads
159
Maintainers
Readme
@noorkaru/prisma-client
TypeScript SDK for Prisma Market API - product browsing, search, and category navigation for the Estonian grocery store chain.
Features
- Text search across all products with sorting and pagination
- Category browsing with optional filtering
- Label filters - vegan, gluten-free, organic, discounted, etc.
- Batch product lookup by EAN barcodes
- Category navigation tree
- Store information retrieval
- Fully typed with TypeScript
- Formatted responses - no raw API response handling needed
Installation
npm install @noorkaru/prisma-clientQuick Start
import { PrismaClient } from '@noorkaru/prisma-client';
const client = new PrismaClient({
storeId: '542860184' // Optional, defaults to store ID 542860184
});
// Text search
const results = await client.products.search('piim', { limit: 10 });
console.log(`Found ${results.total} products`);
results.items.forEach(product => {
console.log(`${product.name} - ${product.price}€`);
console.log(` Unit price: ${product.comparisonPrice}€/${product.comparisonUnit}`);
});
// Get product details
const product = await client.products.getDetails('4740125120059');
console.log(product.name, product.price);API Reference
Products
search(query: string, options?: SearchOptions)
Text search across all products.
const results = await client.products.search('piim', {
limit: 24,
from: 0,
orderBy: 'price',
order: 'asc'
});Options:
limit(number, max 120): Results per page. Default: 24.from(number): Starting index for pagination. Default: 0.orderBy('price' | 'comparisonPrice' | 'name' | 'score'): Sort field.order('asc' | 'desc'): Sort direction.availabilityDate(string): Filter by availability date.labels(ProductLabel[]): Label filters.
browse(slug?: string, options?: SearchOptions)
Browse products by category, or all products if no slug provided.
// Browse a category
await client.products.browse('piim-munad-ja-rasvad', { limit: 20 });
// Browse all products
await client.products.browse();getDetails(ean: string)
Get detailed product information by EAN barcode.
const product = await client.products.getDetails('4740125120059');getByEans(eans: string[])
Batch lookup multiple products by EAN barcodes.
const products = await client.products.getByEans([
'4740125120059',
'4740125120011'
]);Label Convenience Methods
All methods accept optional SearchOptions to control pagination, sorting, and category filtering.
// All discounted products, paginated
await client.products.getDiscounted({ limit: 24, from: 24 });
// Discounted in a category
await client.products.getDiscounted({
slug: 'food-market',
limit: 10
});
// Vegan products, sorted by price
await client.products.getVegan({
orderBy: 'price',
order: 'asc'
});Available methods:
getDiscounted(options?)getVegan(options?)getGlutenFree(options?)getLactoseFree(options?)getLowLactose(options?)getOrganic(options?)getFrozen(options?)
Categories
getNavigationMenu()
Get the full category navigation tree.
const categories = await client.categories.getNavigationMenu();
// Returns Category[] with { name, slug, children? }Stores
getInfo(storeId?: string)
Get store information.
const store = await client.stores.getInfo();
console.log(store.brand, store.coOperative);Response Types
FormattedProduct
interface FormattedProduct {
name: string;
ean: string;
price?: number;
regularPrice?: number; // Set when onCampaign is true
onCampaign: boolean;
url: string; // Full product URL
imageUrl?: string; // Product image URL
category?: string; // Top-level category name
comparisonPrice?: number; // Unit price (e.g., per liter)
comparisonUnit?: string; // Unit (e.g., "LTR", "KG")
nutrients?: NutrientInfo[]; // Nutritional information (only in getDetails)
}SearchResult
interface SearchResult {
items: FormattedProduct[];
total: number; // Total results available
}Category
interface Category {
name: string;
slug: string;
children?: Category[];
}NutrientInfo
interface NutrientInfo {
nutrients: Nutrient[];
referenceQuantity: string; // e.g., "100 ml", "100 g"
referenceQuantityType: string; // e.g., "MEASUREMENT"
}
interface Nutrient {
name: string; // e.g., "Energia", "Rasvad", "Valgud"
value: string; // e.g., "55 kcal", "2,5 g"
recommendedIntake?: string; // Optional recommended daily intake
}Pagination Example
// Page 1
const page1 = await client.products.search('piim', {
limit: 24,
from: 0
});
// Page 2
const page2 = await client.products.search('piim', {
limit: 24,
from: 24
});
console.log(`Showing ${page1.items.length} of ${page1.total} total`);Sorting Example
// Cheapest first
await client.products.search('piim', {
orderBy: 'price',
order: 'asc'
});
// Best unit price
await client.products.search('piim', {
orderBy: 'comparisonPrice',
order: 'asc'
});
// Alphabetical
await client.products.search('piim', {
orderBy: 'name',
order: 'asc'
});Development
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm testLicense
ISC
