Example
import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
const nash = new Client(EnvironmentConfiguration.sandbox)
Returns the connect socket
Example
import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
const nash = new Client(EnvironmentConfiguration.sandbox)
await nash.login(...)
// Getting the orderbook for the neo_eth marked
nash.subscriptions.onUpdatedOrderbook(
{ marketName: 'neo_eth' },
{
onResult: ({
data: {
updatedOrderBook: { bids, asks }
}
}) => {
console.log(`updated bids ${bids.length}`)
console.log(`updated asks ${asks.length}`)
}
}
)
// Getting the user orderobok for all markets
nash.subscriptions.onUpdatedAccountOrders(
{},
{
onResult: ({
data: {
updatedAccountOrders
}
}) => {
console.log(`Updated orders: {updatedAccountOrders.length}`)
}
}
)
Cancel all orders by market name
Example
const result = await nash.cancelAllOrders('neo_gas')
console.log(result)
Cancel a list of orders by ID.
Example
const cancelledOrders = await nash.cancelOrder(['11','12'])
console.log(cancelledOrders)
Cancel an order by ID.
Example
const cancelledOrder = await nash.cancelOrder('11')
console.log(cancelledOrder)
Cancel a list of orders by ID.
Example
const cancelledOrders = await nash.cancelOrder(['11','12'])
console.log(cancelledOrders)
Sets up a websocket and authenticates it using the current token.
Example
import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
const nash = new Client(EnvironmentConfiguration.sandbox)
await nash.login(...)
const connection = nash.createSocketConnection()
// Getting the orderbook for the neo_eth marked
connection.onUpdatedOrderbook(
{ marketName: 'neo_eth' },
{
onResult: ({
data: {
updatedOrderBook: { bids, asks }
}
}) => {
console.log(`updated bids ${bids.length}`)
console.log(`updated asks ${asks.length}`)
}
}
)
// Getting the user orderobok for all markets
connection.onUpdatedAccountOrders(
{},
{
onResult: ({
data: {
updatedAccountOrders
}
}) => {
console.log(`Updated orders: {updatedAccountOrders.length}`)
}
}
)
@deprecated please use subscriptions
Get the deposit address for the given crypto currency.
Example
import { CryptoCurrency } from '@neon-exchange/api-client-typescript'
const address = await nash.getAccountAddress(CryptoCurrency.NEO)
console.log(address)
Get [[AccountBalance]] for the given crypto currency.
Example
import { CryptoCurrency } from '@neon-exchange/api-client-typescript'
const accountBalance = await nash.getAcountBalance(CryptoCurrency.ETH)
console.log(accountBalance)
Get an order by ID.
Example
const order = await nash.getAccountOrder('999')
console.log(order)
Get the [[AccountPortfolio]] for the current authenticated account.
Example
const accountPortfolio = await nash.getAccountPortfolio({
fiatSymbol: "USD",
})
console.log(accountPortfolio)
Fetches the current account volumes for the current periods
Example
const volumes = await nash.getAccountVolumes()
console.log(volumes.makerFeeRate)
console.log(volumes.takerFeeRate)
List all current asset nonces
Example
const getNoncesData = await nash.getAssetNonces()
console.log(getNoncesData)
[description]
Get a specific [[Market]] by name.
Example
const market = await nash.getMarket('neo_gas')
console.log(market)
Get a [[Movement]] by the given id.
Example
const movement = await nash.getMovement(1)
console.log(movement)
Get the [[OrderBook]] for the given market.
Example
const orderBook = await nash.getOrderBook('neo_gas')
console.log(orderBook.bids)
Gets Balance States, Signs Balance States, then Syncs Balance states to the server
Whether to sync the state updates to the blockchain. Defaults to false
Example
// sign states
const signStates = await nash.getSignAndSyncStates()
console.log(signStates)
// sign and sync states to blockchain
const signAndSyncStates = await nash.getSignAndSyncStates(true)
console.log(signAndSyncStates)
Get a single [[Ticker]] for the given market name.
Example
const ticker = await nash.getTicker('neo_gas')
console.log(ticker)
List all balances for current authenticated account.
Example
const accountBalance = await nash.listAccountBalances()
console.log(accountBalance)
list available orders for the current authenticated account.
Example
const accountOrder = await nash.listAccountOrders({
marketName : 'neo_eth'
})
console.log(accountOrder.orders)
list available trades for the current authenticated account.
Example
const tradeHistory = await nash.listAccountTrades({
limit : 10,
marketName : 'neo_eth'
})
console.log(tradeHistory.trades)
List available account transactions.
Example
const accountTransaction = await nash.listAccountTransactions({
limit : 150,
${paramName} : ${paramValue}
})
console.log(accountTransaction.transactions)
Fetches as list of all available [[Asset]] that are active on the exchange.
Example
const assets = await nash.listAssets()
console.log(assets)
List a [[CandleRange]] for the given market.
Example
const candleRange = await nash.listCandles({
marketName : 'neo_gas'
})
console.log(candleRange)
``
List all available markets.
Example
const markets = await nash.listMarkets()
console.log(markets)
List all movements for the current authenticated account.
Example
const movements = await nash.listMovements({
currency : 'eth'
})
console.log(movements)
Fetches as list of all available [[Ticker]] that are active on the exchange.
Example
const tickers = await nash.listTickers()
console.log(tickers)
Get [[TradeHistory]] for the given market name.
Example
const tradeHistory = await nash.listTrades({
marketname : 'neo_gas'
})
console.log(tradeHistory.trades)
Login using an API key.
request.
string
string
Legacy login against the central account service. Note: you should prefer to use an API key with the login
method.
Be careful about using this feature, private keys are derived using the password. So this technically gives full access to the account. Because of this the following features are not supported using legacy login.
string
string
string
Example
try {
nash.passwordLogin({
email: "email@domain.com",
password: "example"
})
} catch (e) {
console.error(`login failed ${e}`)
}
Place a limit order.
Example
import {
createCurrencyAmount,
createCurrencyPrice,
OrderBuyOrSell,
OrderCancellationPolicy
} from '@neon-exchange/api-client-typescript'
const order = await nash.placeLimitOrder(
false,
createCurrencyAmount('1', CryptoCurrency.NEO),
OrderBuyOrSell.BUY,
OrderCancellationPolicy.GOOD_TIL_CANCELLED,
createCurrencyPrice('0.01', CryptoCurrency.GAS, CryptoCurrency.NEO),
'neo_gas'
)
console.log(order.status)
Place a market order.
Example
import {
createCurrencyAmount,
OrderBuyOrSell,
} from '@neon-exchange/api-client-typescript'
const order = await nash.placeMarketOrder(
createCurrencyAmount('1.00', CryptoCurrency.NEO),
OrderBuyOrSell.SELL,
'neo_gas'
)
console.log(order.status)
Place a stop limit order.
Example
import {
createCurrencyAmount,
createCurrencyPrice,
OrderBuyOrSell,
OrderCancellationPolicy
} from '@neon-exchange/api-client-typescript'
const order = await nash.placeStopLimitOrder(
false,
createCurrencyAmount('1', CryptoCurrency.NEO),
OrderBuyOrSell.BUY,
OrderCancellationPolicy.GOOD_TIL_CANCELLED,
createCurrencyPrice('0.01', CryptoCurrency.GAS, CryptoCurrency.NEO),
'neo_gas'
createCurrencyPrice('0.02', CryptoCurrency.GAS, CryptoCurrency.NEO)
)
console.log(order.status)
Place a stop market order.
Example
import {
createCurrencyAmount,
createCurrencyPrice,
OrderBuyOrSell,
} from '@neon-exchange/api-client-typescript'
const order = await nash.placeStopLimitOrder(
createCurrencyAmount('1', CryptoCurrency.NEO),
OrderBuyOrSell.BUY,
'neo_gas'
createCurrencyPrice('0.02', CryptoCurrency.GAS, CryptoCurrency.NEO)
)
console.log(order.status)
Submit all states and open orders to be signed for settlement
Example
const signStatesResult = await nash.signStates(getStatesResult)
console.log(signStatesResult)
List all states and open orders to be signed for settlement
Example
const getStatesData = await nash.getStates()
console.log(getStatesData)
Generated using TypeDoc
Create a new instance of Client