albert-heijn-wrapper
v2.0.1
Published
API wrapper for Albert Heijn
Downloads
206
Readme
Unofficial Node.js API wrapper for Albert Heijn.
Installation
npm install albert-heijn-wrapper
or
yarn add albert-heijn-wrapper
then
import { AH } from 'albert-heijn-wrapper';
Basic usage
// Creates AH object, set verbose=true if you want to see all requests
const ah = new AH({ verbose: true });
// Gets product as reponse from ID
const product = await ah.product().getProductFromId(200486);
More information about the functions and parameters can be found on the wiki.
Example usage
For all of these examples, please keep in mind that your function in which you request something should be async
since the requests return a Promise
.
Products
Let's say I want to find the names of the products called "Brood" but the products have to be gluten free, vegan and of the brand "AH Glutenvrij" and I want to sort on ascending price:
import {
AH,
ProductFilter,
ProductPropertyFilter,
ProductSortOptions,
} from 'albert-heijn-wrapper';
async function getGlutenFreeVeganBread() {
// First create an AH object
const ah = new AH();
// Initialise the filter with the brand and properties (gluten free and vegan)
const filter: ProductFilter = {
brand: "AH Glutenvrij",
property: [ProductPropertyFilter.GlutenFree, ProductPropertyFilter.Vegan]
};
// Search for all products on ascending price with the filter
const products = await ah.product().getProductsFromName("Brood", {
filter,
sort: ProductSortOptions.PriceAsc
});
// Return only the names of the products
const res = products.products.map((product) => {
return product.title;
});
console.log(res);
}
getGlutenFreeVeganBread();
[
'AH Glutenvrij Pistolets meerzaden',
'AH Glutenvrij Mueslibroodjes',
'AH Glutenvrij Vezelrijke broodmix'
]
Stores
Let's say I want to find the address of the nearest store to a given location:
import { AH } from 'albert-heijn-wrapper';
async function findNearestStore(latitude: number, longitude: number) {
// Create AH object
const ah = new AH();
// Find nearest store
const store = await ah.store().getClosestStoreFromLocation(latitude, longitude);
console.log(`${store.address.street} ${store.address.houseNumber}, ${store.address.postalCode}`);
}
findNearestStore(50, 4);
Wilhelminalaan 9, 4551EP
Authentication
Unfortunately, it is not possible to log in with your personal AH account, which means you won't be able to access your orders.