Python client library for shebang.run
Project description
shebangrun Python Client
Python client library for shebang.run - a platform for hosting and sharing shell scripts with versioning, encryption, and signing.
Installation
pip install shebangrun
Or install from source:
cd python
pip install -e .
Quick Start
Simple Script Fetching
from shebangrun import run
# Fetch a script (returns content as string)
content = run(username="mpruitt", script="bashtest")
print(content)
Execute Python Scripts
from shebangrun import run
# Fetch and execute with confirmation prompt
run(username="mpruitt", script="myscript", eval=True)
# Execute without confirmation (use with caution!)
run(username="mpruitt", script="myscript", eval=True, accept=True)
Working with Versions
from shebangrun import run
# Get latest version
content = run(username="mpruitt", script="deploy", version="latest")
# Get specific version
content = run(username="mpruitt", script="deploy", version="v5")
# Get tagged version
content = run(username="mpruitt", script="deploy", version="dev")
Private Scripts
from shebangrun import run
# Access private script with share token
content = run(
username="mpruitt",
script="private-script",
token="your-share-token-here"
)
Full API Client
For more advanced usage, use the ShebangClient class:
from shebangrun import ShebangClient
# Initialize client
client = ShebangClient(url="shebang.run")
# Login
client.login(username="myuser", password="mypassword")
# Create a script
client.create_script(
name="hello",
content="#!/bin/bash\necho 'Hello World'",
description="My first script",
visibility="public"
)
# List your scripts
scripts = client.list_scripts()
for script in scripts:
print(f"{script['name']} - v{script['version']}")
# Update a script (creates new version)
client.update_script(
script_id=1,
content="#!/bin/bash\necho 'Hello World v2'",
tag="dev"
)
# Generate share token for private script
token = client.generate_share_token(script_id=1)
print(f"Share URL: https://shebang.run/myuser/myscript?token={token}")
# Get script metadata
meta = client.get_metadata(username="mpruitt", script="bashtest")
print(f"Version: {meta['version']}, Size: {meta['size']} bytes")
# Verify signature
verification = client.verify_signature(username="mpruitt", script="bashtest")
print(f"Signed: {verification['signed']}")
Key Management
from shebangrun import ShebangClient
client = ShebangClient(url="shebang.run")
client.login(username="myuser", password="mypassword")
# Generate a new keypair
key = client.generate_key(name="my-signing-key")
print(f"Public Key: {key['public_key']}")
print(f"Private Key: {key['private_key']}") # Save this securely!
# List keys
keys = client.list_keys()
for key in keys:
print(f"{key['name']} - Created: {key['created_at']}")
# Import existing public key
client.import_key(
name="imported-key",
public_key="-----BEGIN PUBLIC KEY-----\n..."
)
# Delete a key
client.delete_key(key_id=1)
Account Management
from shebangrun import ShebangClient
client = ShebangClient(url="shebang.run")
client.login(username="myuser", password="mypassword")
# Change password
client.change_password(
current_password="oldpass",
new_password="newpass"
)
# Export all data (GDPR)
data = client.export_data()
print(f"Exported {len(data['scripts'])} scripts")
# Delete account (permanent!)
client.delete_account()
API Reference
run() Function
run(username, script, key=None, eval=False, accept=False,
url="shebang.run", version=None, token=None)
Parameters:
username(str, required): Script owner's usernamescript(str, required): Script namekey(str, optional): Private key for decryption (not yet implemented)eval(bool, optional): Execute the script in Python (default: False)accept(bool, optional): Skip confirmation when eval=True (default: False)url(str, optional): Base URL (default: "shebang.run")version(str, optional): Version tag (e.g., "latest", "v1", "dev")token(str, optional): Share token for private scripts
Returns:
- String content if
eval=False - Execution result if
eval=True
ShebangClient Class
Authentication
register(username, email, password)- Register new userlogin(username, password)- Login and get JWT token
Script Management
list_scripts()- List user's scriptsget_script(username, script, version=None, token=None)- Fetch script contentget_metadata(username, script)- Get script metadataverify_signature(username, script)- Verify script signaturecreate_script(name, content, description="", visibility="private", keypair_id=None)- Create scriptupdate_script(script_id, content=None, description=None, visibility=None, tag=None, keypair_id=None)- Update scriptdelete_script(script_id)- Delete scriptgenerate_share_token(script_id)- Generate share tokenrevoke_share_token(script_id, token)- Revoke share token
Key Management
list_keys()- List keypairsgenerate_key(name)- Generate new keypairimport_key(name, public_key)- Import public keydelete_key(key_id)- Delete keypair
Account Management
change_password(current_password, new_password)- Change passwordexport_data()- Export all data (GDPR)delete_account()- Delete account
Security Notes
⚠️ Warning: Using eval=True with accept=True will execute remote code without confirmation. Only use this with scripts you trust completely.
✅ Best Practices:
- Always review scripts before executing with
eval=True - Use
accept=False(default) to see the script before execution - Store private keys securely, never commit them to version control
- Use environment variables for tokens and credentials
- Verify script signatures when available
Examples
Automation Script
#!/usr/bin/env python3
from shebangrun import run
# Fetch deployment script and execute with confirmation
run(
username="devops",
script="deploy-prod",
version="latest",
eval=True,
accept=False # Always confirm production deployments!
)
CI/CD Integration
import os
from shebangrun import ShebangClient
client = ShebangClient()
client.login(
username=os.environ["SHEBANG_USER"],
password=os.environ["SHEBANG_PASS"]
)
# Update deployment script
client.update_script(
script_id=int(os.environ["DEPLOY_SCRIPT_ID"]),
content=open("deploy.sh").read(),
tag="latest"
)
print("Deployment script updated!")
License
MIT
Links
- Website: https://shebang.run
- Documentation: https://shebang.run/docs
- GitHub: https://github.com/shebangrun/python-client
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 shebangrun-0.1.0.tar.gz.
File metadata
- Download URL: shebangrun-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df7cdb64f5a4bdcb1fad62aee7ca6c6f6b1061bb1d46c92d679a99f913c4c3a2
|
|
| MD5 |
9245a28f4b3064ca5912373e28db31fc
|
|
| BLAKE2b-256 |
46ac0189e5195edbe96cc56a49caec4dfd9ba192cdb70f98ddf436b8e0512f15
|
File details
Details for the file shebangrun-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shebangrun-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53b2f3c3ddf1b7eeb81e0c126194af72b131d1591b6360d349ad3e2761255011
|
|
| MD5 |
93fd3f1a11c829aa1eb5bc6877ddc6bd
|
|
| BLAKE2b-256 |
b976ea0818924b4a06cf5db82ee069665e0bacb25f6b6b0b6e07f7d9bbc73fd0
|