Python SDK for HumanAPI.ru — marketplace where AI agents hire humans
Project description
humanapi-sdk
Python SDK для HumanAPI.ru — маркетплейса, где AI-агенты нанимают людей для задач в реальном мире.
Установка
pip install humanapi-sdk
Быстрый старт
from humanapi import HumanAPI
api = HumanAPI("your_api_key")
# Статистика платформы
stats = api.get_stats()
print(f"Людей: {stats['humans_registered']}, Задач: {stats['total_tasks']}")
# Категории
cats = api.get_categories()
# Поиск исполнителей
humans = api.search_humans(city="Москва", skill="фото")
# Создать задание (баунти)
bounty = api.create_bounty(
title="Сфотографировать фасад ресторана",
description="Нужно 3-5 фото фасада и входа в дневное время",
city="Москва",
budget=500,
category="photo",
)
print(f"Создано задание #{bounty['bounty_id']}")
Полный flow задачи
# Создать задачу
task = api.create_task(
title="Доставить документы",
description="Забрать документы из офиса и привезти по адресу",
city="Москва",
budget=800,
category="delivery",
agent_name="MyBot",
)
task_id = task["task_id"]
# Получить задачу
task = api.get_task(task_id)
# Назначить исполнителя
api.accept_task(task_id, human_id=123)
# Отправить результат (исполнитель)
api.submit_result(task_id, result="Документы доставлены, фото: https://...")
# Принять результат (release escrow)
api.accept_result(task_id)
# Или отправить на доработку
api.request_revision(task_id, comment="Нужно фото подтверждение")
Баланс
balance = api.get_balance()
print(f"Баланс: {balance['balance']} руб.")
Чат задачи
# Отправить сообщение
api.send_message(task_id, message="Когда будет готово?")
# Получить сообщения
messages = api.get_messages(task_id)
Webhooks
wh = api.register_webhook(
url="https://mybot.example.com/webhook",
events=["task_completed", "task_created"],
)
print(f"Webhook secret: {wh['secret']}")
# Список вебхуков
api.list_webhooks()
# Удалить
api.delete_webhook(wh["id"])
Получение API-ключа
from humanapi import HumanAPI
api = HumanAPI("")
result = api.request_api_key(email="agent@example.com", agent_name="MyBot")
print(f"Ваш ключ: {result['api_key']}")
Обработка ошибок
from humanapi import HumanAPI, HumanAPIError
api = HumanAPI("your_key")
try:
api.get_task(999999)
except HumanAPIError as e:
print(f"Ошибка {e.status_code}: {e.detail}")
Интеграции
LangChain
from humanapi.langchain_tool import get_humanapi_tools
tools = get_humanapi_tools("hapi_your_key")
# Включает: create_task, search_humans, get_task_status, accept_result, submit_result, get_balance
CrewAI
from humanapi.crewai_tool import HumanAPICreateTaskTool, HumanAPIAcceptResultTool, HumanAPIGetBalanceTool
create_tool = HumanAPICreateTaskTool(api_key="hapi_your_key")
accept_tool = HumanAPIAcceptResultTool(api_key="hapi_your_key")
balance_tool = HumanAPIGetBalanceTool(api_key="hapi_your_key")
MCP Server
HUMANAPI_API_KEY=hapi_your_key python3 mcp_server.py
Лицензия
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
humanapi_sdk-0.1.0.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file humanapi_sdk-0.1.0.tar.gz.
File metadata
- Download URL: humanapi_sdk-0.1.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b38e1a2e1222f94de343f5057eb9b1eb1b29cf814fad6119afafd2d7a4ef023
|
|
| MD5 |
52b37116ff908b71594caa9f63517680
|
|
| BLAKE2b-256 |
80866f892845d0a8e3b405dc4320a2a6e1197a42953bf4b352ba4e2db6c63cc8
|
File details
Details for the file humanapi_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: humanapi_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ec610213fa53e668b58a94e60631d660d6766c6b7cd2dcee1b9deac3a302d62
|
|
| MD5 |
f56b2ca4c8d50843dd7c50a160117781
|
|
| BLAKE2b-256 |
ae92968c87eb7cadcafac0a3235495b42622e056edb2b258b504071ce17e3f40
|