TradesCallBuilder

TradesCallBuilder

TradesCallBuilder

Constructor

new TradesCallBuilder(serverUrl)

Source:
See:
Parameters:
Name Type Description
serverUrl string

serverUrl Horizon server URL.

Extends

Methods

call() → {Promise}

Triggers a HTTP request using this builder's current configuration.

Overrides:
Source:
Returns:
Type:
Promise

a Promise that resolves to the server's response.

cursor(cursor) → {object}

Sets cursor parameter for the current call. Returns the CallBuilder object on which this method has been called.

Overrides:
Source:
See:
Parameters:
Name Type Description
cursor string

A cursor is a value that points to a specific location in a collection of resources.

Returns:
Type:
object

current CallBuilder instance

forAccount(accountId) → {TradesCallBuilder}

Filter trades for a specific account

Source:
See:
Parameters:
Name Type Description
accountId string

For example: GBYTR4MC5JAX4ALGUBJD7EIKZVM7CUGWKXIUJMRSMK573XH2O7VAK3SR

Returns:
Type:
TradesCallBuilder

current TradesCallBuilder instance

forAssetPair(base, counter) → {TradesCallBuilder}

Filter trades for a specific asset pair (orderbook)

Source:
Parameters:
Name Type Description
base Asset

asset

counter Asset

asset

Returns:
Type:
TradesCallBuilder

current TradesCallBuilder instance

forEndpoint(endpoint, param) → {CallBuilder}

A helper method to craft queries to "neighbor" endpoints.

For example, we have an /effects suffix endpoint on many different "root" endpoints, such as /transactions/:id and /accounts/:id. So, it's helpful to be able to conveniently create queries to the /accounts/:id/effects endpoint:

this.forEndpoint("accounts", accountId)`.

Overrides:
Source:
Parameters:
Name Type Description
endpoint string

neighbor endpoint in question, like /operations

param string

filter parameter, like an operation ID

Returns:
Type:
CallBuilder

this CallBuilder instance

forLiquidityPool(liquidityPoolId) → {TradesCallBuilder}

Filter trades for a specific liquidity pool

Source:
See:
Parameters:
Name Type Description
liquidityPoolId string

For example: 3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4

Returns:
Type:
TradesCallBuilder

current TradesCallBuilder instance

forOffer(offerId) → {TradesCallBuilder}

Filter trades for a specific offer

Source:
Parameters:
Name Type Description
offerId string

ID of the offer

Returns:
Type:
TradesCallBuilder

current TradesCallBuilder instance

forType(tradeType) → {TradesCallBuilder}

Filter trades by a specific type.

Source:
Parameters:
Name Type Description
tradeType ServerApi.TradeType

the trade type to filter by.

Returns:
Type:
TradesCallBuilder

current TradesCallBuilder instance.

join(join) → {object}

Sets join parameter for the current call. The join parameter includes the requested resource in the response. Currently, the only valid value for the parameter is transactions and is only supported on the operations and payments endpoints. The response will include a transaction field for each operation in the response.

Overrides:
Source:
Parameters:
Name Type Description
join "transactions"

Records to be included in the response.

Returns:
Type:
object

current CallBuilder instance.

limit(number) → {object}

Sets limit parameter for the current call. Returns the CallBuilder object on which this method has been called.

Overrides:
Source:
See:
Parameters:
Name Type Description
number number

Number of records the server should return.

Returns:
Type:
object

current CallBuilder instance

order(direction) → {object}

Sets order parameter for the current call. Returns the CallBuilder object on which this method has been called.

Overrides:
Source:
Parameters:
Name Type Description
direction "asc" | "desc"

Sort direction

Returns:
Type:
object

current CallBuilder instance

stream(optionsopt) → {function}

Creates an EventSource that listens for incoming messages from the server. To stop listening for new events call the function returned by this method.

Overrides:
Source:
See:
Parameters:
Name Type Attributes Description
options object <optional>

EventSource options.

Name Type Attributes Description
onmessage function <optional>

Callback function to handle incoming messages.

onerror function <optional>

Callback function to handle errors.

reconnectTimeout number <optional>

Custom stream connection timeout in ms, default is 15 seconds.

Returns:
Type:
function

Close function. Run to close the connection and stop listening for new events.