Skip to main content

A Python API client for Pyaterochka store catalog

Project description

Pyaterochka API (not official)

Tests last run (ISO) Tests PyPI - Python Version PyPI - Package Version PyPI - Downloads License Discord Telegram

Pyaterochka (Пятёрочка) - https://5ka.ru/

⭐ Star us on GitHub | 📚 Read the Docs | 🐛 Report Bug

Принцип работы

Библиотека полностью повторяет сетевую работу обычного пользователя на сайте.

Usage:

pip install pyaterochka_api
python -m camoufox fetch
from pyaterochka_api import PyaterochkaAPI
import asyncio
from PIL import Image

async def main():
    async with PyaterochkaAPI() as api:
        
        # 1. Получение информации о текущем выбранном магазине доставки
        store_info = await api.delivery_panel_store()
        sap_code = store_info["selectedStore"]["sapCode"]
        print(f"SAP код выбранного магазина: {sap_code}\n")

        # 2. Получение списка всех категорий
        tree_resp = await api.Catalog.tree(sap_code_store_id=sap_code)
        categories_data = tree_resp.json()
        first_category = categories_data[0]
        print(f"Первая категория: {first_category['name']!s:.50s}...\n")

        # 3. Получение списка товаров в первой категории
        products_resp = await api.Catalog.products_list(
            category_id=first_category["id"], sap_code_store_id=sap_code
        )
        products_data = products_resp.json()
        first_product_plu = products_data["products"][0]["plu"]
        print(f"Первый товар (PLU): {first_product_plu}\n")

        # 4. Получение подробной информации о первом товаре
        product_info_resp = await api.Catalog.Product.info(
            sap_code_store_id=sap_code, plu_id=first_product_plu
        )
        product_info_data = product_info_resp.json()
        print(f"Название первого товара: {product_info_data['name']!s:.50s}...\n")

        # 5. Примеры использования геолокации
        
        # Поиск адресов по запросу
        suggest_resp = await api.Geolocation.suggest("москва")
        print(f"Предложения по геолокации для 'москва': {suggest_resp.json()['results'][0]['address']['formatted_address']!s:.50s}...\n")

        # Определение текущей геолокации
        geocode_resp = await api.Geolocation.geocode()
        pos: str = geocode_resp.json()["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"]["Point"]["pos"]
        longitude, latitude = pos.split(" ")
        print(f"Выбранная геолокация (долгота, широта): {longitude}, {latitude}\n")
        
        # 6. Скачивание изображения (на примере изображения первой подкатегории)
        image_link = first_category["categories"][0]["image_link"]
        image_stream = await api.General.download_image(image_link)

        # Пример обработки изображения с помощью PIL
        with Image.open(image_stream) as img:
            print(f"Изображение скачано. Формат: {img.format}. Размер: {img.size}\n")
            # img.save("first_category_image.png") # Можно сохранить локально

# Запуск асинхронной функции main
if __name__ == "__main__":
    asyncio.run(main())

Для более подробной информации смотрите референсы документации.


Report

If you have any problems using it / suggestions, do not hesitate to write to the project's GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaterochka_api-0.2.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyaterochka_api-0.2.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file pyaterochka_api-0.2.1.tar.gz.

File metadata

  • Download URL: pyaterochka_api-0.2.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyaterochka_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 56b7a30de6eb4abd966446dbec32f8bd3e6d18bed9a8ea34445abd012d052581
MD5 f5e669da609a61c5aa1199310d5549b7
BLAKE2b-256 782857c6e5438edf51a3a059030c3dc92baaf2936f643bcdd68bba08f04b5244

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyaterochka_api-0.2.1.tar.gz:

Publisher: python-publish.yml on Open-Inflation/pyaterochka_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyaterochka_api-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyaterochka_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0b169f931d70faef9843dc561f3a2c2199ac491f6038eda9307af3be8c48975
MD5 de5b075d2749d4ce6bca2da0da03f459
BLAKE2b-256 8c0bdf76026795c8d2e0f2ef6189b901bef6ca85ed6b5d42f12f20854858a9da

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyaterochka_api-0.2.1-py3-none-any.whl:

Publisher: python-publish.yml on Open-Inflation/pyaterochka_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page