{"id":13602153,"url":"https://github.com/danielgtaylor/huma","last_synced_at":"2026-01-18T15:11:24.098Z","repository":{"id":38820132,"uuid":"245763170","full_name":"danielgtaylor/huma","owner":"danielgtaylor","description":"Huma REST/HTTP API Framework for Golang with OpenAPI 3.1","archived":false,"fork":false,"pushed_at":"2025-05-09T23:56:52.000Z","size":11597,"stargazers_count":3050,"open_issues_count":109,"forks_count":201,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-05-10T00:28:14.236Z","etag":null,"topics":["api","documentation","fastapi","framework","golang","golang-library","hacktoberfest","huma","json-schema","openapi","openapi-server","openapi3","openapi31","rest","rest-api","swagger-ui","web"],"latest_commit_sha":null,"homepage":"https://huma.rocks/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielgtaylor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["danielgtaylor"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2020-03-08T06:19:51.000Z","updated_at":"2025-05-10T00:12:57.000Z","dependencies_parsed_at":"2023-12-10T18:23:45.267Z","dependency_job_id":"caa90649-99a8-4d5f-89e1-f6dc26a89da7","html_url":"https://github.com/danielgtaylor/huma","commit_stats":{"total_commits":733,"total_committers":71,"mean_commits":10.32394366197183,"dds":"0.42291950886766716","last_synced_commit":"be8d9606655709b97bc8606fb2231fc965905519"},"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fhuma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fhuma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fhuma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fhuma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgtaylor","download_url":"https://codeload.github.com/danielgtaylor/huma/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253929359,"owners_count":21985802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","documentation","fastapi","framework","golang","golang-library","hacktoberfest","huma","json-schema","openapi","openapi-server","openapi3","openapi31","rest","rest-api","swagger-ui","web"],"created_at":"2024-08-01T18:01:15.365Z","updated_at":"2026-01-18T15:11:24.092Z","avatar_url":"https://github.com/danielgtaylor.png","language":"Go","readme":"\u003ca href=\"#\"\u003e\n\t\u003cpicture\u003e\n\t\t\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://huma.rocks/huma-dark.png\" /\u003e\n\t\t\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://huma.rocks/huma.png\" /\u003e\n\t\t\u003cimg alt=\"Huma Logo\" src=\"https://huma.rocks/huma.png\" /\u003e\n\t\u003c/picture\u003e\n\u003c/a\u003e\n\n[![HUMA Powered](https://img.shields.io/badge/Powered%20By-HUMA-f40273)](https://huma.rocks/) [![CI](https://github.com/danielgtaylor/huma/workflows/CI/badge.svg?branch=main)](https://github.com/danielgtaylor/huma/actions?query=workflow%3ACI+branch%3Amain++) [![codecov](https://codecov.io/gh/danielgtaylor/huma/branch/main/graph/badge.svg)](https://codecov.io/gh/danielgtaylor/huma) [![Docs](https://godoc.org/github.com/danielgtaylor/huma/v2?status.svg)](https://pkg.go.dev/github.com/danielgtaylor/huma/v2?tab=doc) [![Go Report Card](https://goreportcard.com/badge/github.com/danielgtaylor/huma/v2)](https://goreportcard.com/report/github.com/danielgtaylor/huma/v2)\n\n[**🌎中文文档**](./README_CN.md)\n[**🇯🇵日本語ドキュメント**](./README_JA.md)\n\n- [What is huma?](#intro)\n- [Install](#install)\n- [Example](#example)\n- [Documentation](#documentation)\n\n\u003ca name=\"intro\"\u003e\u003c/a\u003e\nA modern, simple, fast \u0026 flexible micro framework for building HTTP REST/RPC APIs in Go backed by OpenAPI 3 and JSON Schema. Pronounced IPA: [/'hjuːmɑ/](https://en.wiktionary.org/wiki/Wiktionary:International_Phonetic_Alphabet). The goals of this project are to provide:\n\n- Incremental adoption for teams with existing services\n  - Bring your own router (including Go 1.22+), middleware, and logging/metrics\n  - Extensible OpenAPI \u0026 JSON Schema layer to document existing routes\n- A modern REST or HTTP RPC API backend framework for Go developers\n  - Described by [OpenAPI 3.1](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md) \u0026 [JSON Schema](https://json-schema.org/)\n- Guard rails to prevent common mistakes\n- Documentation that can't get out of date\n- High-quality generated developer tooling\n\nFeatures include:\n\n- Declarative interface on top of your router of choice:\n  - Operation \u0026 model documentation\n  - Request params (path, query, header, or cookie)\n  - Request body\n  - Responses (including errors)\n  - Response headers\n- JSON Errors using [RFC9457](https://datatracker.ietf.org/doc/html/rfc9457) and `application/problem+json` by default (but can be changed)\n- Per-operation request size limits with sane defaults\n- [Content negotiation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation) between server and client\n  - Support for JSON ([RFC 8259](https://tools.ietf.org/html/rfc8259)) and optionally CBOR ([RFC 7049](https://tools.ietf.org/html/rfc7049)) content types via the `Accept` header with the default config.\n- Conditional requests support, e.g. `If-Match` or `If-Unmodified-Since` header utilities.\n- Optional automatic generation of `PATCH` operations that support:\n  - [RFC 7386](https://www.rfc-editor.org/rfc/rfc7386) JSON Merge Patch\n  - [RFC 6902](https://www.rfc-editor.org/rfc/rfc6902) JSON Patch\n  - [Shorthand](https://github.com/danielgtaylor/shorthand) patches\n- Annotated Go types for input and output models\n  - Generates JSON Schema from Go types\n  - Static typing for path/query/header params, bodies, response headers, etc.\n  - Automatic input model validation \u0026 error handling\n- Documentation generation using [Stoplight Elements](https://stoplight.io/open-source/elements)\n- Optional CLI built-in, configured via arguments or environment variables\n  - Set via e.g. `-p 8000`, `--port=8000`, or `SERVICE_PORT=8000`\n  - Startup actions \u0026 graceful shutdown built-in\n- Generates OpenAPI for access to a rich ecosystem of tools\n  - Mocks with [API Sprout](https://github.com/danielgtaylor/apisprout) or [Prism](https://stoplight.io/open-source/prism)\n  - SDKs with [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) or [oapi-codegen](https://github.com/deepmap/oapi-codegen)\n  - CLI with [Restish](https://rest.sh/)\n  - And [plenty](https://openapi.tools/) [more](https://apis.guru/awesome-openapi3/category.html)\n- Generates JSON Schema for each resource using optional `describedby` link relation headers as well as optional `$schema` properties in returned objects that integrate into editors for validation \u0026 completion.\n\nThis project was inspired by [FastAPI](https://fastapi.tiangolo.com/). Logo \u0026 branding designed by Kari Taylor.\n\n## Sponsors\n\nA big thank you to our current \u0026 former sponsors!\n\n\u003cdiv\u003e\n\t\t\t\t\t\u003cimg width=\"1000\" height=\"0\" /\u003e\n\t\t\t\t\t\u003ca href=\"https://zuplo.link/huma-gh \"\u003e\n\t\t\t\t\t\u003cpicture\u003e\n\t\t\t\t\t\t\t\u003c!-- \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs/zuplo-dark.png\"\u003e --\u003e\n\t\t\t\t\t\t\t\u003cimg src=\"https://github.com/user-attachments/assets/aace5aa7-32bd-45cf-a8f8-2e352feaf017\" alt=\"Zuplo\" width=\"260\" align=\"right\"\u003e\n\t\t\t\t\t\u003c/picture\u003e\n\t\t\t\t\t\u003c/a\u003e\n\t\t\t\t\t\u003ch3\u003eZuplo: Scale, Protect, and Productize your Huma API\u003c/h3\u003e\n\t\t\t\t\t\u003cp\u003e\n\t\t\t\t\t\t\tOur API Gateway allows you to secure your API, scale it globally, generate documentation from your OpenAPI, and monetize your users.\n\t\t\t\t\t\u003c/p\u003e\n\t\t\t\t\t\u003ca href=\"https://zuplo.link/huma-gh \"\u003eStart for Free\u003c/a\u003e\n\u003c/div\u003e\n\u003chr/\u003e\n\n- [@bclements](https://github.com/bclements)\n- [@bekabaz](https://github.com/bekabaz)\n- [@victoraugustolls](https://github.com/victoraugustolls)\n- [@phoenixtechnologies-io](https://github.com/phoenixtechnologies-io)\n- [@chenjr0719](https://github.com/chenjr0719)\n- [@vinogradovkonst](https://github.com/vinogradovkonst)\n- [@miyamo2](https://github.com/miyamo2)\n- [@nielskrijger](https://github.com/nielskrijger)\n\n## Testimonials\n\n\u003e This 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 ... I really like the feature set, the fact that it [can use] 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. - [Jeb_Jenky](https://www.reddit.com/r/golang/comments/zhitcg/comment/izmg6vk/?utm_source=reddit\u0026utm_medium=web2x\u0026context=3)\n\n\u003e After working with #Golang for over a year, I stumbled upon Huma, the #FastAPI-inspired web framework. It’s the Christmas miracle I’ve been hoping for! This framework has everything! - [Hana Mohan](https://twitter.com/unamashana/status/1733088066053583197)\n\n\u003e I love Huma. Thank you, sincerely, for this awesome package. I’ve been using it for some time now and it’s been great! - [plscott](https://www.reddit.com/r/golang/comments/1aoshey/comment/kq6hcpd/?utm_source=reddit\u0026utm_medium=web2x\u0026context=3)\n\n\u003e Thank you Daniel for Huma. Superbly useful project and saves us a lot of time and hassle thanks to the OpenAPI gen — similar to FastAPI in Python. - [WolvesOfAllStreets](https://www.reddit.com/r/golang/comments/1aqj99d/comment/kqfqcml/?utm_source=reddit\u0026utm_medium=web2x\u0026context=3)\n\n\u003e Huma is wonderful, I've started working with it recently, and it's a pleasure, so thank you very much for your efforts 🙏 - [callmemicah](https://www.reddit.com/r/golang/comments/1b32ts4/comment/ksvr9h7/?utm_source=reddit\u0026utm_medium=web2x\u0026context=3)\n\n\u003e It took us 3 months to build our platform in Python with FastAPI, SQL Alchemy and only 3 weeks to rewrite it in Go with Huma and SQL C. Things just work and I seldomly have to debug where in Python I spent a majority of my time debugging. - [Bitclick\\_](https://www.reddit.com/r/golang/comments/1cj2znb/comment/l2e4u6y/)\n\n\u003e Look at Huma, it's great. A nice slim layer on top of stdlib mux/chi and automatic body and parameter serialization, kinda feels like doing dotnet web APIs, but forces you to actually design request and response structs, which is great imo. - [Kirides](https://www.reddit.com/r/golang/comments/1fnn5c2/comment/lokuvpo/)\n\n# Install\n\nInstall via `go get`. Note that Go 1.23 or newer is required.\n\n```sh\n# After: go mod init ...\ngo get -u github.com/danielgtaylor/huma/v2\n```\n\n# Example\n\nHere is a complete basic hello world example in Huma, that shows how to initialize a Huma app complete with CLI, declare a resource operation, and define its handler function.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/danielgtaylor/huma/v2\"\n\t\"github.com/danielgtaylor/huma/v2/adapters/humachi\"\n\t\"github.com/danielgtaylor/huma/v2/humacli\"\n\t\"github.com/go-chi/chi/v5\"\n\n\t_ \"github.com/danielgtaylor/huma/v2/formats/cbor\"\n)\n\n// Options for the CLI. Pass `--port` or set the `SERVICE_PORT` env var.\ntype Options struct {\n\tPort int `help:\"Port to listen on\" short:\"p\" default:\"8888\"`\n}\n\n// GreetingOutput represents the greeting operation response.\ntype GreetingOutput struct {\n\tBody struct {\n\t\tMessage string `json:\"message\" example:\"Hello, world!\" doc:\"Greeting message\"`\n\t}\n}\n\nfunc main() {\n\t// Create a CLI app which takes a port option.\n\tcli := humacli.New(func(hooks humacli.Hooks, options *Options) {\n\t\t// Create a new router \u0026 API\n\t\trouter := chi.NewMux()\n\t\tapi := humachi.New(router, huma.DefaultConfig(\"My API\", \"1.0.0\"))\n\n\t\t// Add the operation handler to the API.\n\t\thuma.Get(api, \"/greeting/{name}\", func(ctx context.Context, input *struct{\n\t\t\tName string `path:\"name\" maxLength:\"30\" example:\"world\" doc:\"Name to greet\"`\n\t\t}) (*GreetingOutput, error) {\n\t\t\tresp := \u0026GreetingOutput{}\n\t\t\tresp.Body.Message = fmt.Sprintf(\"Hello, %s!\", input.Name)\n\t\t\treturn resp, nil\n\t\t})\n\n\t\t// Tell the CLI how to start your router.\n\t\thooks.OnStart(func() {\n\t\t\thttp.ListenAndServe(fmt.Sprintf(\":%d\", options.Port), router)\n\t\t})\n\t})\n\n\t// Run the CLI. When passed no commands, it starts the server.\n\tcli.Run()\n}\n```\n\n\u003e [!TIP]\n\u003e Replace `chi.NewMux()` → `http.NewServeMux()` and `humachi.New` → `humago.New` to use the standard library router from Go 1.22+. Just make sure your `go.mod` has `go 1.22` or newer listed in it. Everything else stays the same! Switch whenever you are ready.\n\nYou can test it with `go run greet.go` (optionally pass `--port` to change the default) and make a sample request using [Restish](https://rest.sh/) (or `curl`):\n\n```sh\n# Get the message from the server\n$ restish :8888/greeting/world\nHTTP/1.1 200 OK\n...\n{\n\t$schema: \"http://localhost:8888/schemas/GreetingOutputBody.json\",\n\tmessage: \"Hello, world!\"\n}\n```\n\nEven though the example is tiny you can also see some generated documentation at http://localhost:8888/docs. The generated OpenAPI is available at http://localhost:8888/openapi.json or http://localhost:8888/openapi.yaml.\n\nCheck out the [Huma tutorial](https://huma.rocks/tutorial/installation/) for a step-by-step guide to get started.\n\n# Documentation\n\nSee the [https://huma.rocks/](https://huma.rocks/) website for full documentation in a presentation that's easier to navigate and search then this README. You can find the source for the site in the `docs` directory of this repo.\n\nOfficial Go package documentation can always be found at https://pkg.go.dev/github.com/danielgtaylor/huma/v2.\n\n# Articles \u0026 Mentions\n\n- [APIs in Go with Huma 2.0](https://dgt.hashnode.dev/apis-in-go-with-huma-20)\n- [Reducing Go Dependencies: A case study of dependency reduction in Huma](https://dgt.hashnode.dev/reducing-go-dependencies)\n- [Golang News \u0026 Libs \u0026 Jobs shared on Twitter/X](https://twitter.com/golangch/status/1752175499701264532)\n- Featured in Go Weekly [#495](https://golangweekly.com/issues/495) \u0026 [#498](https://golangweekly.com/issues/498)\n- [Bump.sh Deploying Docs from Huma](https://docs.bump.sh/guides/bump-sh-tutorials/huma/)\n- Mentioned in [Composable HTTP Handlers Using Generics](https://www.willem.dev/articles/generic-http-handlers/)\n\nBe sure to star the project if you find it useful!\n\n\u003ca href=\"https://star-history.com/#danielgtaylor/huma\u0026Date\"\u003e\n\t\u003cpicture\u003e\n\t\t\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=danielgtaylor/huma\u0026type=Date\u0026theme=dark\" /\u003e\n\t\t\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=danielgtaylor/huma\u0026type=Date\" /\u003e\n\t\t\u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=danielgtaylor/huma\u0026type=Date\" /\u003e\n\t\u003c/picture\u003e\n\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/danielgtaylor"],"categories":["Go","Web Frameworks","api"],"sub_categories":["Utility/Miscellaneous","Fail injection"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgtaylor%2Fhuma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgtaylor%2Fhuma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgtaylor%2Fhuma/lists"}