whatisgithub

What is hug?

hugapi/hug — explained in plain English

Analysis updated 2026-06-24

6,893PythonAudience · developerComplexity · 2/5Setup · easy

In one sentence

A Python framework that turns plain functions into web API endpoints using simple decorators, with automatic type checking, input validation, documentation generation, and versioning built in.

Mindmap

mindmap
  root((hug))
    What it does
      REST API from functions
      Auto type validation
      Auto documentation
    Key Features
      Decorator-based routing
      API versioning
      hug.test module
    Tech Stack
      Python
      Falcon
      WSGI servers
    Use Cases
      Rapid API prototyping
      Versioned endpoints
      No-boilerplate APIs
    Audience
      Python developers
      Backend engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Turn a Python function into a REST API endpoint in a few lines without writing routing or validation boilerplate.

USE CASE 2

Build a versioned API where older clients keep working while newer clients receive updated routes.

USE CASE 3

Test API endpoints without running a server by calling the original Python functions directly in unit tests.

What is it built with?

PythonFalcon

How does it compare?

hugapi/hugxuehaipan/nvitopflwrlabs/flower
Stars6,8936,8956,896
LanguagePythonPythonPython
Setup difficultyeasyeasymoderate
Complexity2/52/54/5
Audiencedeveloperdataresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Project is in maintenance mode and mostly stable but not actively developed since around 2020.

So what is it?

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.

Copy-paste prompts

Prompt 1
Using hug, show me how to expose a Python function as a GET endpoint at /greet that accepts a name parameter and returns a JSON greeting.
Prompt 2
I am building a versioned API with hugapi/hug. Show me how to define version 1 and version 2 of the same endpoint so old clients still get the v1 response.
Prompt 3
Using hug, write an endpoint that accepts a POST request with an integer and a string, validates the types automatically, and returns an error if the types are wrong.
Prompt 4
How do I test a hug API endpoint without spinning up a server? Show me how to use hug.test to simulate a GET request and check the response.

Frequently asked questions

What is hug?

A Python framework that turns plain functions into web API endpoints using simple decorators, with automatic type checking, input validation, documentation generation, and versioning built in.

What language is hug written in?

Mainly Python. The stack also includes Python, Falcon.

How hard is hug to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is hug for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.