Go client for ausdata.io

Go's standard library covers everything you need: net/http for the request, encoding/json for the response. The 20-line client below is what every Go user writes.

No Go module yet. The 20-line client above is the canonical implementation.

Canonical client

Go
package ausdata

import (
    "encoding/json"
    "fmt"
    "net/http"
    "net/url"
    "os"
)

type Client struct{ Key string }

func New() *Client { return &Client{Key: os.Getenv("AUSDATA_KEY")} }

func (c *Client) Get(path string, params url.Values, out any) error {
    u := "https://api.ausdata.io" + path
    if len(params) > 0 { u += "?" + params.Encode() }
    req, _ := http.NewRequest("GET", u, nil)
    req.Header.Set("Authorization", "Bearer "+c.Key)
    resp, err := http.DefaultClient.Do(req)
    if err != nil { return err }
    defer resp.Body.Close()
    if resp.StatusCode >= 400 { return fmt.Errorf("ausdata %d", resp.StatusCode) }
    return json.NewDecoder(resp.Body).Decode(out)
}

Use it

Go
c := ausdata.New()
var resp struct{ Data struct{ CashRate float64 `json:"cash_rate"` } }
_ = c.Get("/v1/economic-dashboard", nil, &resp)
fmt.Println(resp.Data.CashRate)

Notes

  • .Set AUSDATA_KEY in your environment. Inject via os.Getenv, not flags.
  • .Use context.Context and http.NewRequestWithContext in production code.
  • .Decode into a typed struct per endpoint. The OpenAPI spec lists every field.

Other SDKs

Get a key and call your first endpoint

500 free calls per month. No credit card.

Get a free API key