Skip to main content

Lockally for FastAPI

Official Lockally integration for FastAPI. Inject a Lockally client into any route with FastAPI's dependency system.

Install

pip install lockally-fastapi

Configure

Construct a provider and use it directly as a dependency:

from fastapi import Depends, FastAPI
from lockally_fastapi import Lockally, LockallyClient

app = FastAPI()
lockally = Lockally(api_key="lk_live_xxx")      # lk_test_xxx runs in sandbox
# lockally = Lockally(api_key="lk_live_xxx", base_url="https://api.lockally.com")

@app.post("/signup", status_code=202)
def signup(client: LockallyClient = Depends(lockally)):
    client.send_email(
        from_="alerts@yourdomain.com",
        to="user@example.com",
        subject="Welcome",
        html="<b>Thanks for signing up.</b>",
        reply_to="support@yourdomain.com",
    )

Prefer configuration from the environment? Set LOCKALLY_API_KEY (and optionally LOCKALLY_BASE_URL) and use the ready-made annotated dependency:

from lockally_fastapi import LockallyDep

@app.post("/signup", status_code=202)
def signup(client: LockallyDep):
    client.send_email(from_="alerts@yourdomain.com", to="user@example.com", subject="Hi")

to/cc/bcc/reply_to accept a single address or a list; attachments is a list of (filename, content, content_type) (content is bytes or str).

Mapping notes

  • Reply-To is sent as a header (Lockally has no reply_to field).
  • Attachments are base64-encoded as {filename, content_type, content_base64}.
  • One Idempotency-Key is generated per send (24 h dedupe window).

License

MIT © Lockally

Download files

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

Source Distribution

lockally_fastapi-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

lockally_fastapi-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file lockally_fastapi-0.1.0.tar.gz.

File metadata

  • Download URL: lockally_fastapi-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lockally_fastapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 656c8ae19d40c5dde2fc9dfa172820046c9abb6e1a07b938757dc45046b51555
MD5 abc9e2b0d45d60076157818673a07112
BLAKE2b-256 9d0d04d55331867f66791596ef7cc8c06da6054de4f14614bbdad3541b8bf904

See more details on using hashes here.

Provenance

The following attestation bundles were made for lockally_fastapi-0.1.0.tar.gz:

Publisher: publish.yml on LockallyInc/lockally-fastapi

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

File details

Details for the file lockally_fastapi-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lockally_fastapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3e3f67a663b5ee126f6bc3ea37d92f1f4f0de18f3e99e80d294efac4adab9b7
MD5 a78fe4a28114c336e2538f2805da8224
BLAKE2b-256 66b5407b3a94993b9e37f3c0add187ac2bc7bf6c68aa68f5b7ea2b2f42cb7c80

See more details on using hashes here.

Provenance

The following attestation bundles were made for lockally_fastapi-0.1.0-py3-none-any.whl:

Publisher: publish.yml on LockallyInc/lockally-fastapi

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page