Skip to content

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 RSA
  • reveal(private_key) - Decrypt and retrieve secret
  • is_locked() - Check if vault is locked

Models:

  • PlainBucket - Unencrypted (testing only)
  • RSABucket - RSA OAEP encryption
  • AESCTRBucket - AES-CTR encryption
  • AESGCMBucket - 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 user
  • list_accounts() - List user's accounts
  • list_vaults(account_id) - List vaults in account

Configuration

Environment Variables

bash
export SOCKET0_ENDPOINT=https://api.socket0.dev
export SOCKET0_API_KEY=your-api-key

Python 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.username

Further Reading

Socket0 Python SDK License - Not open source. For usage terms see /license