PAK.sh API Documentation
Complete API reference for Package Automation Kit - CLI and Web interfaces
Overview
PAK.sh provides a comprehensive API system with two main interfaces for package automation across 30+ platforms.
Command-line interface for automation and scripting
- 300+ commands
- Module system
- Platform integration
- Security scanning
RESTful web interface for applications and dashboards
- Authentication system
- Project management
- Deployment tracking
- Telemetry collection
CLI API
Command-line interface for automation and scripting across multiple platforms.
Core Commands
Module Commands
pak.sh core <command>
essential
Core system commands for status and health checks
✓ All systems operational
$ pak.sh core version
PAK.sh v2.0.0
pak.sh platform <command>
Platform management and configuration
npm, pypi, maven, nuget, cargo...
$ pak.sh platform test npm
✓ npm: Connection successful
pak.sh deploy <command>
Deployment operations across platforms
📦 Deploying to npm, pypi, cargo...
✓ All platforms deployed successfully
Advanced Commands
Flask Web API
RESTful web interface for web applications and dashboards with authentication and project management.
All API endpoints are relative to: https://your-pak-instance.com
Authentication Endpoints
User authentication endpoint for login, register, and password reset.
Login Request
POST /auth
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"action": "login"
}
Login Response
{
"success": true,
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe",
"role": "user"
}
}
Register Request
POST /auth
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "password123",
"name": "New User",
"action": "register"
}
Password Reset Request
POST /auth
Content-Type: application/json
{
"email": "user@example.com",
"action": "reset"
}
User logout endpoint to invalidate session.
{
"success": true,
"message": "Logged out successfully"
}
Project Management
List all projects for the authenticated user.
{
"projects": [
{
"id": 1,
"name": "my-package",
"description": "My awesome package",
"status": "active",
"created_at": "2024-01-01T00:00:00Z"
}
]
}
Get detailed information about a specific project.
{
"project": {
"id": 1,
"name": "my-package",
"description": "My awesome package",
"config_path": "/path/to/config",
"status": "active",
"created_at": "2024-01-01T00:00:00Z",
"deployments": [
{
"id": 1,
"environment": "production",
"status": "success",
"created_at": "2024-01-01T00:00:00Z"
}
]
}
}
Deployment Endpoints
Deploy a project to specified environment.
POST /deploy/my-package
Content-Type: application/json
{
"environment": "production",
"version": "1.2.3"
}
{
"success": true,
"deployment_id": "deploy_123",
"status": "pending"
}
Package a project for distribution.
POST /package/my-package
Content-Type: application/json
{
"version": "1.2.3"
}
{
"success": true,
"package_path": "/path/to/package.tar.gz"
}
Telemetry & Webhooks
Submit telemetry data for analytics and monitoring.
POST /api/telemetry
Content-Type: application/json
{
"event": "package_deployed",
"package": "my-package",
"version": "1.2.3",
"platform": "npm",
"timestamp": "2024-01-01T00:00:00Z",
"metadata": {
"deployment_time": 45.2,
"file_size": 1024000
}
}
Webhook endpoint for external telemetry data.
POST /webhook/telemetry
Content-Type: application/json
X-PAK-Signature: sha256=abc123...
{
"source": "external_system",
"data": {
"event": "deployment_completed",
"package": "my-package"
}
}
Platform Integration
PAK.sh supports 30+ package platforms with unified configuration and deployment.
JavaScript package registry
{
"name": "npm",
"type": "javascript",
"registry": "https://registry.npmjs.org",
"api": "https://registry.npmjs.org",
"commands": {
"publish": "npm publish",
"info": "npm info {package}"
}
}
Python package index
{
"name": "pypi",
"type": "python",
"registry": "https://pypi.org",
"api": "https://pypi.org/pypi",
"commands": {
"publish": "twine upload dist/*",
"info": "pip show {package}"
}
}
Java repository system
{
"name": "maven",
"type": "java",
"registry": "https://repo1.maven.org/maven2",
"api": "https://search.maven.org/solrsearch",
"commands": {
"publish": "mvn deploy",
"info": "mvn dependency:tree"
}
}
Database Models
SQLAlchemy models for user management, projects, and deployments.
User Management
User Model
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255), unique=True, nullable=False)
password_hash = db.Column(db.String(255), nullable=False)
name = db.Column(db.String(255), nullable=False)
role = db.Column(db.String(50), default='user')
is_active = db.Column(db.Boolean, default=True)
email_verified = db.Column(db.Boolean, default=False)
created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
last_login = db.Column(db.DateTime)
failed_attempts = db.Column(db.Integer, default=0)
locked_until = db.Column(db.DateTime)
Project Model
class PakProject(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), unique=True, nullable=False)
description = db.Column(db.Text)
config_path = db.Column(db.String(500))
status = db.Column(db.String(50), default='active')
created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
created_by = db.Column(db.Integer, db.ForeignKey('users.id'))
Configuration
Environment variables and configuration files for PAK.sh system.
Environment Variables
Configuration File
pak.conf
# PAK.sh Configuration
# Core Settings
PAK_VERSION="2.0.0"
PAK_DATA_DIR="/opt/pak/data"
PAK_LOGS_DIR="/opt/pak/logs"
PAK_CONFIG_DIR="/opt/pak/config"
# Platform Settings
PAK_PLATFORMS="npm pypi maven nuget crates docker helm"
PAK_HEALTH_CHECK_INTERVAL=300
# Security Settings
PAK_API_KEY="your_api_key"
PAK_API_SECRET="your_api_secret"
PAK_API_RATE_LIMIT=100
# Logging Settings
PAK_LOG_LEVEL="INFO"
PAK_LOG_FORMAT="json"
PAK_LOG_RETENTION_DAYS=30
Examples
Practical examples for integrating PAK.sh into your workflow.
Python Integration
Basic Package Deployment
import requests
# Login to PAK.sh
response = requests.post('http://localhost:5000/auth', json={
'email': 'user@example.com',
'password': 'password123',
'action': 'login'
})
# Deploy package
response = requests.post('http://localhost:5000/deploy/my-package', json={
'environment': 'production',
'version': '1.2.3'
}, cookies=session.cookies)
print(response.json())
Webhook Integration
Custom Webhook Handler
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/webhook/pak', methods=['POST'])
def pak_webhook():
# Verify webhook signature
signature = request.headers.get('X-PAK-Signature')
if not verify_signature(request.data, signature):
return jsonify({'error': 'Invalid signature'}), 401
# Process webhook data
data = request.json
event = data.get('event')
if event == 'package_deployed':
package = data.get('package')
version = data.get('version')
print(f"Package {package} version {version} deployed")
return jsonify({'status': 'success'})