Skip to main content

A Python API client for FixPrice catalog

Project description

FixPrice API (not official)

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

FixPrice (Фикс Прайс) - https://fix-price.com/

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

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

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

Usage

pip install fixprice_api
python -m camoufox fetch
import asyncio
from fixprice_api import FixPriceAPI, CatalogSort
from PIL import Image


async def main():
    async with FixPriceAPI() as api:
        # 1. Получаем дерево категорий
        tree_data = (await api.Catalog.tree()).json()
        first_alias = tree_data[next(iter(tree_data))]["alias"]
        print(f"Первая категория: {first_alias}")

        # 2. Список товаров в категории
        products = (
            await api.Catalog.products_list(
                category_alias=first_alias,
                page=1,
                limit=24,
                sort=CatalogSort.POPULARITY,
            )
        ).json()
        first_product_id = products[0]["id"]
        first_product_url = products[0]["url"]
        print(f"Первый товар: {products[0]['title']!s:.60s} ({first_product_id})")

        # 3. Геолокация (влияет на каталог и баланс)
        cities = (await api.Geolocation.cities_list(country_id=2)).json()  # Россия
        api.city_id = cities[0]["id"]
        print(f"Текущий city_id: {api.city_id}")

        # 4. Проверка наличия товара по магазинам
        balance = (await api.Catalog.Product.balance(product_id=first_product_id)).json()
        print(f"Проверено магазинов: {len(balance)}")

        # 5. Подробное инфо о товаре
        info = (await api.Catalog.Product.info(url=first_product_url)).json()
        print(f"Подробно о товаре: {list(info.keys())}")

        # 6. Загрузка изображения
        image_url = products[0]["images"][0]["src"]
        image_stream = await api.General.download_image(image_url)
        with Image.open(image_stream) as img:
            print(f"Image format: {img.format}, size: {img.size}")


if __name__ == "__main__":
    asyncio.run(main())
> Первая категория: kosmetika-i-gigiena
> Первый товар: Крем для рук и тела, 150 мл (2345678)
> Текущий city_id: 3
> Проверено магазинов: 339
> Image format: WEBP, size: (190, 190)

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


Автотесты API (pytest + snapshots)

В проекте используется автотест-фреймворк из human_requests:

  • endpoint-методы в бизнес-коде помечаются @autotest;
  • pytest-плагин сам находит эти методы и запускает их;
  • JSON-ответы проверяются через pytest-jsonschema-snapshot (schemashot);
  • параметры вызова и пост-обработка результата регистрируются в tests/api_test.py через:
    • @autotest_params
    • @autotest_hook
    • @autotest_depends_on

Минимальная конфигурация уже включена в pyproject.toml:

[tool.pytest.ini_options]
anyio_mode = "auto"
autotest_start_class = "fixprice_api.FixPriceAPI"

Запуск тестов:

pytest

Важно:

  • используется pytest-anyio (не pytest-asyncio);
  • ручные тесты остаются только для кейсов, которые не относятся к JSON-схемам endpoint-методов (например, download_image).

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

fixprice_api-0.2.4.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

fixprice_api-0.2.4-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file fixprice_api-0.2.4.tar.gz.

File metadata

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

File hashes

Hashes for fixprice_api-0.2.4.tar.gz
Algorithm Hash digest
SHA256 727c590653e181f88609793dd09397454dc7f9f382ad90a9e51e19822793aed5
MD5 e2bc7ab58c117dc5d6fcf9baf292d040
BLAKE2b-256 252127958291a5049b079b7dadf7eb862443351fd297751903f4147bd07a6d15

See more details on using hashes here.

Provenance

The following attestation bundles were made for fixprice_api-0.2.4.tar.gz:

Publisher: publish.yml on Open-Inflation/fixprice_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 fixprice_api-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: fixprice_api-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fixprice_api-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 56865269192dec4176a1e25ff33b1dc19d08b207b88ae7d62874da7d81209cef
MD5 2a682b2b9b0db3d349d3c249e079c46b
BLAKE2b-256 49a025d3227e81cfa6ff53d7cc47b6ea5644297629634a657fbd27c2ca0d0899

See more details on using hashes here.

Provenance

The following attestation bundles were made for fixprice_api-0.2.4-py3-none-any.whl:

Publisher: publish.yml on Open-Inflation/fixprice_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