Skip to content
Merged
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Bug report
description: The client does something wrong or fails to decode an API response.
labels: [bug]
body:
- type: input
id: version
attributes:
label: Client version
description: Output of `go list -m github.com/glassnode/glassnode-api-go-client`, or the commit.
placeholder: v0.1.0
validations:
required: true
- type: input
id: go
attributes:
label: Go version
placeholder: go1.24.5 linux/amd64
validations:
required: true
- type: textarea
id: what
attributes:
label: What happened
description: What you called, what you expected and what you got. Paste the error message; the client never includes credentials in it, but check that your own logs don't either.
validations:
required: true
- type: textarea
id: repro
attributes:
label: How to reproduce
description: A short program or the metric path and parameters. For a decoding problem, a few points of the raw JSON response are the most useful thing you can include.
render: go
- type: checkboxes
id: checks
attributes:
label: Checks
options:
- label: I have removed API keys and tokens from everything pasted above.
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Security issue
url: https://github.com/glassnode/glassnode-api-go-client/security/advisories/new
about: Report a vulnerability privately instead of opening an issue.
- name: Glassnode API documentation
url: https://docs.glassnode.com
about: Questions about metrics, parameters, credits and plans are answered there; the client only transports what the API returns.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Feature request
description: Support for an API endpoint, response shape or option the client lacks.
labels: [enhancement]
body:
- type: textarea
id: problem
attributes:
label: What you are trying to do
description: The API call or workflow, and what makes it hard or impossible with the client today.
validations:
required: true
- type: input
id: docs
attributes:
label: API documentation
description: Link to the relevant page on docs.glassnode.com, if any.
placeholder: https://docs.glassnode.com/basic-api/...
- type: textarea
id: proposal
attributes:
label: Proposed change
description: Optional. How you imagine the client API for it, or a workaround you use now with `GetMetric`, `Get` or `Raw`.
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Summary

<!-- What changes for a user of the client, and why. Link the issue if there is one. -->

## Test plan

<!-- How you verified the change: new or updated tests, a recorded response, a run against the API. -->

- [ ] `go test -race ./...` and `golangci-lint run ./...` pass
- [ ] CHANGELOG.md updated (for user-visible changes)
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns: ['*']
# The client has no dependencies; this keeps the Go directive current.
- package-ecosystem: gomod
directories: [/, /examples]
schedule:
interval: weekly
49 changes: 39 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
Expand All @@ -12,25 +16,50 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go }}
cache: false
- name: Format
run: test -z "$(gofmt -l .)"
cache: false # no dependencies to cache
- name: Check module files
run: go mod tidy -diff
- name: Vet
run: go vet ./...
- name: Test with race detector
run: go test -race ./...
- name: Check example module files
working-directory: examples
run: go mod tidy -diff
- name: Vet examples
working-directory: examples
run: go vet ./...
- name: Build examples
working-directory: examples
run: go build ./...

lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
cache: false
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.14
- name: Lint examples
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.14
working-directory: examples
# The first step already installed this version; skip its cache setup.
install-mode: none

vulncheck:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
cache: false
- name: govulncheck
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release
on:
push:
tags: ['v*.*.*']
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
cache: false
- name: Test
run: go test -race ./...
- name: Check that the changelog mentions this version
run: grep -q "^## ${GITHUB_REF_NAME}" CHANGELOG.md
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Release notes are the changelog section for this version.
awk -v tag="$GITHUB_REF_NAME" '
/^## / { printing = ($2 == tag) ; next }
printing { print }
' CHANGELOG.md > notes.md
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file notes.md --verify-tag
39 changes: 39 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "2"

linters:
default: standard
enable:
- bodyclose
- copyloopvar
- errorlint
- gocritic
- gosec
- misspell
- nilerr
- noctx
- revive
- unconvert
- unparam
settings:
gosec:
excludes:
# Retry jitter does not need cryptographic randomness.
- G404
errorlint:
# errors.Is on io.EOF and context errors is idiomatic for sentinel errors.
comparison: false
revive:
rules:
- name: exported
arguments: ["checkPrivateReceivers", "disableStutteringCheck"]
exclusions:
rules:
- path: _test\.go
linters: [gosec, noctx, errcheck, unparam]
- path: examples/
linters: [gosec]

formatters:
enable:
- gofmt
- goimports
44 changes: 20 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
# Changelog

## v0.1.0 — 2026-10-01
## v0.1.0 — 2026-10-08

Initial private SDK release. One dependency-free root `glassnode` package, with
typed metrics, metadata and usage endpoints, context cancellation, configurable
HTTP transport and bounded retries. Runnable examples are a separate module and
excluded from the SDK distribution.
Initial public release.

Changes following the Fable review:

- Preserve metric `parameters_defaults` from recorded API responses.
- Include redacted diagnostic causes in decode and transport errors, preserving
the original error chain for `errors.Is` and `errors.As`.
- Add `TokenSource`, `TokenSourceFunc`, `WithTokenSource` and `AuthError` for
application-owned OAuth refresh. Tokens are obtained per HTTP attempt and
redacted per call, including tokens used on earlier retries.
- Reject conflicting authentication, invalid credential whitespace/control
characters and OAuth combined with query API-key authentication. Previously,
bearer tokens silently took precedence over a configured API key.
- Make explicit `WithTimeout` override a supplied HTTP client's timeout in
either option order.
- Extract JSON API error messages and bound detail after redaction.
- Add recorded API contract coverage and tests for token-source concurrency,
cancellation, failures and redaction, interrupted reads, per-attempt timeouts,
HTTP-date Retry-After and malformed metadata/usage responses.

OAuth login and token storage remain application-owned. x402 is deferred.
- Metric time series: scalar (`GetTimeSeries`), object (`GetObjectTimeSeries`),
bulk (`GetBulkMetric`) and custom shapes (`GetMetric`). Point-in-time metrics
expose `ComputedAt`; bulk entries keep every selector in `Params`.
- Asset and metric metadata, metric lag statistics, and lists of metric tags,
asset tags, categories, blockchains, exchanges, networks and miners.
- API credit usage (`GetAPIUsage`).
- CSV downloads of a metric to an `io.Writer` (`GetMetricCSV`).
- Generic `Get` and `Raw` for endpoints without a dedicated method.
- Authentication with an API key (header or query) or an existing OAuth access
token, fixed or from a `TokenSource`; a `TokenRefresher` can replace a token
the API rejected with `401`.
- Context cancellation, a per-attempt timeout and retries with jittered
backoff that honour `Retry-After` and `x-rate-limit-reset`, with the wait
exposed as `APIError.RetryAfter`.
- Optional response size limit (`WithMaxResponseBytes`).
- Typed errors with credentials redacted from messages; redirects are never
followed.
- No dependencies outside the standard library.
85 changes: 85 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at the maintainers listed in [CODEOWNERS](CODEOWNERS), by opening a private security advisory on GitHub or by contacting any of them directly. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

Loading
Loading