Skip to main content

mijnah

Interact with mijn Albert Heijn V2 API

Installation

pip install mijnah

Usage

Cart

AH uses a recaptcha token to authenticate, so it's easier to pass a ah_token or ah_token_presumed (found in a cookie after authenticating).

  • Authentication:

    import mijnah
    ah = mijnah.Cart(ah_token_presumed="my-ah-token")
    
  • List cart:

    ah.list_cart()
    
  • Add item to cart:

    ah.add_to_cart(product_id=1234, amount=2)
    

    The id can be found in the product url. For example the id in https://www.ah.nl/producten/product/wi471282/chatelain-notre-dame-medoc is 471282.

  • Update cart:

    ah.update_cart(product_id=1234, amount=0)
    
  • Empty cart:

    ah.empty_cart()
    

Product

  • Initialize:
    import mijnah
    p = mijnah.Product(product_id=1234)
    
  • Object properties:
    p.id
    p.name
    p.category
    p.description
    p.brand
    p.price
    

Example

Getting cart totals

import mijnah
import json
ah = mijnah.Cart(ah_token_presumed='ah_token')
ah.empty_cart()
# add some items
ah.add_to_cart(product_id=168153, amount=2)
ah.add_to_cart(product_id=224710, amount=1)
ah.add_to_cart(product_id=129138, amount=3)
ah.add_to_cart(product_id=198412, amount=2)
cart = ah.list_cart()
# Generate invoice
print(json.dumps([
    {
        'product': item['product'].name,
        'quantity': item['quantity'],
        'price': item['product'].price,
        'total': item['quantity'] * item['product'].price
    } for item in cart], indent=2))
# Get total items
print('total items:', sum(item['quantity'] for item in cart))
# Get total items
print('total price:', sum(
    item['quantity']*item['product'].price for item in cart))
[
  {
    "product": "AH IJsbergsla voordeel",
    "quantity": 2,
    "price": 1.79,
    "total": 3.58
  },
  {
    "product": "AH Babyspinazie",
    "quantity": 1,
    "price": 1.59,
    "total": 1.59
  },
  {
    "product": "AH Frambozen",
    "quantity": 3,
    "price": 2.39,
    "total": 7.17
  },
  {
    "product": "Valle del sole Popcorn ma\u00efs",
    "quantity": 2,
    "price": 1.53,
    "total": 3.06
  }
]
total items: 8
total price: 15.4

Changelog

1.2.0

  • Added ability to use ah_token, ah_token_presumed, or both.
  • Added tests

1.1.0

  • Initial version

Release files for mijnah 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mijnah 1.2.0
File Size Uploaded
mijnah-1.2.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mijnah 1.2.0
File Interpreter ABI Platform
mijnah-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / mijnah-1.2.0.tar.gz

Download URL mijnah-1.2.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
359dba89b0c98ad3a3dcb98b671b545d5b0700ef13e4b5af2467d1b76509f2fb
BLAKE2b-256 checksum
How to use checksums
99770382741dbc924beffcfdbeef3e5bc10ecba77dceea3f78867a76ef44ed99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.7

Release files / mijnah-1.2.0-py3-none-any.whl

Download URL mijnah-1.2.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
297c535fea04bb7436af7124d455c62fa50858ac3dac8fb4cb454fd54c5c7a2d
BLAKE2b-256 checksum
How to use checksums
3ab87953f7876cf31b7921b88990a70d91346a2f489bd6a6a2e7b956d3ed6568
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

1 release file

1.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page