# Environments

> Select the STX exchange the client connects to.

Source: https://docs.stxapp.io/sdks/go/environments/

The exchanges, their hosts and which one to start with are listed on [Environments](/environments/). In the SDK, pick one with `stx.WithEnvironment`, or with a region and env (as an option, as `STX_REGION` and `STX_ENV`, or in a credentials profile):

| Exchange | Option | `region` | `env` |
|---|---|---|---|
| STX US demo | `stx.WithEnvironment(stx.USDemo)` | `us` | `demo` |
| STX Ontario demo | `stx.WithEnvironment(stx.OntarioDemo)` | `ontario` | `demo` |
| STX Ontario | `stx.WithEnvironment(stx.OntarioProduction)` | `ontario` | `production` |

```go
client, err := stx.New(stx.WithEnvironment(stx.USDemo), stx.WithKey("3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d", "~/.stx/us-demo.pem"))
if err != nil {
	log.Fatal(err)
}
fmt.Println(client.BaseURL(), client.SocketURL())
// https://demo.stxapp.io wss://demo.stxapp.io/socket/websocket

// The same exchange, by region and env, or by name:
same, err := stx.New(stx.WithRegion("us", "demo"))
byName, err := stx.New(stx.WithEnvironmentName("us-demo"))
```

`stx.Environments()` lists every published environment, and `stx.EnvironmentNamed("ontario-demo")` looks one up by name. `Environment.RealMoney` is true for production exchanges.

An API key works on one exchange only, so keep one credentials profile per exchange and switch with `stx.WithProfile`.

To reach any other host, such as a local server, pass `stx.WithHost("http://localhost:4000")` (or set `STX_HOST`). The URL's scheme is kept for both HTTP and the socket. `stx.WithInsecureSkipVerify()` turns off TLS verification, for a local server with a self-signed certificate only.
