A Golang SDK for the Hyperliquid API.
go get github.com/chainswatch/go-hyperliquid
package main
import (
"log"
"github.com/chainswatch/go-hyperliquid"
)
func main() {
hyperliquidClient := hyperliquid.NewHyperliquid(&hyperliquid.HyperliquidClientConfig{
IsMainnet: true,
AccountAddress: "0x12345", // Main address of the Hyperliquid account that you want to use
PrivateKey: "abc1234", // Private key of the account or API private key from Hyperliquid
})
// Get balances
res, err := hyperliquidClient.GetAccountState()
if err != nil {
log.Print(err)
}
log.Printf("GetAccountState(): %+v", res)
}
Integration tests require access to a funded Hyperliquid account. Provide the credentials via environment variables TEST_ADDRESS
and TEST_PRIVATE_KEY
. For convenience you can copy .test.env.example
to .test.env
at the repository root and populate these variables:
TEST_ADDRESS=0xabc123...
TEST_PRIVATE_KEY=...
The test suite automatically loads this file if present. Avoid committing any real credentials to source control.
Environment files like .env
and .test.env
are ignored by git.
If these variables are missing when the tests run the suite will fail immediately.
Run the unit tests with:
make test
Run the integration tests (requires TEST_ADDRESS
and TEST_PRIVATE_KEY
):
make integration
To run both sets together use:
make test-all
The Makefile uses go test -count=1
so results are not cached between runs.