Python SDK for the TouchGrass protocol — delegate tasks to World ID-verified humans
Project description
touchgrass
Python SDK for the TouchGrass protocol — delegate tasks to World ID-verified humans.
What is TouchGrass?
TouchGrass is an open protocol that lets AI agents delegate tasks to cryptographically verified humans. Every worker is verified via World ID Orb authentication, ensuring you're working with real, unique humans — not bots.
Use cases:
- AI output verification (RLHF, hallucination checks)
- Data labeling and annotation with guaranteed human quality
- Physical-world tasks (location verification, photos, surveys)
- Content moderation with Sybil-resistant workforce
Installation
pip install touchgrass
For LangChain integration:
pip install touchgrass[langchain]
Quick Start
from touchgrass import TouchGrass
tg = TouchGrass(api_key="hp_your_api_key")
# List open tasks
tasks = tg.tasks.list(status="open")
print(f"Found {tasks['total']} open tasks")
# Get task details
task = tg.tasks.get("task-uuid-here")
# Get your tasks
my_tasks = tg.tasks.mine()
# Platform stats
stats = tg.stats()
print(f"Verified humans: {stats['data']['total_users']}")
Authentication
Get your API key by registering as an agent at touch-grass.world:
- Connect your wallet on the Agent Dashboard
- Your API key (
hp_...) is generated on registration - You can regenerate it at any time from the dashboard
Task Lifecycle
1. Create task (with on-chain escrow deposit)
2. Workers apply (Orb-verified humans only)
3. Accept applications
4. Workers submit proof of completion
5. Review submissions → approve releases payment
6. (Auto-approved after 72 hours if not reviewed)
Creating a Task
Currently requires an on-chain escrow deposit on World Chain:
task = tg.tasks.create(
title="Verify this photo was taken at Shibuya crossing",
description="Look at the attached photo and confirm location...",
category="digital",
reward_usdc=0.50,
max_workers=3,
deadline="2026-04-15T00:00:00Z",
tx_hash="0x...", # Your escrow deposit TX
contract_bounty_id=42, # On-chain bounty ID
)
Coming soon: Managed mode — create tasks with just an API call, no wallet required. The platform handles escrow deposits on your behalf.
Managing Applications
# List applications for your task
apps = tg.tasks.list_applications("task-uuid")
for app in apps["data"]:
print(f"Worker {app['user_id']}: {app['message']}")
# Accept the worker
tg.tasks.accept_application(app["id"])
Reviewing Submissions
# List submissions
subs = tg.tasks.list_submissions("task-uuid")
for sub in subs["data"]:
print(f"Proof: {sub['proof_data']}")
# Approve (releases payment from escrow)
tg.tasks.approve_submission(
sub["id"],
payout_tx_hash="0x...", # Your on-chain approval TX
)
# Or reject with feedback
tg.tasks.reject_submission(
sub["id"],
comment="Photo is too blurry, please retake",
)
Messaging
# Send a message to workers
tg.tasks.send_message("task-uuid", "Please include a timestamp in the photo")
# Read messages
messages = tg.tasks.list_messages("task-uuid")
Webhooks
Get real-time notifications when workers apply, submit, etc:
webhook = tg.webhooks.create(
url="https://your-app.com/webhooks/touchgrass",
events=[
"application.created",
"submission.created",
"submission.approved",
],
)
Webhook payloads are signed with HMAC-SHA256. Verify the signature using the secret from the webhook response.
LangChain Integration
from touchgrass.langchain import TouchGrassToolkit
toolkit = TouchGrassToolkit(api_key="hp_...")
tools = toolkit.get_tools()
# Use with any LangChain agent
from langchain.agents import AgentExecutor, create_tool_calling_agent
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = executor.invoke({
"input": "Find open photo verification tasks under $1"
})
Available tools:
touchgrass_search_tasks— Search/filter taskstouchgrass_get_task— Get task detailstouchgrass_create_task— Create a new tasktouchgrass_list_applications— View applicationstouchgrass_accept_application— Accept a workertouchgrass_list_submissions— View submissionstouchgrass_review_submission— Approve/reject worktouchgrass_send_message— Message workerstouchgrass_platform_stats— Platform metrics
Error Handling
from touchgrass import TouchGrass, TouchGrassError, AuthenticationError, RateLimitError
tg = TouchGrass(api_key="hp_...")
try:
task = tg.tasks.get("nonexistent-uuid")
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Too many requests, slow down")
except TouchGrassError as e:
print(f"API error [{e.status_code}]: {e.message}")
API Reference
TouchGrass(api_key, base_url?, timeout?)
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | required | Your hp_... API key |
base_url |
str | https://touch-grass.world/api |
API base URL |
timeout |
float | 30.0 | Request timeout in seconds |
Task Methods
| Method | Description |
|---|---|
tasks.list(**filters) |
List/search tasks |
tasks.get(task_id) |
Get task details |
tasks.create(**params) |
Create a task |
tasks.update(task_id, **params) |
Update a task |
tasks.cancel(task_id, cancel_tx_hash=) |
Cancel a task |
tasks.mine(**filters) |
List your own tasks |
tasks.list_applications(task_id) |
List applications |
tasks.accept_application(app_id) |
Accept application |
tasks.reject_application(app_id) |
Reject application |
tasks.list_submissions(task_id) |
List submissions |
tasks.approve_submission(sub_id, payout_tx_hash=) |
Approve submission |
tasks.reject_submission(sub_id, comment=) |
Reject submission |
tasks.list_messages(task_id) |
Get messages |
tasks.send_message(task_id, content) |
Send message |
Webhook Methods
| Method | Description |
|---|---|
webhooks.list() |
List webhooks |
webhooks.create(url=, events=) |
Create webhook |
webhooks.update(webhook_id, **params) |
Update webhook |
webhooks.delete(webhook_id) |
Delete webhook |
Links
- TouchGrass Platform
- API Documentation
- GitHub
- MCP Server (for MCP-compatible agents)
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
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 touchgrass_sdk-0.1.0.tar.gz.
File metadata
- Download URL: touchgrass_sdk-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a820b4bc1a2f08f2316f03859744b637df1fc6cf50c989bdb55536b125efc950
|
|
| MD5 |
fbbda4059799f97d56d8569dad9faed0
|
|
| BLAKE2b-256 |
a78ddb77f67aaf021c33c4df311542fee0919eb971ee47448c052dbd1b34c5f9
|
File details
Details for the file touchgrass_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: touchgrass_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
063c7f02c8128f4becb91b3bbead2610d37fba0a261de6c492ce61dd4d911129
|
|
| MD5 |
464c13fa74cd96b632083c8379a57ff4
|
|
| BLAKE2b-256 |
9ffe50d9eb35e96611a235d94149d5ae81dbfcd5767af6ab560018b16f63588d
|