/api/v3 to your installation URL, signs private requests with HMAC v2, and returns typed results. Start with two ping requests to verify the exchanger’s address, token, and signing secret.
Install the module
Use Go 1.26.0 or later. If your project has nogo.mod, create one with go mod init example.com/exchanger-ping. Then add the verified module revision.
Verify the address without credentials
SetEXCHANGER_API_ORIGIN or replace https://your-exchange in the example with your installation’s HTTPS origin. Save the code as main.go and run go run .. On success, Ping prints status=ok and the exchanger name.
main.go
Verify credentials and signing
Set the process environment variables. Get both credentials from the same API key.
Replace the contents of
main.go and run go run . again.
main.go
status=ok. PrivatePing verifies credentials with a fresh HMAC v2 signature and requires no additional scope. Ping sends an anonymous request even when credentials are configured. Share Metadata.RequestID if you contact the operator.
Construct one client per installation and reuse it across requests. Config.Timeout covers the whole request, including reading the response. A zero value defaults to 30 seconds. Config.Locale sets the X-Locale header for a locale the installation supports. The SDK stops at HTTP redirects.
Call methods that require scopes
Grantpublic-api:exchange:routes:read to use client.Exchange().Routes(ctx, query). Calling client.Exchange().Quote(ctx, input) requires public-api:exchange:quotes:read. Look up scopes for other methods in the API reference.
For the route catalog, pass parameters in api.Query from github.com/iexexchanger/exchanger-sdk-go/api. To use a cursor, start with pagination=cursor. When Metadata.Pagination is present, HasMore is true, and NextCursor is set, pass its value in cursor and keep the same filters and sort order. Lists and pagination
Handle errors and retries
Useerrors.As with typed errors from the api package. Check for missing credentials on a private call with errors.Is(err, api.ErrMissingCredentials).
Your application decides how to recover from each error. For HTTP
429, read Code on APIError. If a proxy returned HTML, for example, the SDK returns ProtocolError. Both types expose Metadata.HTTPStatus and carry the original header in Metadata.RetryAfter when present. Errors and retries
Save the request body and idempotency key before the first attempt. After an ambiguous write failure, check the operation’s state first. To retry order creation, pass the same JSON bytes and key to client.Orders().CreateRaw(ctx, body, key). The SDK signs the new request with a fresh nonce. Metadata.IdempotencyReplayed indicates that the server returned a saved response. Idempotency
Go SDK examples in GitHub · Go SDK source code