A simple API client for code execution
Project description
InstaVM Client
A Python client library for interacting with a simple API.
Installation
You can install the package using pip:
pip install instavm
Usage
Basic Usage
from instavm import InstaVM, ExecutionError, NetworkError
# Create client with automatic session management
client = InstaVM(api_key='your_api_key')
try:
# Execute a command
result = client.execute("print(100**100)")
print(result)
# Get usage info for the session
usage = client.get_usage()
print(usage)
except ExecutionError as e:
print(f"Code execution failed: {e}")
except NetworkError as e:
print(f"Network issue: {e}")
finally:
client.close_session()
Context Manager (Recommended)
from instavm import InstaVM
# Automatic session cleanup
with InstaVM(api_key='your_api_key') as client:
result = client.execute("print('Hello from InstaVM!')")
print(result)
# Session automatically closed
Streaming Execution
from instavm import InstaVM
with InstaVM(api_key='your_api_key') as client:
# Real-time output streaming
for output in client.execute_streaming("pip install matplotlib && python -c 'import matplotlib; print(\"Success!\")'"):
print(f"Output: {output}")
Error Handling
from instavm import InstaVM, AuthenticationError, RateLimitError, SessionError
try:
client = InstaVM(api_key='invalid_key')
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limit exceeded - try again later")
except SessionError as e:
print(f"Session error: {e}")
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
instavm-0.2.0.tar.gz
(5.3 kB
view details)
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 instavm-0.2.0.tar.gz.
File metadata
- Download URL: instavm-0.2.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
159bd1565ee0af28aa9cf80165459524b60e95fbbf273a9f6a647f099f5e6466
|
|
| MD5 |
6a7e4de7a0793f87fe43c584dfe4779f
|
|
| BLAKE2b-256 |
9385d43b5068b80c3dfdbcd2519a2ccfa01ef63dee406775884c42165a6b0735
|
File details
Details for the file instavm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: instavm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5def93857f1b27e47bda6c62d8c4da9787199c289dda32ac8c137881a474eda8
|
|
| MD5 |
124b730a457f548e71dcf7c3170ffa12
|
|
| BLAKE2b-256 |
98881accbef0b6f7ab4171be5aefbff64da6d02eef0411334bb01f25f89b1998
|