API Reference
Socket0 Python SDK provides two main APIs:
Vault API
The local vault API for cryptographic operations and secret management.
SecretBucket
Main class for creating and managing encrypted secrets.
python
from socket0.vault.base import SecretBucket
from Cryptodome.PublicKey import RSA
# Create with RSA encryption
key_pair = RSA.generate(2048)
vault = SecretBucket.create_with_rsa(
secret="my-secret",
public_key=key_pair.publickey()
)
# Decrypt secret
secret = vault.reveal(key_pair)Methods:
create_with_rsa(secret, public_key)- Create encrypted vault with RSAreveal(private_key)- Decrypt and retrieve secretis_locked()- Check if vault is locked
Models:
PlainBucket- Unencrypted (testing only)RSABucket- RSA OAEP encryptionAESCTRBucket- AES-CTR encryptionAESGCMBucket- AES-GCM encryption with authentication
REST API Client
The async HTTP client for Socket0 REST API operations.
AsyncClient
python
import asyncio
from socket0.api.rest.client import AsyncClient
async def main():
async with AsyncClient(
api_key="your-api-key",
api_endpoint="https://api.socket0.dev"
) as client:
# Get current user info
user = await client.whoami()
print(f"Authenticated as: {user.username}")
# List accounts
accounts = await client.list_accounts()
for account in accounts:
print(f"Account: {account.name}")Methods:
whoami()- Get current authenticated userlist_accounts()- List user's accountslist_vaults(account_id)- List vaults in account
Configuration
Environment Variables
bash
export SOCKET0_ENDPOINT=https://api.socket0.dev
export SOCKET0_API_KEY=your-api-keyPython Configuration
python
from socket0.config import settings
print(settings.api_endpoint)
print(settings.api_key)Error Handling
python
from socket0.api.rest.client import AsyncClient
async def example():
try:
async with AsyncClient(api_key="key", api_endpoint="url") as client:
result = await client.whoami()
except Exception as e:
print(f"Error: {e}")Type Safety
All APIs are fully typed with Pydantic models:
python
from socket0.vault.base import SecretBucket
from socket0.api.rest.schemas.auth import WhoAmIResult
# Type hints work with IDE autocomplete
result: WhoAmIResult = ...
username: str = result.usernameFurther Reading
- Vault Guide - Learn about vault operations
- CLI Reference - Command-line interface guide