skillfed

cornice

Define Web Services in Pyramid.

cornice v6.1.0 142.7K downloads/30d#11,202 on PyPI389
Copyleft 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/. Active released

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 cornice

uv

uv add cornice

poetry

poetry add cornice

Installing 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

Framework :: PylonsLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Programming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: Implementation :: CPythonTopic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: WSGI :: Application

Tags

REST API framework pyramidweb service decoratorspyramid request validationAPI documentation generationREST endpoint helperspyramid web servicesHTTP service building
rest-apipyramid-extensionweb-framework

More WWW/HTTP packages