Skip to content

viggojonasson/node-prices-tf-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-prices-tf-wrapper

API Wrapper for v2 prices.tf.

Installation

npm i prices-tf-wrapper --save

Usage

The module handles access token re-generation for you. All you have to do is call the methods.

import PricesTF, {RequestOptions, parsePrice} from "prices-tf-wrapper";

const api = new PricesTF();

/* ************* */
/*    METHODS    */
/* ************* */

// Set access token to use.
api.setToken("");

// Clear the current token.
api.clearToken();

// Request a item to get re-checked by the pricer.
api.requestPrice('5021;6');

// Get many prices, paginate through them uses the params.
api.getPrices();

// Get an items price.
api.getPrice('5021;6');

// Get an access token and update the internal one.
api.getAccessToken();

// All endpoint methods allows some options to be provided
const requestOptions: RequestOptions = {
  maxRetries: 3, // Max amount of attempts made on each request before it forfeits.
  waitTime: 10 * 1000, // Time (ms) to wait before retrying again.
  axiosTimeout: 10 * 1000, // The timeout property specified to the axios request.
  skipTokenRegeneration: false, // Whether or not to regenerate a new token, if this is true you will have to specify one yourself using the api.setToken method.
};

// Parse a prices.tf price into a currency object.
api.getPrice('5021;6').then((res) => {
  console.log(parsePrice(res));
})

About

API Wrapper for v2 prices.tf

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published