This package has been deprecated

Author message:

The Hash API is no longer in service. I recommend using https://www.npmjs.com/package/chainpoint-client instead. Learn more at https://chainpoint.org/

hashapi-lib-node

1.3.0 • Public • Published

hashapi-lib-node

npm npm

Tierion Hash API client library for Node.js

Installation

$ npm install --save hashapi-lib-node

Authenticate

You may either create a HashClient object with token values you've already received, or you may authenticate using your Tierion credentials. In both cases, tokens will refresh automatically when they expire.

To use token values you have already received to create a HashClient object:

var hashclient = require('hashapi-lib-node');
 
var access_token = 'your_access_token_here';
var refresh_token = 'your_refresh_token_here';
var hashClient = new hashclient(access_token, refresh_token);

To create a HashClient object and authenticate with your Tierion username and password:

var hashclient = require('hashapi-lib-node');
 
var username = 'your_username_here';
var password = 'your_password_here';
var hashClient = new hashclient();
 
hashClient.authenticate(username, password, function(err, authToken){
    if(err) {
        // handle the error
    } else {
        // authentication was successful
        // access_token, refresh_token are returned in authToken
        // authToken values are saved internally and managed autmatically for the life of the HashClient 
    }
});

Once authenticated, you may choose to manually refresh your access token instead of waiting for the client to auto refresh.

hashClient.refreshAuthToken(function(err, authToken){
    if(err) {
        // handle the error
    } else {
        // refresh was successful
    }
});

Usage

This library contains a function for each Tierion Hash API endpoint. Each function will return the JSON result for each endpoint as defined in the Hash API documentation at https://tierion.com/docs/hashapi.

HashItems

hashClient.submitHashItem(hash, function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});

Receipts

hashClient.getReceipt(id, function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});

BlockSubscriptions

hashClient.getAllBlockSubscriptions(function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});
hashClient.getBlockSubscription(id, function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});
// parameters variable is an object with up to two elements ->
// callbackUrl - REQUIRED - Your url endpoint for the block subscription callback
// label - OPTIONAL - Label used for your own reference
hashClient.createBlockSubscription(parameters, function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});
// parameters variable is an object with up to two elements ->
// callbackUrl - OPTIONAL - Set to update callbackUrl value
// label - OPTIONAL - Set to update label value
hashClient.updateBlockSubscription(id, parameters, function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});
hashClient.deleteBlockSubscription(id, function(err, result){
    if(err) {
        // handle the error
    } else {
        // process result
    }
});

Package Sidebar

Install

npm i hashapi-lib-node

Weekly Downloads

0

Version

1.3.0

License

MIT

Last publish

Collaborators

  • jasonbukowski
  • waynevaughan