SDK library

Browse the docs by language.

Python, TypeScript, and PHP are live now. Each route documents the same Dilnaka upload lifecycle in the conventions of its own runtime.

View docs hub

Documentation

Dilnaka Python SDK

Python SDK for uploading files through the Dilnaka Upload API. The SDK reads the API key from .env by default, asks your Dilnaka backend for a presigned S3 upload URL, uploads the file directly to S3, and then calls the completion endpoint.

PyPI installation

Install the published package from PyPI, then let the client load credentials from .env by default.

Direct-to-S3 upload

Files go straight to S3 using a temporary presigned URL, while your backend remains the source of truth.

Backend contract

The SDK expects a small set of file-management endpoints from your Caspian backend.

Setup

Install from PyPI

Install the published Dilnaka Python SDK from PyPI. The package is available online now, so the old editable test install flow is no longer part of the docs.

Package: pypi.org/project/dilnaka

bash
pip install dilnaka

Configuration

Configure .env

The SDK only needs your API key in .env. It is built specifically for Dilnaka Storage.

Required .env
DILNAKA_API_KEY=dlk_dev_your_api_key_here
Optional .env override
DILNAKA_TIMEOUT=60

Optional: set DILNAKA_TIMEOUT if you want a custom request timeout.

Core flow

Basic upload

Instantiate the client with environment defaults and upload a file with a single method call.

python
from dilnaka import Dilnaka

client = Dilnaka()

uploaded = client.upload("./test-upload.txt")

print(uploaded.id)
print(uploaded.key)
print(uploaded.status)

Alternate setup

Explicit API key

Pass values directly only when you want to avoid environment variables.

python
from dilnaka import Dilnaka

client = Dilnaka(
    api_key="dlk_dev_your_api_key_here",
)

uploaded = client.upload("./avatar.png", folder="avatars")
print(uploaded)

Quota model

Storage and Bandwidth Limits

Storage is the total size of the files you keep in Dilnaka. Bandwidth is the total amount of file data downloaded or served by users and applications during the current billing month.

Uploads do not count toward bandwidth. Reads and downloads do count because Dilnaka is authorizing delivery from your S3-backed file store.

Free accounts stop serving files after the included monthly bandwidth is exhausted. Paid plans can continue serving files with storage and bandwidth overage billing until the plan safety cap is reached.

Free

2 GB storage and 5 GB/month bandwidth. Best for testing and small prototypes. No overage. File serving pauses when the monthly bandwidth limit is reached.

Pro

100 GB storage and 50 GB/month bandwidth. Extra storage is billed at $0.08/GB and extra bandwidth at $0.12/GB. Service keeps running until the 500 GB monthly safety cap.

Usage-Based

250 GB storage and 150 GB/month bandwidth. Extra storage is billed at $0.08/GB and extra bandwidth at $0.12/GB. Service keeps running until the 1 TB monthly safety cap.

Backend contract

Expected backend endpoints

The SDK expects your Caspian backend to expose the following endpoints.

txt
POST /v1/uploads/presign
POST /v1/uploads/complete
GET  /v1/files
GET  /v1/files/{file_id}
GET  /v1/files/{file_id}/access-url?expiresIn=1200
DELETE /v1/files/{file_id}

Use the access-url endpoint when you need a temporary read URL for one file. Pass expiresIn in seconds to request a shorter or longer lifetime. When omitted, Dilnaka uses the app default signed URL TTL.

API payloads

Presign and complete response shapes

json: presign response
{
  "fileId": "clx_file_id",
  "fileKey": "uploads/2026/05/clx_file_id-test.txt",
  "uploadUrl": "https://s3-presigned-url",
  "expiresIn": 300,
  "method": "PUT",
  "headers": {
    "Content-Type": "text/plain"
  }
}
json: complete response
{
  "fileId": "clx_file_id",
  "status": "uploaded",
  "key": "uploads/2026/05/clx_file_id-test.txt",
  "originalName": "test.txt",
  "contentType": "text/plain",
  "size": 94,
  "publicUrl": null
}
json: access-url response
{
  "fileId": "clx_file_id",
  "url": "https://s3-presigned-url",
  "expiresIn": 1200,
  "isTemporary": true
}
json: bandwidth limit exceeded
{
  "success": false,
  "error": "bandwidth_limit_exceeded",
  "message": "Monthly bandwidth limit exceeded. Upgrade your plan or wait until the next billing cycle."
}
json: paid overage active example
{
  "success": true,
  "warning": "bandwidth_overage_active",
  "message": "This account has exceeded included bandwidth. Extra usage will be billed."
}
json: paid safety cap reached
{
  "success": false,
  "error": "bandwidth_hard_cap_reached",
  "message": "Monthly bandwidth hard cap reached. Contact Dilnaka support to continue serving files."
}

Examples

Common usage patterns

Temporary file access URL

from dilnaka import Dilnaka

client = Dilnaka()

        access = client.get_file_access_url(
          "maext0cfjsquw2mu9o597fb9",
          expires_in=1200,
        )

        print(access.url)
        print(access.expires_in)

Delete file

from dilnaka import Dilnaka

client = Dilnaka()

file_id = "maext0cfjsquw2mu9o597fb9"
result = client.delete_file(file_id)

print(result)

Upload file

from dilnaka import Dilnaka

client = Dilnaka()

uploaded = client.upload("./test-upload.txt", folder="uploads")

print("Uploaded file:")
print(f"  id: {uploaded.id}")
print(f"  key: {uploaded.key}")
print(f"  status: {uploaded.status}")
print(f"  size: {uploaded.size}")
print(f"  content_type: {uploaded.content_type}")

File list

from dilnaka import Dilnaka

client = Dilnaka()

for file in client.list_files():
    print(f"{file.id} | {file.status} | {file.key}")

Pricing example

Bandwidth overage example

Pro plan example: you get 100 GB of storage and 50 GB/month of included bandwidth. If your app serves 70 GB in one month, the extra 20 GB is billed as bandwidth overage and service keeps running. Dilnaka only blocks delivery if the plan later reaches its 500 GB monthly safety cap.

Security

Security model

The SDK never receives AWS credentials. It only receives a temporary presigned upload URL from your Dilnaka backend.

Your backend remains responsible for API key validation, scope checking, file validation, S3 key generation, metadata persistence, upload completion verification, and temporary read URL expiration.