Python SDK Reference
The Synodes Python SDK provides a robust interface for programmatically interacting with Synodes Sandboxes.
Installation
Install the Synodes Python SDK using pip:
pip install synodesOr using poetry:
poetry add synodesGetting Started
Here’s a simple example to help you get started with the Synodes Python SDK:
from synodes import Synodes
def main(): # Initialize the SDK (uses environment variables by default) synodes = Synodes()
# Create a new sandbox sandbox = synodes.create()
# Execute a command response = sandbox.process.exec("echo 'Hello, World!'") print(response.result)
if __name__ == "__main__": main()import asynciofrom synodes import AsyncSynodes
async def main(): # Initialize the SDK (uses environment variables by default) async with AsyncSynodes() as synodes: # Create a new sandbox sandbox = await synodes.create()
# Execute a command response = await sandbox.process.exec("echo 'Hello, World!'") print(response.result)
if __name__ == "__main__": asyncio.run(main())Configuration
The SDK can be configured using environment variables or by passing options to the constructor:
from synodes import Synodes, SynodesConfig
# Using environment variables (SYNODES_API_KEY, SYNODES_API_URL, SYNODES_TARGET)synodes = Synodes()
# Using explicit configurationconfig = SynodesConfig( api_key="your-api-key", api_url="https://app.synodes.io/api", target="us")synodes = Synodes(config)import asynciofrom synodes import AsyncSynodes, SynodesConfig
async def main(): try: # Using environment variables (SYNODES_API_KEY, SYNODES_API_URL, SYNODES_TARGET) synodes = AsyncSynodes() # Your async code here pass finally: await synodes.close()
# Using explicit configuration config = SynodesConfig( api_key="your-api-key", api_url="https://app.synodes.io/api", target="us" ) async with AsyncSynodes(config) as synodes: # Your code here pass
if __name__ == "__main__": asyncio.run(main())