-
-
Notifications
You must be signed in to change notification settings - Fork 1
4. API Usage
Axorax edited this page Apr 14, 2023
·
1 revision
To interact with the Duino Coin API with duco.js you still need to create a variable with the below code:
const api = new Duco({
username: 'axorax'
});
Note: We used 'api' for the variable name here instead of 'miner' to make it easier for the reader to understand but using the variable name 'miner' will also work.
api.get('shop')
.then(data => {
console.log(data)
}).catch((error) => {
console.log(error)
})
The above code shows how to catch errors in getting data. Don't focus on the api.get('shop')
part it is described below. You can do this to catch in all the interactions with the API.
The error catching part won't be showed in the other code examples to keep the code shorter and easier to understand.
api.get()
.then(data => {
console.log(data)
})
api.get('user')
.then(data => {
console.log(data)
})
This will give less information than using api.get()
api.get('stats')
.then(data => {
console.log(data)
})
api.get('pools')
.then(data => {
console.log(data)
})
api.get('balance')
.then(data => {
console.log(data)
})
api.get('miners')
.then(data => {
console.log(data)
})
api.get('transactions')
.then(data => {
console.log(data)
})
api.get('latestTransactions')
.then(data => {
console.log(data)
})
api.get('hash', '1437cfdcd0dadf286d10a0cf03a61d2e77c089e8')
.then(data => {
console.log(data)
})
api.get('id', 1251235)
.then(data => {
console.log(data)
})
api.auth({
password: 'testing'
})
.then(data => {
console.log(data)
})
api.get('shop')
.then(data => {
console.log(data)
})
api.buy({
item: <numeric-value-of-item>,
password: 'your-password'
})
.then(data => {
console.log(data)
})
api.send({
password: 'your-password',
recipient: 'revox',
amount: 1,
memo: 'duco.js'
})
api.exchange({
password: 'your-password',
email: 'your-email',
type: 'ex-type',
amount: 15000,
coin: 'crypto-currency-you-want',
address: 'your-crypto-wallet-address'
})