0.5.7 • Published 4 years ago

nomics v0.5.7

Weekly downloads
147
License
MIT
Repository
github
Last release
4 years ago

Nomics JavaScript client

A Node and Browser client to make using the Nomics API a breeze in your JavaScript project.

This project is currently under development

Installation and Usage

To install the Nomics client, simply install the package:

npm install --save nomics
yarn add nomics

Then import and initialize the client:

import Nomics from "nomics";

// ...

const nomics = new Nomics({
  apiKey: "<your api key>"
});

// ...

Ticker functions

To interact with the API after initializing the client, call the corresponding function off of the client variable:

async function client() {
  // all currencies provided by the ticker with default options
  const currencies = await nomics.currenciesTicker();
}

Please note the use of await here. Because these requests are asynchronous and are returned via Promise, the functions must be awaited. Using promise syntax will also work:

function client() {
  let currencies;
  nomics.currenciesTicker().then(ticker => (currencies = ticker));
}

All ticker functions can take two arguments (both are optional): ticker options (see relevant ticker information) and request fetch options.

nomics.currenciesTicker(tickerOptions, fetchOptions);

For fetch options, an object conforming to fetch standard options can be passed. These options are for more advanced configurations, and for a majority of use cases, should not need to be included.

Currently supported Ticker functions

Currencies

nomics.currenciesTicker({
  /*
    Specify the interval for interval data in return
    One or more strings can be provided. If not provided, **all** are used.
    The intervals specified will affect what is returned in the response (see below)
  */
  interval?: ['1d'], // '1d', '7d', '30d', '365d', 'ytd'
  /*
    Limit the returned currencies to the ones in the following array. If not
    specified, **all** will be returned
  */
  ids?: ['BTC', 'ETH'],
  /*
    Specify the currency to quote all returned prices in
  */
  quoteCurrency?: "EUR", // [DEPRECATED] use "convert" below instead
  convert?: "EUR", // defaults to "USD"
});

This returns a list of all currencies from the currencies ticker endpoint with the following data:

NameTypeDescription
idstringThe currency's display id
symbolstringThe currency's original symbol
namestringThe full name
logo_urlstringThe url for the currency logo image
pricestringCurrent price
price_datestringThe date (YYYY-MM-DD) of the price
circulating_supplystringThe current circulating supply
max_supplystringThe max supply of the currency
market_capstringTotal market cap for the currency
rankstringRank by market cap
highstringAll time high for the currency
high_timestampstringThe date of the all time high

Additionally, the returned data will come with interval information corresponding to the interval options passed with the call for each of the currency rows. For each interval string, the response will will have a key of the same name with interval data.

For example:

const currencies = await nomics.currenciesTicker();
const oneDayIntervalData = currencies[0]["1d"]; // the first row's 1d interval

The interval data is as follows:

NameTypeDescription
volumestringCurrent volume
price_changestringPrice change over the interval
price_change_pctstringPrice change percent over the interval
volume_changestringVolume change over the interval
volume_change_pctstringVolume change percent over the interval
market_cap_changestringMarket cap change over the interval
market_cap_change_pctstringMarket cap change percent over the interval

Development

Publishing a new version

  1. Version the package: npm version {patch | minor | major} — this updates the package json accordingly
  2. Publish the package: npm publish — this does a pre-publish step to transpile the code to /dist, and then it publishes that. If you have 2FA setup, it’ll prompt you to enter that before publish finishes
  3. Commit and push the update back to master: git push origin master — just make sure that the package.json in master matches the published version
0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago