Auto-generated Go client library for NetBox, generated from NetBox's OpenAPI specification.
- Automatic Version Detection: Detects NetBox version from the API and generates versioned clients
- Complete API Coverage: Generated from official OpenAPI spec with full type safety
- Multi-Framework Support: Includes server stubs for popular Go web frameworks (gin, echo, chi, fiber, iris, gorilla/mux, net/http)
- Go 1.21+
- oapi-codegen v2.5.1+
jqfor JSON processinggoimportsfor fixing imports- Access to a NetBox instance (API token required)
make upThis starts a complete NetBox environment with Docker Compose, including PostgreSQL and Redis.
make generateThis will:
- Fetch the OpenAPI spec from your NetBox instance
- Auto-detect the NetBox version
- Generate a versioned Go client (e.g.,
v4.2.1/) - Format and clean up the generated code
import "github.com/inngest/netbox-go/v4.2.1"
// Use the generated client...Set environment variables to point to your NetBox instance:
NETBOX_URL=https://netbox.example.com \
NETBOX_TOKEN=your-api-token \
make generateNETBOX_URL- NetBox instance URL (default:http://localhost:8000)NETBOX_TOKEN- NetBox API token (default: local dev token)
make generate- Generate Go client from NetBox APImake lint- Run golangci-lint (in versioned directories)make up- Start local NetBox with Docker Composemake down- Stop local NetBox
.
├── bin/
│ └── generate.sh # Generation script
├── vX.Y.Z/ # Generated versioned clients
│ ├── netbox.go # Generated client code
│ ├── openapi.json # OpenAPI specification
│ ├── codegen.yml # Code generation config
│ └── go.mod # Go module
├── codegen.tpl.yml # Codegen template
└── compose.yml # Docker Compose for NetBox
- Fetches the OpenAPI spec from a running NetBox instance
- Extracts the version from the spec metadata
- Generates Go client using
oapi-codegen - Post-processes: fixes nil constants, runs
gofmt, andgoimports - Creates isolated Go module for each version
This is auto-generated code. Refer to NetBox's license for the API specification.