Official Go SDK for the Cryptohopper API.
Status: v0.4.0-alpha.1 — full coverage of all 18 public API domains:
User,Hoppers,Exchange,Strategy,Backtest,Market,Signals,Arbitrage,MarketMaker,Template,AI,Platform,Chart,Subscription,Social,Tournaments,Webhooks,App.
Deeper docs: Getting Started · Authentication · Error Handling · Rate Limits
go get github.com/cryptohopper/cryptohopper-go-sdk@latestRequires Go 1.22+.
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/cryptohopper/cryptohopper-go-sdk"
)
func main() {
client, err := cryptohopper.NewClient(os.Getenv("CRYPTOHOPPER_TOKEN"))
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
me, err := client.User.Get(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(me["email"])
ticker, err := client.Exchange.Ticker(ctx, "binance", "BTC/USDT")
if err != nil {
log.Fatal(err)
}
fmt.Println(ticker["last"])
}Cryptohopper uses OAuth2 bearer tokens. To get one:
- Sign in at cryptohopper.com and open the developer dashboard.
- Create an OAuth application — you'll receive a
client_idandclient_secret. - Drive the OAuth consent flow (
/oauth-consent?app_id=<client_id>&redirect_uri=<your_uri>&state=<csrf>) to receive a 40-character bearer token scoped to the permissions you requested.
Pass the token to NewClient. Optionally pass your OAuth client_id with WithAppKey — it's sent as the x-api-app-key header.
client, err := cryptohopper.NewClient(
os.Getenv("CRYPTOHOPPER_TOKEN"),
cryptohopper.WithAppKey(os.Getenv("CRYPTOHOPPER_CLIENT_ID")),
)| Option | Default | Description |
|---|---|---|
WithBaseURL(string) |
https://api.cryptohopper.com/v1 |
Override for staging |
WithHTTPClient(*http.Client) |
— | Inject a custom HTTP client |
WithTimeout(time.Duration) |
30s |
Per-request timeout (ignored if WithHTTPClient set) |
WithUserAgent(string) |
— | Appended after cryptohopper-go-sdk/<v> |
WithAppKey(string) |
— | OAuth client_id, sent as x-api-app-key |
WithMaxRetries(int) |
3 |
Retries on HTTP 429. 0 disables auto-retry. |
Every non-2xx response becomes a *cryptohopper.Error:
var ce *cryptohopper.Error
if errors.As(err, &ce) {
switch ce.Code {
case "RATE_LIMITED":
time.Sleep(ce.RetryAfter)
case "UNAUTHORIZED":
log.Fatal("token expired or invalid")
case "FORBIDDEN":
log.Printf("missing scope or IP mismatch (ip=%s)", ce.IPAddress)
}
}ce.Code values: UNAUTHORIZED, FORBIDDEN, NOT_FOUND, RATE_LIMITED, VALIDATION_ERROR, DEVICE_UNAUTHORIZED, SERVER_ERROR, NETWORK_ERROR, TIMEOUT, UNKNOWN. Unknown strings pass through verbatim.
The server enforces three buckets (normal 30/min, order 8/8s, backtest 1/2s). On 429 the SDK retries with exponential backoff up to WithMaxRetries(n) (default 3), honouring Retry-After.
go vet ./...
go test ./... -race -count=1Push a v* git tag (plain v prefix required by Go modules). The workflow runs go vet, go test -race, and cuts a GitHub Release; Go proxies pick it up automatically from the tag.
MIT — see LICENSE.