1.0.1 • Published 6 years ago

trashbin-api v1.0.1

Weekly downloads
1
License
UNLICENSED
Repository
-
Last release
6 years ago

##This is an API to get JSON response from trashbin.6te.net by hash

This module is really simple and is done simply by doing this,

const tb = require("trashbin-api");

There are different modes/settings for how this API handles the JSON responses: 3 - log JSON data in your console 4 - write to a file (requires a filepath) 7 - both 3 and 4 mixed to one (yet this requires a filepath)

Well as we did above with const tb = require("trashbin-api"); we now can do following:

var a = new tb("this-is-an-invalid-hash", "3");

//this is invalid and will give a 0 response from the API like this below

/*
{"crypto":"ok","id":"-7","apiversion":"1","request-time":1538685892,"data":"-4","response":"0"}
*/


var b = new tb("this-is-a-valid-hash", "3");

//this would be able to give a success response from the API and it would look something like this

/*
{"crypto":"this-is-a-valid-hash","id":"8291032","apiversion":"1","request-time":1538685894,"data":"This is the data in the paste you required by the hash","response":"1"}
*/

var c = new tb("hash-37", "4", `${__dirname}/test.json`);

//this would put the JSON response data from the hash "hash-37" in the current directory with a file named test.json, yes put file extension JSON as it is what it works best with and will be changed in future update

##Guide: const tb = require("trashbin-api"); Require the trashbin API module.

new tb(); Makes a new JSON API request if API available.

new tb(, , param3); param1 and param2 is required, while param3 is only required if param2 which is settings parameter is set to 4 or 7. param1 is the hash of the paste you wanna get JSON API response from. param2 is settings/mode which can be set to 3, 4 or 7. param3 is required if param2 is 4 or 7 and not 3, as this is parameter is the filepath for writing to a file.

See settings.txt for more detail on the different settings.