Python wrapper for the SnipeIT REST API. SnipeIT Python API.
python -m pip install snipepyThis package is currently in alpha. Pre-release builds are published to TestPyPI and can be installed by pointing pip at the test index:
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
snipepyfrom snipepy import Snipepy
client = Snipepy.from_env()
# Query an asset
asset = client.assets.get(124)
print(asset.name, asset.asset_tag)
# List and filter
assets = client.assets.list(location_id=3, limit=50)
for a in assets.rows:
print(a.asset_tag, a.status_label.name if a.status_label else "")
# Checkout to a user
client.assets.checkout(124, checkout_to_type="user", assigned_user=11)
# Checkout to a location
client.assets.checkout(124, checkout_to_type="location", assigned_location=5)
# Checkin
client.assets.checkin(124, note="Returned after repair")
# Create an asset
new_asset = client.assets.create(
asset_tag="T00000999",
status_id=1,
model_id=3,
name="Office Laptop",
)
# Error handling
from snipepy import SnipepyNotFoundError, SnipepyAuthError, SnipepyValidationError
try:
asset = client.assets.get(999)
except SnipepyNotFoundError:
print("Asset not found")
except SnipepyAuthError:
print("Invalid API token")
except SnipepyValidationError as e:
print(f"Validation failed: {e}")| Variable | Required | Default | Description |
|---|---|---|---|
SNIPEPY_URL |
Yes | : | SnipeIT instance URL |
SNIPEPY_API_TOKEN |
Yes | : | API token |
SNIPEPY_TIMEOUT |
No | 30 |
HTTP request timeout (seconds) |
SNIPEPY_VERIFY_SSL |
No | false |
SSL verification (true/false/1/0/yes) |
cp .env.example .env
# Edit .env and fill in SNIPEPY_URL and SNIPEPY_API_TOKENThis software is provided as-is without warranty of any kind. The authors are not responsible for any damages or data loss arising from its use. Always test against a non-production SnipeIT instance before relying on this library in critical workflows.
Apache 2.0