skillfed

knockapi

The official Python library for the knock API

knockapi v1.29.0 1.0M downloads/30d#4,453 on PyPI16
Permissive license Apache-2.0 Active released

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 knockapi

uv

uv add knockapi

poetry

poetry add knockapi

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

knock api client pythonnotification service sdkasync http client libraryrest api wrapper typedworkflow trigger automationpydantic typed api clienthttpx-based rest client
api-clientasync-supporttyped-sdk

More Python Modules packages