Skip to content

Go SDK

Describes github.com/stxapp/stx-go v0.3.1, the current release.

github.com/stxapp/stx-go is the Go SDK for the STX exchange. Read markets, place and cancel orders, follow your account, and stream the WebSocket channels, with every request signed by your API key. Response fields are described in the API reference.

go get github.com/stxapp/stx-go
package main
import (
"context"
"fmt"
"log"
stx "github.com/stxapp/stx-go"
)
func main() {
ctx := context.Background()
// Reads your API key and exchange from STX_* environment variables or ~/.stx/credentials.
client, err := stx.New()
if err != nil {
log.Fatal(err)
}
me, err := client.Account.Me(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(me.UserID)
page, err := client.Markets.List(ctx, &stx.MarketsQuery{Status: []string{"open"}, Limit: 5})
if err != nil {
log.Fatal(err)
}
for _, m := range page.Items {
fmt.Println(m.Symbol)
}
}
e6528824-b4e0-4ff8-bd70-36e5904738d1
STXNHL-26OCT101600EDMSJ-GAMEEDM
STXNHL-26OCT101600EDMSJ-SOGSJCMCDAVID209555-3.5
STXNHL-26OCT101600EDMSJ-SOGEDMCMCDAVID97-3.5
STXNBA-26OCT102000LALGSW-GAMELAL
STXNBA-26OCT102000LALGSW-PTSLALLJAMES23-24.5

Authentication shows how to give the client your API key, and Environments lists the exchanges and where to get a key. What you can do maps every feature to its SDK calls and shows which exchange has which.

  • One client. stx.New returns a *stx.Client with a field per area: client.Account, client.Markets, client.Events, client.Orders, client.Portfolio, client.Leaderboard and client.Combos. Create it once and share it: it is safe for concurrent use.
  • Context first. Every call takes a context.Context as its first argument, so deadlines and cancellation work the way they do in the rest of your program.
  • Errors are values. Calls return an error; nothing panics. API errors are *stx.APIError, and sentinels such as stx.ErrNotFound and stx.ErrRateLimited work with errors.Is. See Errors & retries.
  • Iterators for paging. List methods return one *stx.Page[T]; their All twins return an iter.Seq2[T, error] that follows the cursor for you. See Markets.

Amounts are stx.Decimal, a string type that keeps the exact digits the API sends (order.Price == "0.5800"). Orders take decimals too: stx.MustDecimal("0.58"). Nothing in a money path is a float64. Decimal.Rat gives you a *big.Rat for arithmetic, and Decimal.Cmp compares two values numerically.

Released under the MIT license.

STX is operated by XV Exchange, LLC, a Designated Contract Market regulated by the U.S. Commodity Futures Trading Commission (CFTC). Contracts traded on STX are cleared by XV Clearing, LLC, a CFTC-registered Derivatives Clearing Organization. Trading involves substantial risk of loss and may not be appropriate for everyone. Members risk losing the cost to enter any transaction, including fees. Consider whether trading is appropriate for you in light of your experience and financial resources. Nothing on this site is investment advice or a recommendation to trade. Past performance is not indicative of future results.

© 2026 STX. All rights reserved.llms.txtllms-full.txtView as Markdown
Docs version v1.10.5