Example
import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
const nash = new Client(EnvironmentConfiguration.sandbox)
Cancel all orders by market name
Example
const result = await nash.cancelAllOrders('neo_gas')
console.log(result)
Cancel an order by ID.
Example
const cancelledOrder = await nash.cancelOrder('11')
console.log(cancelledOrder)
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}`)
}
}
)
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)
List all current asset nonces
Example
const getNoncesData = await nash.getAssetNonces()
console.log(getNoncesData)
[description]
List all orders for a given movement
Example
const getOrdersForMovementData = await nash.getOrdersForMovement(unit)
console.log(getOrdersForMovementData)
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)
Used by our internal trading bot
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.legacyLogin({
email: "email@domain.com",
password: "example"
})
} catch (e) {
console.error(`login failed ${e}`)
}
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)
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)
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
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)
helper function that returns the correct types for the needed GQL queries and mutations.
Submit all states and open orders to be signed for settlement
Example
const signStatesResult = await nash.signStates(getStatesResult)
console.log(signStatesResult)
Sign a withdraw request.
Example
import { createCurrencyAmount } from '@neon-exchange/api-client-ts'
const address = 'd5480a0b20e2d056720709a9538b17119fbe9fd6';
const amount = createCurrencyAmount('1.5', CryptoCurrency.ETH);
const signedMovement = await nash.signWithdrawRequest(address, amount);
console.log(signedMovement)
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