Turn a Python function into a REST API endpoint in a few lines without writing routing or validation boilerplate.
Build a versioned API where older clients keep working while newer clients receive updated routes.
Test API endpoints without running a server by calling the original Python functions directly in unit tests.
Project is in maintenance mode and mostly stable but not actively developed since around 2020.
Hug is a Python framework for building APIs, which are the interfaces that let one piece of software talk to another. The idea behind hug is that writing an API endpoint should feel as close as possible to writing a regular Python function. You decorate a function with a simple annotation like @hug.get, and hug automatically exposes it as a web endpoint, handles incoming requests, validates inputs, and generates documentation for the API. The whole setup to get a working web endpoint takes just a few lines of code. Hug works with HTTP methods like GET, POST, and PUT, and it handles routing, input type checking, and output formatting. When you annotate a function argument with a type like int or a custom type, hug uses that to validate and convert incoming data before it reaches your function. This means less repetitive validation code scattered throughout your logic. The same type annotations also feed into automatic documentation that hug generates and serves at a /documentation path on your running server. One notable feature is built-in API versioning. You can mark different versions of the same endpoint separately, and callers can request a specific version either through the URL path or an HTTP header. This makes it straightforward to keep older clients working while releasing changes for newer ones. Testing is designed to stay simple. Because hug does not modify the original Python functions you decorate, you can call them directly in tests without spinning up a server. Hug also provides a hug.test module that simulates HTTP calls against your API so you can test the full stack in a controlled way. Hug is built on top of Falcon, a fast HTTP library for Python. It requires Python 3 and can run on any standard server that supports the WSGI interface, including uWSGI and Gunicorn. It installs via pip. The project appears to be in maintenance mode with most of its activity predating 2020, but the library is stable and the README reflects a mature, documented feature set.
← hugapi on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.