Skip to main content

Secryn Python SDK — manage secrets, projects, and API keys programmatically

Project description

Secryn Python SDK

PyPI Python License

Python client for the Secryn secrets management API.
Manage projects, secrets, API keys, and team members programmatically.

Installation

pip install secryn

Requires Python 3.10+.

Quick Start

from secryn import SecrynClient

# Connect to your Secryn instance
client = SecrynClient(base_url="https://api.secryn.xyz/api/v1")

# Cookie-based auth
client.auth.login("user@example.com", "password")

# OR API-key-based auth
client = SecrynClient(
    base_url="https://api.secryn.xyz/api/v1",
    api_key="sc_...",
)

Usage

All API resources are accessible as namespaced sub-objects with full autocompletion support.

Auth

client.auth.login("user@example.com", "password")
client.auth.register("new@example.com", "secure123")
client.auth.logout()                # clears session cookies
client.auth.refresh()               # extends JWT session
client.auth.forgot_password("user@example.com")
client.auth.reset_password(token, "new-password")

MFA

setup = client.mfa.setup()          # returns secret + QR code URL
client.mfa.enable(token)
client.mfa.confirm(token, mfa_token)
client.mfa.recovery(code, mfa_token)
client.mfa.status()                 # -> {"enabled": True}
codes = client.mfa.recovery_codes() # -> {"codes": ["...", ...]}
client.mfa.send_backup_code("user@example.com")
client.mfa.disable()

Projects

projects = client.projects.list()
project = client.projects.create("My Project", description="Backend secrets")
info = client.projects.get(project_id)
client.projects.update(project_id, name="Renamed")
client.projects.transfer(project_id, new_owner_id)
client.projects.delete(project_id)

Members & Invites

# Invite someone to a project
client.invites.create(project_id, email="dev@team.com")

# Accept an invitation by slug
client.invites.accept("abc123")

# Manage members
client.members.add_permissions(project_id, member_id, ["READ_SECRETS"])
client.members.remove_permissions(project_id, member_id, ["READ_SECRETS"])
client.members.remove(project_id, member_id)

Secrets

# Create, read, update, delete
secret = client.secrets.create(project_id, "API_KEY", "sk-abc123", notes="Production key")
secret = client.secrets.get(secret_id)
secrets = client.secrets.list(project_id)
client.secrets.update(secret_id, value="sk-new-value")

# Export as .env
dotenv = client.secrets.export_dotenv(project_id)  # str
with open(".env", "w") as f:
    f.write(dotenv)

client.secrets.delete(secret_id)

API Keys

key = client.api_keys.create("CI/CD Pipeline", permissions=["read"])
keys = client.api_keys.list()
client.api_keys.update(key_id, name="CI Pipeline v2")
client.api_keys.delete(key_id)

Users

profile = client.users.me()         # authenticated user
user = client.users.get(user_id)
client.users.update(name="New Name", email="new@example.com")
client.users.delete()               # deletes authenticated account

Error Handling

from secryn import SecrynApiError

try:
    client.secrets.get("nonexistent")
except SecrynApiError as e:
    print(e.status_code)  # 404
    print(e.code)         # "NOT_FOUND"
    print(e.message)      # "Secret not found"
    print(e.details)      # Optional structured context

Configuration

Param Default Description
base_url http://localhost:3000/api/v1 API base URL with /api/v1 prefix
api_key None Optional API key for programmatic access
user_agent secryn-sdk-python/1.0.0 Custom User-Agent header

License

Apache 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secryn-1.0.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secryn-1.0.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file secryn-1.0.1.tar.gz.

File metadata

  • Download URL: secryn-1.0.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for secryn-1.0.1.tar.gz
Algorithm Hash digest
SHA256 53572062d97b23c99a89c44af83961a4cceb7b3a16f193d688fdd8c8d07985bc
MD5 1e48235d47a642db3cc4e0a5b7d94017
BLAKE2b-256 088f6cc5fb267c4637c1836bf451c3d32f2de2cb01cd994c89ac40fe0494ed39

See more details on using hashes here.

Provenance

The following attestation bundles were made for secryn-1.0.1.tar.gz:

Publisher: publish-sdk-py.yaml on P4ciuf/secryn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secryn-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: secryn-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for secryn-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39537f35c3738837ff29d12cb5a6cf44d8d89efc146da06bf605a7e9d0f8ada8
MD5 b706f46c057f7d330979dd059cded89e
BLAKE2b-256 8e8b8c891b6e90fddb6da608e7714522e20a74ef77699ec03690f953d4ac34ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for secryn-1.0.1-py3-none-any.whl:

Publisher: publish-sdk-py.yaml on P4ciuf/secryn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page