1.0.1 • Published 2 years ago

fixedfloat-api v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Installation

With NPM

npm i fixedfloat-api

With Yarn

yarn add fixedfloat-api

Usage

const FixedFloat = require("fixedfloat-api");
const fixed = new FixedFloat('API_KEY', 'API_SECRET');

Methods

constructor(settings)

Create instance.

const fixed = new FixedFloat('API_KEY', 'API_SECRET');

.getCurrencies()

Getting a list of all currencies that are available. Official docs

const response = await fixed.getCurrencies();

.getPrice(from, to, type)

Information about a currency pair with a set amount of funds. Official docs

// Simple float
const response = await fixed.getPrice('0.1 ETH', 'BTC');

// Reversive fixed
const response = await fixed.getPrice('ETH', '0.1 BTC', 'fixed');

.getOrder(id, token)

Receiving information about the order. Official docs

Modified original response: added a response.statusText (see Order states section)

const response = await fixed.getOrder('ORDER_ID', 'ORDER_TOKEN');

.setEmergency(id, token, choice, address)

Emergency Action Choice. Official docs

await fixed.setEmergency('ORDER_ID', 'ORDER_TOKEN', 'EXCHANGE or REFUND', 'ADDRESS for refund');

.createOrder(from, to, toAddress, type, extra)

Creating exchange order. Official docs

Modified original response: added a response.statusText (see Order states section)

const response = await fixed.createOrder('0.1 ETH', 'BTC', 'BTC address');

._request(req_method, api_method, body)

Call method manually.

Attention: this is a utility method

// GET query or POST body
const body = new URLSearchParams({
    someParam: 'someValue',
    ...
});
const response = await fixed._request('GET or POST', 'methodName', body);

Order states

All order states (statuses) are listed here

const STATES = [
    /* 0 */ 'Transaction expected',
    /* 1 */ 'The transaction is waiting for the required number of confirmations',
    /* 2 */ 'Currency exchange',
    /* 3 */ 'Sending funds',
    /* 4 */ 'Completed',
    /* 5 */ 'Expired',
    /* 6 */ 'Not currently in use',
    /* 7 */ 'A decision must be made to proceed with the order'
];

License

fixedfloat-api is Licensed under the MIT License. Simple and clear about MIT License is written here