Skip to main content
The ticket-py package provides native Python bindings to ticket-rs, giving you full access to issue management and graph analytics from Python code.

Installation

Activating the Environment

If you used the installer script, activate the environment:
source ~/.ticket/.venv/bin/activate
Or run directly without activation:
~/.ticket/.venv/bin/python -c "import ticket_py; print(ticket_py.version())"

Quick Start

from ticket_py import Ticket
from pathlib import Path

# Initialize with your project directory
tk = Ticket(cwd=Path("/path/to/your/project"))

# Get issues ready to work on
ready = tk.ready()
for issue in ready:
    print(f"{issue.id}: {issue.title}")

# Get repository statistics
stats = tk.stats()
print(f"Total issues: {stats.total}")
print(f"Open: {stats.open}")

API Reference

The Ticket Class

The main interface for interacting with your issues.
from ticket_py import Ticket
from pathlib import Path

tk = Ticket(cwd=Path.cwd())

Methods

MethodDescriptionReturns
ready(limit=None)Get issues with no open blockersList[Issue]
list_issues()List all issuesList[Issue]
show(issue_id)Get a specific issueIssue
stats()Get repository statisticsStats
triage()Get AI recommendationsTriageResult
priority(limit=10)Get PageRank priority rankingList[PriorityItem]

Module Functions

You can also use the module-level functions directly:
import ticket_py

# Get version
print(ticket_py.version())

# List all issues (uses current directory)
issues = ticket_py.list_issues()

# Get ready issues
ready = ticket_py.ready_issues(limit=5)

# Show specific issue
issue = ticket_py.show_issue("tk-abc123")

# Create an issue
new_id = ticket_py.create_issue(
    title="Implement feature X",
    description="Details here...",
    issue_type="feature",
    priority=1
)

# Update an issue
ticket_py.update_issue(
    issue_id="tk-abc123",
    status="in_progress"
)

# Get statistics
stats = ticket_py.stats()

# Get triage recommendations
triage = ticket_py.triage()

# Get priority ranking
priorities = ticket_py.priority(limit=10)

Data Types

Issue

@dataclass
class Issue:
    id: str
    title: str
    status: str
    issue_type: str
    priority: int
    deps: List[str]
    labels: List[str]
    assignee: Optional[str]
    body: str
    created: datetime
    updated: datetime

Stats

@dataclass
class Stats:
    total: int
    open: int
    in_progress: int
    closed: int
    blocked: int

TriageResult

@dataclass
class TriageResult:
    health_score: float
    quick_wins: List[Issue]
    blockers_to_clear: List[Issue]
    recommendations: List[str]

Examples

Find High-Priority Ready Issues

from ticket_py import Ticket
from pathlib import Path

tk = Ticket(cwd=Path.cwd())

# Get ready issues sorted by priority
ready = tk.ready()
high_priority = [i for i in ready if i.priority <= 1]

for issue in high_priority:
    print(f"[P{issue.priority}] {issue.id}: {issue.title}")

Batch Create Issues

import ticket_py

tasks = [
    ("Set up CI/CD", "task", 1),
    ("Write documentation", "task", 2),
    ("Add unit tests", "task", 2),
]

for title, issue_type, priority in tasks:
    issue_id = ticket_py.create_issue(
        title=title,
        issue_type=issue_type,
        priority=priority
    )
    print(f"Created: {issue_id}")

Export Issues to JSON

import ticket_py
import json

issues = ticket_py.list_issues()
data = [
    {
        "id": i.id,
        "title": i.title,
        "status": i.status,
        "priority": i.priority,
    }
    for i in issues
]

with open("issues.json", "w") as f:
    json.dump(data, f, indent=2)

Integration with pandas

import ticket_py
import pandas as pd

issues = ticket_py.list_issues()
df = pd.DataFrame([
    {
        "id": i.id,
        "title": i.title,
        "status": i.status,
        "type": i.issue_type,
        "priority": i.priority,
        "deps_count": len(i.deps),
    }
    for i in issues
])

# Analyze by status
print(df.groupby("status").size())

# Find issues with most dependencies
print(df.nlargest(5, "deps_count")[["id", "title", "deps_count"]])

Platform Support

Pre-built wheels are available for:
PlatformArchitecturesPython Versions
Linuxx86_64, aarch643.8 - 3.13
macOSx86_64 (Intel), arm64 (Apple Silicon)3.12
Windowsx86_643.12
If no pre-built wheel exists for your platform/Python version, installation will build from source (requires Rust toolchain).

Environment Variables

VariableDescriptionDefault
TICKET_HOMELocation for the installer’s venv~/.ticket
TK_WHEEL_VERSIONWheel version to install0.0.1

Troubleshooting

Make sure you’ve activated the virtual environment:
source ~/.ticket/.venv/bin/activate
Or reinstall:
curl -fsSL https://ticket-rs.io/install.sh | sh -s -- --pkgs=py
The package contains native Rust code. If no pre-built wheel exists for your platform, you’ll need:
  1. Rust toolchain: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Python development headers
Or use the installer script which downloads pre-built wheels.
The installer auto-detects your Python version. To use a specific version:
# Set Python version before running installer
export PATH="/path/to/python3.12/bin:$PATH"
curl -fsSL https://ticket-rs.io/install.sh | sh -s -- --pkgs=py

Next Steps