Skip to main content

Konfidant.app Python SDK

Project description

Konfidant Python SDK

Test Codacy Badge Codacy Badge

Python SDK for the Konfidant API. Encrypt and share text messages and files with time-limited, burn-after-reading links.

Requirements

  • Python 3.11+

Installation

pip install konfidant

Quick Start

from konfidant import KonfidantClient

client = KonfidantClient(api_key="your-api-key")

result = client.share_text(text="Secret message", ttl_hours=24)

print(result.share_url)

Authentication

All requests require a Bearer API key. Pass it when constructing the client:

client = KonfidantClient(api_key="your-api-key")

Configuration

client = KonfidantClient(
    api_key="your-api-key",
    base_url="https://www.konfidant.app",  # default
    timeout=120.0,                         # seconds; None disables timeout
)

Usage

Share a Text Message

Encrypts a text message and returns a share link.

result = client.share_text(text="Secret message", ttl_hours=24)

print(result.text_id)       # "9140b841-..."
print(result.share_url)     # "https://download.konfidant.app?t=..."
print(result.expires_at)    # "2026-06-01 00:00:00"
print(result.verified_burn) # True
Parameter Type Description
text str The message to encrypt
ttl_hours int How long the link is valid (hours)

Share a File (end-to-end convenience)

The simplest way to share a file. Handles the full flow: get a presigned URL, upload the file, poll until encryption is complete, return the share link.

with open("document.pdf", "rb") as f:
    data = f.read()

result = client.share_and_upload_file(
    data=data,
    size=len(data),
    filename="document.pdf",
    content_type="application/pdf",
    ttl_hours=48,
)

print(result.share_url)     # "https://download.konfidant.app?t=..."
print(result.file_id)       # "681da863-..."
print(result.expires_at)    # "2026-06-01 00:00:00"
print(result.verified_burn) # True
Parameter Type Default Description
data bytes | IO[bytes] File content
size int File size in bytes
filename str Original filename including extension
content_type str MIME type (e.g. "application/pdf")
ttl_hours int How long the link is valid (hours)
poll_interval float 2.0 Seconds between status polls
timeout float 60.0 Max seconds to wait for encryption

Share a File (step-by-step)

Use the low-level methods when you need more control — for example, to track upload progress or handle polling yourself.

Step 1 — Request a presigned upload URL:

presigned = client.share_file(
    filename="archive.zip",
    file_size=10_485_760,  # bytes
    ttl_hours=48,
)

print(presigned.upload_url) # short-lived URL
print(presigned.file_key)   # use this to poll status
print(presigned.poll_url)   # convenience poll URL

Step 2 — Upload the file:

with open("archive.zip", "rb") as f:
    client.upload_file(
        data=f,
        size=10_485_760,
        content_type="application/zip",
        presigned=presigned,
    )

Step 3 — Poll until encryption completes:

import time

while True:
    status = client.get_file_status(presigned.file_key)
    if status.status == "complete":
        print(status.share_url)
        break
    print(f"Status: {status.message}")
    time.sleep(2)

List Shares

Returns all shares for the authenticated organization.

response = client.list_shares()

for share in response.shares:
    print(share.type)            # "file" or "text"
    print(share.file_name)
    print(share.file_size_bytes)
    print(share.created_at)
    print(share.expires_at)
    print(share.accessed_at)     # None if not yet accessed
    print(share.created_by)

print(response.pagination.total)
print(response.pagination.has_more)

Filtering and pagination:

response = client.list_shares(
    type="file",     # "file" or "text"
    status="active", # "active" or "accessed"
    limit=10,
    offset=20,
)
Parameter Type Description
type str, optional Filter by share type
status str, optional Filter by access status
limit int, optional Max results to return
offset int, optional Number of results to skip

Error Handling

All API errors raise KonfidantApiError:

from konfidant import KonfidantClient, KonfidantApiError

client = KonfidantClient(api_key="your-api-key")

try:
    result = client.share_text(text="Secret", ttl_hours=24)
except KonfidantApiError as e:
    print(e.status_code)  # e.g. 401
    print(str(e))         # e.g. "Missing or invalid Authorization header."
    print(e.body)         # raw response body (dict or str)

upload_file raises KonfidantApiError if the S3 upload fails. share_and_upload_file raises TimeoutError if encryption does not complete within the configured timeout.

Development

# Install dependencies
poetry install

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=konfidant

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

konfidant-0.2.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

konfidant-0.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file konfidant-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for konfidant-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fb888be2a3515940583f22fe22d65ff203a9f4e458d2b36f32f2eace9b6d344b
MD5 310d1451dbce94ead3511fc0cbd61dc8
BLAKE2b-256 8360fb9136835780ee6892a61110bab00c720ed48a9c9fd753601bcdeea97c8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for konfidant-0.2.0.tar.gz:

Publisher: publish.yml on konfidant/sdk-py

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

File details

Details for the file konfidant-0.2.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for konfidant-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 636f5b493e198355c0b84d218c9ec5afeb44484fbb6c00c6ce560c73e79d81d8
MD5 ccb582ef574fe2c1c0ad03cc591df136
BLAKE2b-256 1f6d7243fecabd883c4bf97532e6f3eefe32bbdea253673ff518ee0477418e9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for konfidant-0.2.0-py3-none-any.whl:

Publisher: publish.yml on konfidant/sdk-py

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