tavern
Simple testing of RESTful APIs
What it is and what it does
Tavern lets you write API tests in plain YAML files that pytest can discover and run alongside your other tests. Instead of writing Python code for each API call and assertion, you declare the request (URL, method, headers, body) and the expected response (status code, JSON structure) in a readable, version-controllable format. It integrates directly with pytest, so you get all of pytest's reporting, plugins, and CI/CD tooling for free.
The package supports testing REST APIs, MQTT message brokers, and gRPC services in the same test file. You can use pytest fixtures and hooks to extend tests, write custom validation functions in Python when YAML isn't expressive enough, and organize tests with pytest marks. It ships as a pytest plugin (auto-discovered on install), a standalone command-line tool (tavern-ci) for shell scripts, and a Python library for programmatic use.
Use it for:
- Write and maintain API contract tests in version control as YAML files that non-developers can read and modify.
- Run API tests in CI/CD pipelines against staging or test servers, integrated with pytest's reporting and failure notifications.
- Test MQTT brokers and gRPC services alongside REST APIs in a single test suite without switching frameworks.
- Validate JSON response structure and values using jmespath and jsonschema without writing custom Python assertions.
- Extend tests with Python fixtures and custom validation functions for complex scenarios while keeping simple tests declarative.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Tavern is a pytest plugin and command-line tool for automated testing of RESTful APIs, MQTT-based APIs, and gRPC services using a YAML-based test syntax.
Yes. Tavern is actively maintained, has no known vulnerabilities, and solves a real problem—making API tests readable and maintainable. The YAML syntax is genuinely easier to write and review than Python test code for straightforward cases, and the pytest integration means you don't sacrifice tooling or ecosystem. Low install friction and permissive licensing add no friction. Best for teams that value test readability and want to keep API tests in version control as documentation.
Install
tavern on PyPI
pip
pip install tavernuv
uv add tavernpoetry
poetry add tavernInstalling tavern
Before you install
Low install friction with a pure-Python wheel distribution. Active maintenance with a recent release (61 days ago) and ongoing commits. Depends on 10 runtime packages including pytest, requests, and validation libraries—all standard, well-maintained tools.
License in practice
Permissive license (MIT) means you can use, modify, and distribute Tavern freely in commercial and private projects without restriction.
Quickstart
pip install tavern[pytest]
# Create test_api.tavern.yaml:
# ---
# test_name: Test API endpoint
# stages:
# - name: GET request
# request:
# url: https://api.example.com/data
# method: GET
# response:
# status_code: 200
pytest test_api.tavern.yaml -v
Requires Python 3.11 or later. Best used with pytest; standalone CLI tool tavern-ci available but pytest integration is the recommended path.
Verify before relying
- Whether the 10 runtime dependencies are all required for basic use or if some are optional for specific features.
- Performance characteristics when testing high-volume or long-running API test suites.
- Extent of custom Python validation function support and how it compares to other frameworks.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 10 — PyYAML, jmespath, jsonschema, pyjwt, pykwalify, pytest, python-box, requests, simpleeval, stevedore |
| Maintenance | actively maintained — 61 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 267,069/month — #8,297 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tavern-3.6.1-py3-none-any.whl
Keywords: testing, pytest
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
grpcio-testingProvides testing utilities and fixtures for…
permissive · top 15,000 on PyPI
pytest-onlyA pytest plugin that runs only tests marked…
permissive · top 15,000 on PyPI
pytest-playwright-asyncioA pytest plugin that integrates Playwright…
permissive · top 15,000 on PyPI
pytest-cacheA pytest plugin that persists test state across…
permissive · top 15,000 on PyPI
pytest-grpcA pytest plugin that provides fixtures to write…
permissive · top 15,000 on PyPI
pytest-prettyA pytest plugin that formats test output with…
permissive · top 5,000 on PyPI
pytest-pep8A pytest plugin that integrates PEP8 style…
permissive · top 15,000 on PyPI
qase-python-commonsProvides core configuration and SDK…
permissive · top 15,000 on PyPI
pytest-playwrightA pytest plugin that integrates Playwright…
permissive · top 5,000 on PyPI
pytest-regressionsProvides pytest fixtures for writing regression…
permissive · top 5,000 on PyPI