cornice
Define Web Services in Pyramid.
What it is and what it does
Cornice is a set of helpers built on top of Pyramid that simplifies defining REST web services. It provides decorators to attach HTTP methods to service endpoints, built-in validation and error handling, and tools to generate API documentation. The package is designed for developers who want to build web services within the Pyramid framework without writing boilerplate routing and validation code.
Typically used by adding service definitions with decorators that specify HTTP methods, paths, and request/response schemas. Cornice handles the routing integration with Pyramid and provides utilities for common REST patterns like content negotiation and error responses. It depends only on Pyramid as a runtime dependency, making it lightweight to add to an existing Pyramid project.
Use it for:
- Build REST APIs with Pyramid using declarative service decorators instead of manual routing configuration.
- Add automatic request validation and error handling to Pyramid endpoints without custom middleware.
- Generate API documentation from service definitions and docstrings for client developers.
- Define content-negotiated endpoints that serve different response formats based on client Accept headers.
- Implement standardized HTTP error responses and status codes across multiple service endpoints.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Cornice provides decorators and utilities to build REST web services on top of Pyramid, with built-in support for request validation, error handling, and API documentation.
Yes, if you are building REST services with Pyramid. Cornice is actively maintained, has no known vulnerabilities, and significantly reduces boilerplate for service definition and validation. The copyleft license is a consideration only if you plan proprietary use. Low install friction and a single dependency make it a practical addition to Pyramid projects.
Install
cornice on PyPI
pip
pip install corniceuv
uv add cornicepoetry
poetry add corniceInstalling cornice
Before you install
Low install friction with a single runtime dependency on pyramid. The project is actively maintained with recent commits and has been stable since its first release in 2011, indicating mature, well-tested code.
License in practice
Licensed under Mozilla Public License 2.0 (copyleft), which requires derivative works to disclose source code and license under the same terms. Suitable for open-source projects but may constrain proprietary use.
Quickstart
pip install cornice
from cornice import Service
hello = Service(name='hello', path='/hello', description='A hello service')
@hello.get()
def get_hello(request):
return {'hello': 'world'}
Requires Pyramid to be installed and configured; Cornice is an extension layer, not a standalone framework.
Verify before relying
- Whether the package supports modern Python versions beyond what the fact sheet specifies.
- The scope and maturity of built-in API documentation features compared to alternatives.
Package facts
| License | This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pyramid |
| Maintenance | actively maintained — 918 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 142,721/month — #11,202 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cornice-6.1.0-py3-none-any.whl
Keywords: web, pyramid, pylons
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
pyramidPyramid is a Python web framework for building…
permissive · top 5,000 on PyPI
pyramid-jinja2Integrates the Jinja2 templating engine with…
permissive · top 5,000 on PyPI
pyramid-makoIntegrates the Mako templating engine with the…
permissive · top 5,000 on PyPI
pyramid-debugtoolbarPyramid_debugtoolbar injects an interactive…
permissive · top 5,000 on PyPI
pyramid-retrypyramid_retry wraps Pyramid requests with…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-pyramidAdds automatic tracing and metrics collection…
permissive · top 5,000 on PyPI
pyramid-tmIntegrates Pyramid web requests with the…
permissive · top 15,000 on PyPI
Flask-RESTfulFlask-RESTful provides decorators and utilities…
permissive · top 5,000 on PyPI
factur-xGenerates, validates, and extracts Factur-X,…
permissive · top 15,000 on PyPI