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())
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 AssistagroAPI 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| assistagroapi-0.3.0.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| assistagroapi-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.1 kB
Release files / assistagroapi-0.3.0.tar.gz
| Download URL | assistagroapi-0.3.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8da3a742a6cf357f03d2305ceff782f650b0fa760759383dbb1e97af8299ed85
|
|
BLAKE2b-256 checksum How to use checksums |
0518f98c7274e672e604e62c2cf99014c4877e19a7d800d3203cc4420175fd80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / assistagroapi-0.3.0-py3-none-any.whl
| Download URL | assistagroapi-0.3.0-py3-none-any.whl |
|---|---|
| Size | 26.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad1f8d3034b78726a19f0d5a1b54dc9cf01c661057198ab941e0b6e1db329773
|
|
BLAKE2b-256 checksum How to use checksums |
63e4a80855886d23fdfc991d979d9e0110a0061b4c034ae416b0ecca123648e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|