knockapi
The official Python library for the knock API
What it is and what it does
knockapi is the official Python client for Knock's REST API, generated by Stainless. It wraps HTTP calls to Knock's notification and workflow service with a typed, object-oriented interface. Both synchronous (Knock) and asynchronous (AsyncKnock) clients are provided, powered by httpx; the async client can optionally use aiohttp for higher concurrency. All request parameters and response fields are typed using TypedDicts and Pydantic models, enabling IDE autocomplete and type checking.
The library handles pagination automatically, error classification (connection errors, 4xx/5xx responses), and retries (2x by default for transient failures, 408, 429, and 5xx errors). Responses include helper methods for serialization (to_json, to_dict). It targets developers building notification workflows, triggering campaigns, or managing user data through Knock's API.
Use it for:
- Trigger notification workflows programmatically from a Python application with typed parameters and response validation.
- Build async notification systems using AsyncKnock for high-concurrency environments without blocking I/O.
- Iterate over paginated user or message lists automatically without manual page-fetching logic.
- Handle API errors with specific exception types (RateLimitError, AuthenticationError, etc.) for granular retry/fallback logic.
- Integrate Knock notifications into a Django, FastAPI, or other Python web framework with full type hints for IDE support.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a typed Python client library for the Knock REST API, supporting both synchronous and asynchronous workflows with automatic pagination and comprehensive error handling.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and is Apache-2.0 licensed. It provides a well-typed, modern Python interface to Knock's API with both sync and async support. Install it if you need to integrate Knock notifications into a Python application.
Install
knockapi on PyPI
pip
pip install knockapiuv
uv add knockapipoetry
poetry add knockapiInstalling knockapi
Before you install
Low install friction with a pure-Python wheel distribution. The package is actively maintained with a recent release (29 days old) and supports current Python versions (3.9–3.14). Six runtime dependencies are all well-established libraries.
License in practice
Licensed under Apache-2.0 (permissive), allowing use in commercial and private projects with minimal restrictions; attribution required.
Quickstart
pip install knockapi
import os
from knockapi import Knock
client = Knock(api_key=os.environ.get("KNOCK_API_KEY"))
response = client.workflows.trigger(
key="dinosaurs-loose",
recipients=["dnedry"],
data={"dinosaur": "triceratops"},
)
print(response.workflow_run_id)
Requires Python 3.9 or later; KNOCK_API_KEY environment variable or explicit api_key parameter needed for authentication.
Verify before relying
- Whether the Knock service itself has SLA/uptime guarantees relevant to production use.
- Rate-limit behavior and backoff strategy beyond the documented 2x automatic retry default.
- Performance characteristics of auto-pagination for large result sets.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — anyio, distro, httpx, pydantic, sniffio, typing-extensions |
| Maintenance | actively maintained — 29 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,044,728/month — #4,453 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: knockapi-1.29.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
agentex-clientProvides a typed Python REST client for the…
permissive · top 15,000 on PyPI
composio-clientA Python client library for the Composio REST…
permissive · top 5,000 on PyPI
arcadepyProvides a typed Python client library for the…
permissive · top 15,000 on PyPI
opencode-aiProvides a Python client library for the…
permissive · top 15,000 on PyPI
letta-clientProvides a Python client library for the Letta…
permissive · top 15,000 on PyPI
sambanovaProvides a Python client library for accessing…
permissive · top 15,000 on PyPI
simple-rest-clientA lightweight HTTP client library for building…
unclear · top 15,000 on PyPI
braintrust-apiProvides a Python client library for the…
permissive · top 15,000 on PyPI
hiddenlayer-sdkProvides a typed Python client for the…
permissive · top 15,000 on PyPI
vkbottle-typesProvides type definitions and API method…
permissive · top 15,000 on PyPI