A modern, simple, fast & flexible micro framework for building HTTP REST/RPC APIs in Go backed by OpenAPI 3 and JSON Schema.
History
Back in 2016 I was working for a small-ish company doing live video streaming services which would eventually become part of Warner Bros Discovery through a complex chain of acquisitions and a "spin-merge." We were working on pulling apart a monolithic live video transcoding application meant to run on individual physical server racks into a set of web services run and dynamically scaled in the cloud in an effort to improve reliability, resiliency, and to realize cost savings.
We started to dabble in using (an async Python framework built on top of the excellent that also powers Node.js) to build some APIs for live channel management & operations. We hand-wrote our OpenAPI and used it to generate documentation and a CLI, which was an improvement over what was there (or not) before. Other teams used the OpenAPI document to generate SDKs to interact with our service.
Unfortunately design-first was hard for us, as it is for most teams. The framework, which automatically generates OpenAPI from the code for you, eliminating the possibility of the code & OpenAPI being out of sync, with the downstream effect of the docs, CLI, and SDKs also staying in sync properly. You can also still use a design-first approach, it just involves some structures written in code to be reviewed first. Design vs. code first is a false dichotomy by which we needn't be constrained.
Separately in my personal time I evaluated the Go landscape for something like FastAPI in Go, but came away disappointed. I wondered if I could make something similar, and started to prototype what this might look like. With some excellent mentorship and a lot of rewrites, I wound up with :
[Huma] is by far my favorite web framework for Go. It is inspired by FastAPI, which is also amazing, and conforms to many RFCs for common web things...
Anyway I really like the feature set, the fact that it uses Chi, and the fact that it is still somehow relatively simple to use. I've tried other frameworks and they do not spark joy for me.
The value of a software package's ability to spark joy cannot be understated!
Huma 2.0
Since that initial release I have gotten a ton of great feedback, and alongside a brand new for more information and a deep dive on how the various features work.
Example
Here is a basic "Hello, world!" style example that implements a single API endpoint /greeting/{name} and replies with a JSON object like:
{
"message": "Hello, {name}!"
}
The {name} is replaced with whatever value is sent to the API. This example is taken directly from the :
# In one tab, run the service:
$ go run main.go
# In another tab, make a request
$ restish :8888/greeting/world
You can even see generated interactive documentation powered by Huma's OpenAPI support at
With just a few lines of code you now have a fully functional API with an OpenAPI document and generated documentation!
Further Reading
Use these links to learn more and start using Huma for your next project!
SOCIAL SHARE CARD GENERATOR