Pecunia Node.js API
Notice: This module and API is in early development and may change in the future.
Pecunia Official Website
Getting Started
Install the Pecunia NPM Package with:
npm i pecunia-api
Also, require the module in your Node.js application with:
const pecunia = require("pecunia-api")
Using the API
Authentication
To authenticate with Pecunia, visit the Pecunia API Page and generate an API key. The key will be sent via email, once you've obtained it, throw it into a credentials object like the following:
const creds = {
key: "xxxxx"
}
Supported Coins
An endpoint that gets an object containing the total Pecunia Listed coins, and an array of them.
pecunia.supported(creds).then(coins => {
if (!coins || coins === undefined || !coins.data[0]) return console.error("No coins found on Pecunia")
console.log("Supported coins: " + coins.total)
})
All Nodes
An endpoint that gets an array containing all nodes ran under the API key's account.
pecunia.nodes(creds, "99HOST").then(nodes => {
if (!nodes || nodes === undefined || !nodes[0]) return console.error("No nodes found on Pecunia")
console.log("Nodes found: " + nodes.length + "\n\nNode 1: \nID: " + nodes[0].id + "\nBlockchain: " + nodes[0].nodeId + "\nHosting Type: " + nodes[0].platform)
})
Single Node
An endpoint that gets a node specified by it's "nodeId".
pecunia.node(creds, "99HOST", "39ceda96-ed1d-4291-9fdf-879937616454").then(node => {
if (!node || node === undefined) return console.error("No node found on Pecunia")
console.log("ID: " + node.id + "\nBlockchain: " + node.nodeId + "\nHosting Type: " + node.platform)
})
Example Node.js files can be found in the /examples
directory within the repository.