Repository navigation
Development
This page is for contributors who modify defillama-go. The project uses only the Go standard library at runtime and targets Go 1.22 or newer. Tests use local HTTP servers, not live DefiLlama endpoints, so they do not require an API key or network access.1
git clone https://github.com/tigusigalpa/defillama-go.git
cd defillama-go
go mod tidyRun the following commands before submitting a pull request.
gofmt -l . # Must print nothing.
go vet ./...
staticcheck ./... # Install separately if not available.
golangci-lint run # Run when installed.
go test ./...
go test -race ./...The -race run is useful because the client is documented as safe to share across goroutines. The repository's HTTP tests use httptest.Server together with WithBaseURLsForTesting rather than calling DefiLlama directly.1
The pinned OpenAPI snapshot at spec/defillama-api.json is the source of truth for route coverage. Generated artifacts include routes.go, service files, option structs, and docs/api-index.md. Do not hand-build a base URL inside a service method. When adding or changing an endpoint, update the specification snapshot and regenerate the route registry, service files, options, and API index together.1
The current release covers 132 GET operations: 31 Free and 101 Pro. The route registry stores the route's tier, source origin, Pro override path where available, declared path/query parameters, enum values, and official documentation URL.2
Pro authentication embeds the key in a URL path segment as required by DefiLlama. Never add a path that puts the key into a log, error, header, body, or test fixture. Error handling intentionally redacts the key from URLs, response diagnostics, and nested transport errors. Tests should exercise this redaction behavior when transport code is modified.1
Keep the README, docs/api-index.md, examples, and Wiki pages consistent with the public API. The Wiki bundle's API Reference is a copy of the source API index and should be refreshed whenever the generated endpoint index changes. Update examples when method signatures or option semantics change.
Open ordinary bugs and feature requests as GitHub issues with a minimal reproduction. Remove API keys and other secrets from the report. For a security vulnerability, follow the repository's private disclosure policy rather than filing a public issue.1
defillama-go is an MIT-licensed Go client for the DefiLlama API. For endpoint semantics and API-plan details, consult the official DefiLlama API reference.