Describes @stxapp/stx-typescript 0.12.1, the current release.
Every exception extends STXException. Catch the class you care about with instanceof.
| Exception | Extends | When |
|---|---|---|
STXException |
Error |
Base for every error the SDK throws. |
STXConfigException |
STXException |
The client is misconfigured: unknown region, missing key, bad PEM. |
STXAPIException |
STXException |
The API answered with an error status. Base for the classes below. |
STXValidationException |
STXAPIException |
400: a parameter or body field was rejected, e.g. price is required. |
STXAuthenticationException |
STXAPIException |
401: the signature, key ID or timestamp was not accepted. A machine clock more than 30 seconds off also lands here. |
STXForbiddenException |
STXAPIException |
403: the key is read-only, or the account may not do this. When the server names the scopes that would satisfy the call (in the WWW-Authenticate challenge), requiredScopes lists them. |
STXIPNotAllowedException |
STXForbiddenException |
403 on an OAuth bearer request: the token is fine, but the app’s IP allow-list does not include the address this write came from ({"error": "ip_not_allowed"}). Reads keep working. Send writes from an address on the allow-list you gave STX for this app. Never retried. |
STXBlockedException |
STXForbiddenException |
403 from the network edge in front of the exchange: the request never reached it, so nothing was done. reason is restricted_jurisdiction, unusual_network, or blocked when the edge sent no reason (most often a request without a User-Agent header). reference identifies the block for support, when sent. Retrying will not help, so it is never retried. |
STXRestrictedJurisdictionException |
STXBlockedException |
403 restricted_jurisdiction: the request came from a location the exchange does not serve. |
STXUnusualNetworkException |
STXBlockedException |
403 unusual_network: the request came from a network the exchange does not accept traffic from, such as some hosting providers, proxies or VPNs. |
STXNotFoundException |
STXAPIException |
404: the resource does not exist, or belongs to another account. |
STXRejectedException |
STXAPIException |
422: the exchange refused the request, e.g. insufficient funds, a closed market or an order from outside the region. |
STXFillModeNotAllowedException |
STXRejectedException |
422: this market does not take the order’s fillMode. Combination markets accept only normal orders. fillMode is the mode sent. |
STXPostOnlyWouldMatchException |
STXRejectedException |
A post_only order would have matched on arrival, so it was not left on the book and nothing filled. reason is auto_matching when the exchange accepted and cancelled it (order is that cancelled order), or match_with_self when the first order it would match is your own (a 422; order is undefined). |
STXRateLimitException |
STXAPIException |
429: too many requests. retryAfter is seconds, when sent. reference identifies the block for support when the network edge in front of the exchange answered ({"error": "rate_limited", ...}), else it is undefined. |
STXServerException |
STXAPIException |
5xx: the server failed. Retried by the default policy on GET and DELETE. |
STXTransportException |
STXException |
The request never got an answer: connection, DNS, TLS or timeout. |
STXChannelException |
STXException |
A channel join or channel message was refused by the server. reply holds the server’s response object, for example {reason: "unauthorized"}. |
STXTimeoutException |
STXChannelException |
No reply, message or snapshot arrived on a channel in time. A subclass of STXChannelException. |
STXNotAvailableException |
STXAPIException |
This exchange does not have the feature yet: combos on an exchange without them, OAuth where it is not switched on, a scope the exchange does not offer in its jurisdiction. Nothing is wrong with the request or the credentials, and nothing else is affected; the same call works on an exchange that has the feature. STX.capabilities() says up front which features an exchange has. |
STXCombosUnavailableException |
STXChannelException |
Combos are not available on this exchange: it refused the join to the player or maker topic with unmatched topic. Nothing else is affected. |
STXComboRefusedException |
STXChannelException |
The exchange refused a combo command or join. code is the refusal (not_found, insufficient_assets, player_refused, …); for player_refused:<reason> the part after the first colon is in detail. command is the event that was refused, e.g. accept. reason (from STXChannelException) is the full string as sent. |
STXComboPriceMovedException |
STXComboRefusedException |
accept found nothing live at the accepted amount or better. The request stays open. best is the live best quote now; its fields are null when nothing is live. Accept again at best.amount to take it. |
STXException
Section titled “STXException”Base for every error the SDK throws.
| Property | Type | Description |
|---|---|---|
body |
unknown |
|
method |
string | undefined |
|
path |
string | undefined |
|
statusCode |
number | undefined |
STXConfigException
Section titled “STXConfigException”The client is misconfigured: unknown region, missing key, bad PEM.
STXAPIException
Section titled “STXAPIException”The API answered with an error status. Base for the classes below.
STXValidationException
Section titled “STXValidationException”400: a parameter or body field was rejected, e.g. price is required.
STXAuthenticationException
Section titled “STXAuthenticationException”401: the signature, key ID or timestamp was not accepted. A machine clock more than 30 seconds off also lands here.
STXForbiddenException
Section titled “STXForbiddenException”403: the key is read-only, or the account may not do this. When the server
names the scopes that would satisfy the call (in the WWW-Authenticate
challenge), requiredScopes lists them.
| Property | Type | Description |
|---|---|---|
requiredScopes |
readonly string[] |
STXIPNotAllowedException
Section titled “STXIPNotAllowedException”403 on an OAuth bearer request: the token is fine, but the app’s IP
allow-list does not include the address this write came from
({"error": "ip_not_allowed"}). Reads keep working. Send writes from an
address on the allow-list you gave STX for this app. Never retried.
STXBlockedException
Section titled “STXBlockedException”403 from the network edge in front of the exchange: the request never
reached it, so nothing was done. reason is restricted_jurisdiction,
unusual_network, or blocked when the edge sent no reason (most often a
request without a User-Agent header). reference identifies the block for
support, when sent. Retrying will not help, so it is never retried.
| Property | Type | Description |
|---|---|---|
reason |
string |
|
reference |
string | undefined |
STXRestrictedJurisdictionException
Section titled “STXRestrictedJurisdictionException”403 restricted_jurisdiction: the request came from a location the exchange does not serve.
STXUnusualNetworkException
Section titled “STXUnusualNetworkException”403 unusual_network: the request came from a network the exchange does
not accept traffic from, such as some hosting providers, proxies or VPNs.
STXNotFoundException
Section titled “STXNotFoundException”404: the resource does not exist, or belongs to another account.
STXRejectedException
Section titled “STXRejectedException”422: the exchange refused the request, e.g. insufficient funds, a closed market or an order from outside the region.
STXFillModeNotAllowedException
Section titled “STXFillModeNotAllowedException”422: this market does not take the order’s fillMode. Combination markets
accept only normal orders. fillMode is the mode sent.
| Property | Type | Description |
|---|---|---|
fillMode |
string |
STXPostOnlyWouldMatchException
Section titled “STXPostOnlyWouldMatchException”A post_only order would have matched on arrival, so it was not left on the
book and nothing filled. reason is auto_matching when the exchange
accepted and cancelled it (order is that cancelled order), or
match_with_self when the first order it would match is your own (a 422;
order is undefined).
| Property | Type | Description |
|---|---|---|
order |
Order | undefined |
|
reason |
"auto_matching" | "match_with_self" |
STXRateLimitException
Section titled “STXRateLimitException”429: too many requests. retryAfter is seconds, when sent. reference
identifies the block for support when the network edge in front of the
exchange answered ({"error": "rate_limited", ...}), else it is undefined.
| Property | Type | Description |
|---|---|---|
reference |
string | undefined |
|
retryAfter |
number | undefined |
STXServerException
Section titled “STXServerException”5xx: the server failed. Retried by the default policy on GET and DELETE.
STXTransportException
Section titled “STXTransportException”The request never got an answer: connection, DNS, TLS or timeout.
STXChannelException
Section titled “STXChannelException”A channel join or channel message was refused by the server. reply holds
the server’s response object, for example {reason: "unauthorized"}.
| Property | Type | Description |
|---|---|---|
reply |
unknown |
|
topic |
string |
STXTimeoutException
Section titled “STXTimeoutException”No reply, message or snapshot arrived on a channel in time. A subclass of
STXChannelException.
STXNotAvailableException
Section titled “STXNotAvailableException”This exchange does not have the feature yet: combos on an exchange without
them, OAuth where it is not switched on, a scope the exchange does not offer
in its jurisdiction. Nothing is wrong with the request or the credentials,
and nothing else is affected; the same call works on an exchange that has
the feature. STX.capabilities() says up front which features an exchange
has.
feature is a stable id (oauth, oauth.member, oauth.app, connect,
terms.stx_page, markets.create, market_types, event_players,
leaderboard, loyalty, combos, orders.post_only, orders.fill_or_kill, or
scope:<name>); host is the exchange that answered, and apiVersion its
build when known.
statusCode and body are the HTTP answer the decision came from, when
there was one.
| Property | Type | Description |
|---|---|---|
apiVersion |
string | undefined |
The exchange build, e.g. "3.4.24", when known. |
feature |
string |
The feature id, e.g. "combos". |
host |
string |
The exchange host that lacks it, e.g. "demo.stxapp.ca". |
STXCombosUnavailableException
Section titled “STXCombosUnavailableException”Combos are not available on this exchange: it refused the join to the
player or maker topic with unmatched topic. Nothing else is affected.
A channel exception, as before, and also an STXNotAvailableException
(instanceof is true for both), with feature "combos" and host.
| Property | Type | Description |
|---|---|---|
feature |
"combos" |
|
host |
string |
The exchange host that lacks combos. |
STXComboRefusedException
Section titled “STXComboRefusedException”The exchange refused a combo command or join. code is the refusal
(not_found, insufficient_assets, player_refused, …); for
player_refused:<reason> the part after the first colon is in detail.
command is the event that was refused, e.g. accept. reason (from
STXChannelException) is the full string as sent.
| Property | Type | Description |
|---|---|---|
code |
string |
|
command |
string |
|
detail |
string | undefined |
STXComboPriceMovedException
Section titled “STXComboPriceMovedException”accept found nothing live at the accepted amount or better. The request
stays open. best is the live best quote now; its fields are null when
nothing is live. Accept again at best.amount to take it.
| Property | Type | Description |
|---|---|---|
best |
{ amount: string | null; expires_at: number | null; quote_id: string | null } |

