Options
All
  • Public
  • Public/Protected
  • All
Menu

Main class for work with API for browsers

Library for browsers default export this class

Hierarchy

Index

Methods

call

  • call(method: string, options?: object): Promise<any>
  • Call backend API method directly (types unsafe)

    Use it if backend API update (add new methods, change request or response fileds), but library is not

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • method: string

      Backend API method name

    • options: object = {}

      Backend API options object

    Returns Promise<any>

    Promise, what resolved to backend API response result field value

createInvoice

getBalance

  • getBalance(currencyCode: string, isReturnInNanos?: boolean, isForce?: boolean): Promise<string>
  • Get API app balance value for passed currency

    Call Client.getBalances method to fetch balances information

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • currencyCode: string

      Currency code

    • isReturnInNanos: boolean = false

      If true, return raw balances in nanos, else return converted to coins balances

    • isForce: boolean = false

      If true, return fresh data from backend API, not from cache

    Returns Promise<string>

    Promise, what resolved to API app balance value for passed currency

getBalances

  • getBalances(isReturnInNanos?: boolean, isForce?: boolean): Promise<Balances>
  • Get API app balances infomation

    Use toBalances backend API result convert function

    Call Store.getCurrencies method to fetch exchange rates information

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • isReturnInNanos: boolean = false

      If true, return raw balances in nanos, else return converted to coins balances

    • isForce: boolean = false

      If true, return fresh data from backend API, not from cache

    Returns Promise<Balances>

    Promise, what resolved to API app balances infomation object

getCurrencies

  • getCurrencies(isForce?: boolean): Promise<Currencies>
  • Get API supported currencies infomation

    Use toCurrencies backend API result convert function

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • Optional isForce: boolean

      If true, return fresh data from backend API, not from cache

    Returns Promise<Currencies>

    Promise, what resolved to API supported currencies infomation object

getCurrency

  • getCurrency(currencyCode: string, isForce?: boolean): Promise<Currency>
  • Get currency with passed code infomation

    Call Store.getCurrencies method to fetch currencies information

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • currencyCode: string

      Currency code

    • isForce: boolean = false

      If true, return fresh data from backend API, not from cache

    Returns Promise<Currency>

    Promise, what resolved to currency with passed code infomation object or null, if currency with passed code not exists

getExchangeRate

  • getExchangeRate(source: string, target: string, isForce?: boolean): Promise<number>
  • Get one exchange rate infomation to passed currencies pair

    Call Store.getExchangeRates method to fetch exchange rates information, Store.getCurrencies method to fetch currencies information and use getExchageRate function to get signle exchange rate

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • source: string

      Source currency code

    • target: string

      Target currency code

    • isForce: boolean = false

      If true, return fresh data from backend API, not from cache

    Returns Promise<number>

    Promise, what resolved to exchange rate or zero, if currencies pair not exists

getExchangeRates

  • Get API supported currencies exchange rate infomation

    Use toExchangeRates backend API result convert function

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • Optional isForce: boolean

      If true, return fresh data from backend API, not from cache

    Returns Promise<ExchangeRates>

    Promise, what resolved to API supported currencies exchange rate infomation object

getInvoices

getInvoicesPaginate

getMe

  • getMe(isForce?: boolean): Promise<Me>
  • Get associated with passed API key app infomation

    Use toMe backend API result convert function

    throws

    Error - If there is an error sending request to backend API or parsing response

    Parameters

    • isForce: boolean = false

      If true, return fresh data from backend API, not from cache

    Returns Promise<Me>

    Promise, what resolved to associated with passed API key app infomation object

getPageSize

  • getPageSize(): number

setPageSize

  • setPageSize(pageSizeParam: number): void

Constructors

constructor

  • new Client(apiKey: string, endpoint?: string): Client
  • Create class instance

    throws

    Error - If passed invalid API key or endpoint

    Parameters

    • apiKey: string

      Crypto Bot API key, looks like '1234:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

    • endpoint: string = 'mainnet'

      API endpoint url or 'mainnet' or 'testnet' for hardcoded in library endpoint urls

    Returns Client

Properties

Protected _transport

_transport: Transport

Transport class instance

Private _pageSize

_pageSize: number = 100

Page size for Client.getInvoicesPaginate method