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.2.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.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyaterochka_api-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 fd2920e7529a854eb07e6cfb07155385912f9297310405cc5dc024f3b12a937e
MD5 10d43733a1959f5ca4356737f871f42e
BLAKE2b-256 93c746ca952da7a51a5d6eec3aacfdb5cfc589e3ff596d1431c538bef02e8249

See more details on using hashes here.

Provenance

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

Publisher: 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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyaterochka_api-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b031b4e9fbb72ed6f47617cc28f57d73609faabe2d9548579e59c555dd219acb
MD5 9eba51fe545077602b42a011dde7b62b
BLAKE2b-256 da5b400cc21306937ef5a2e9334c6a27ae2ac8c78d0bf959af489d587b7ef460

See more details on using hashes here.

Provenance

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

Publisher: 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