Skip to main content

Cas d’usage

Le contrôle MAP (Minimum Advertised Price) permet aux laboratoires de :
  • Détecter les revendeurs qui ne respectent pas le prix minimum
  • Documenter les violations pour action légale
  • Protéger l’image de marque

Implémentation

1. Vérifier le respect du MAP

import requests

API_KEY = "oc_YOUR_API_KEY"

def check_map_violations(ean, map_price):
    """Détecte les violations de MAP pour un produit"""
    response = requests.get(
        f"https://api.officiscan.com/v1/prices/compare?ean={ean}",
        headers={"Authorization": f"Bearer {API_KEY}"}
    )
    data = response.json()

    violations = []
    for source in data["sources"]:
        if source["price"] and source["price"] < map_price:
            violations.append({
                "source": source["source"],
                "site_url": source["site_url"],
                "price": source["price"],
                "map_price": map_price,
                "difference": map_price - source["price"],
                "collected_at": source["collected_at"]
            })

    return violations

# Exemple : MAP à 15€
violations = check_map_violations("3401560504507", map_price=15.00)

for v in violations:
    print(f"❌ {v['source']}: {v['price']}€ (MAP: {v['map_price']}€)")
    print(f"   Écart: -{v['difference']:.2f}€")
    print(f"   URL: {v['site_url']}")

2. Monitoring automatique

def daily_map_report(products_map):
    """
    products_map: dict avec {ean: map_price}
    """
    report = []

    for ean, map_price in products_map.items():
        violations = check_map_violations(ean, map_price)

        if violations:
            report.append({
                "ean": ean,
                "map_price": map_price,
                "violation_count": len(violations),
                "violations": violations
            })

    return report

# Configuration MAP
products = {
    "3401560504507": 15.00,
    "3400930001035": 8.50,
    "3401599504502": 12.00
}

report = daily_map_report(products)

for product in report:
    print(f"\n📦 EAN {product['ean']} - {product['violation_count']} violations")
    for v in product["violations"]:
        print(f"  - {v['source']}: {v['price']}€")

3. Export pour action légale

import csv
from datetime import datetime

def export_violations_csv(violations, filename=None):
    """Export les violations au format CSV pour documentation"""
    if not filename:
        filename = f"map_violations_{datetime.now().strftime('%Y%m%d')}.csv"

    with open(filename, "w", newline="") as f:
        writer = csv.DictWriter(f, fieldnames=[
            "ean", "source", "site_url", "price",
            "map_price", "difference", "collected_at"
        ])
        writer.writeheader()

        for v in violations:
            writer.writerow(v)

    return filename

Endpoints utilisés

GET /v1/prices/compare

Prix actuels par source

GET /v1/prices

Historique pour preuves