Skip to main content

AssistAgro API Client

Синхронный и асинхронный HTTP-клиент для AssistAgro API.

Установка

pip install assistagro-client

Асинхронное использование

import asyncio
from assistagro_client import AssistAgroClient

async def main():
    async with AssistAgroClient(base_url="https://gateway-frontend.agroassist.ru") as client:
        tokens = await client.auth.sign_in(
            email="user@example.com",
            password="password123"
        )
        print(f"Access token: {tokens.access_token[:20]}...")

        structures = await client.structures.list_()
        structure_guid = structures[0].structure_guid

        season = await client.seasons.get_current()

        fields = await client.fields.list_(
            structure_guids=[structure_guid],
            season_id=season.season_id,
        )
        print(f"Найдено полей: {len(fields)}")

        crops_response = await client.dictionaries.get_crops()
        print(f"Культур: {len(crops_response.crops)}")

        tasks = await client.tasks.list_(structure_guid=structure_guid)
        print(f"Найдено задач: {len(tasks)}")

if __name__ == "__main__":
    asyncio.run(main())

Синхронное использование

from assistagro_client import AssistAgroSyncClient

with AssistAgroSyncClient(base_url="https://gateway-frontend.agroassist.ru") as client:
    tokens = client.auth.sign_in(
        email="user@example.com",
        password="password123",
    )
    print(f"Access token: {tokens.access_token[:20]}...")

    structures = client.structures.list_()
    print(f"Найдено структур: {len(structures)}")

AssistAgroClient остается асинхронным клиентом для обратной совместимости. AssistAgroSyncClient предоставляет тот же набор API-разделов для обычного синхронного кода. Если нужно передать контекст пользователя в x-user-data, используйте set_user_data(...); заголовок сериализуется как компактный JSON, например {"company_guid":"...","user_guid":"..."}.

TLS/SSL сертификаты

По умолчанию клиент проверяет TLS-сертификат сервера. Если окружение использует свой CA-bundle, передайте путь к нему:

client = AssistAgroClient(verify="/path/to/ca-bundle.pem")

Если сервер временно отдает некорректную цепочку сертификатов, проверку можно отключить явно:

client = AssistAgroClient(verify=False)

То же доступно для AssistAgroSyncClient и через переменную окружения ASSISTAGRO_VERIFY_SSL=false.

API эндпоинты

Модуль Описание Основные методы
auth Аутентификация sign_in, refresh_tokens, logout
accounts Пользователи get_current_user, get_users
companies Компании list_(), list_all, get, get_license, get_license_metadata, get_activities, get_dashboards
structures Структуры list_(), list_plain
seasons Сезоны list, get_current, get_by_name, get_season_id_by_name
fields Поля list_(), get_contours, get_phenophases, get_monitoring, list_meta
tasks Задачи list_(), create, get_list_meta
reports Отчёты list_(), create, get_metadata, get_problems, get_list_meta
techmaps Технологические карты list_(), create
meteostations Метеостанции list_(), get, get_by_field, get_manufacturers, get_providers, get_sensors, get_coordinates_history, get_history
dictionaries Справочники get_crops, get_crop_products, get_techoperations, get_pesticides, get_fertilizers, get_machines, get_tools, get_units, get_regions, get_countries, и др.

Примеры

Скопируйте .env.example в .env и заполните переменные:

cp .env.example .env
ASSISTAGRO_EMAIL=user@example.com
ASSISTAGRO_PASSWORD=your-password
ASSISTAGRO_BASE_URL=https://gateway-frontend.agroassist.ru
ASSISTAGRO_DEBUG=false

Запуск примеров:

# Запустить все модули
uv run python examples/run_tests.py

# Запустить конкретный модуль
uv run python examples/run_tests.py --module structures
uv run python examples/run_tests.py -m auth

# Доступные модули:
# auth, structures, companies, current_user, users,
# dictionaries, meteostations, tasks, fields, reports, techmaps, seasons

Разработка

# Установить зависимости
uv sync

# Запустить тесты
uv run pytest

# Запустить линтер
uv run ruff check .
uv run ruff check --fix .

# Проверка типов
uv run mypy src/

# Форматирование
uv run black .

Лицензия

MIT

Release files for assistagro-client 0.4.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 assistagro-client 0.4.0
File Size Uploaded
assistagro_client-0.4.0.tar.gz 25.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for assistagro-client 0.4.0
File Interpreter ABI Platform
assistagro_client-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.8 kB

Release files / assistagro_client-0.4.0.tar.gz

Download URL assistagro_client-0.4.0.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
575ef929c620f2b30e58b7fbe5fb5b9725e91d184f7caabc90062244336ff25f
BLAKE2b-256 checksum
How to use checksums
12ecfae07037b45fe88d28d529ebe40f6f51c9603859050f391949c834a01b67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.9

Release files / assistagro_client-0.4.0-py3-none-any.whl

Download URL assistagro_client-0.4.0-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b63703cd952407373b1554206a2a9a2aab80352b73b033f9d5b6b57f692f4dc
BLAKE2b-256 checksum
How to use checksums
fa1cf816ee919da15929349fe3be85de7cc60ddd11c90a3ebc0a96c2c3f53083
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.9

Release history Release notifications | RSS feed

0.4.1

2 release files

This release

0.4.0 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

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