A Node.js client for the CryptoKingdom API.
This client supports public and private calls to the Agora Marketplace for trading on CryptoKingdom.
GitHub repository: github.com/saddammonero/cryptokingdom
ISC, open source. See LICENSE file.
npm install cryptokingdom
git clone https://github.com/saddammonero/cryptokingdom.git
cd cryptokingdom
npm install
var CryptoKingdom = require('cryptokingdom');
If not installed via NPM, provide the path to lib/cryptokingdom.js
var ck = new CryptoKingdom('USERNAME', 'PASSWORD', 'DEVICE_ID');
Supported API methods: buy, sell, cancelBid, cancelAsk, cancelAll, give, consume, getStateForItem. All methods require a callback function. The callback is passed two arguments: an error object (null if successful), and a data object (the response from the API).
These methods do not require user authentication.
Returns the current order book for a given item.
ck.getStateForItem('W1604', function(err, data){
if (err){
//handle error
}
console.log(data);
});
Example response:
{ asks: [ { id: '2557', itemID: 'w1604', price: '200000', amount: '5', shortName: 'saddam'} ],
bids: [ { price: '80000', amount: '100', shortName: 'binaryFate' },
{ price: '30000', amount: '50', shortName: 'Zechariah' } ] }
These methods require username, password, and deviceID for user authentication.
Places a bid order for a given item.
ck.buy('W1601', 1, 10000, function(err, response){
if(err){
//handle error
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: 'New bid added for 1 units of W1601 at a limit price of 10000.' } }
Places an ask order for a given item.
ck.sell('W1601', 1, 250000, function(err, response){
if(err){
//handle error
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: 'New ask added for 1 units of W1601 at a limit price of 250000.' } }
Cancels all ask and bid orders for a given item.
ck.cancelAll('W1601', function(err, response){
if(err){
//handle error
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: 'Your asks and bids are cancelled' } }
Cancels a specified bid order.
ck.cancelBid('W1601', 1, 10000, function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
Example response:
{ status: 200, error: false, data: { result: 'Order removed.' } }
Cancels a specified ask order.
ck.cancelAsk('W1601', 1, 300000, function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
Example response:
{ status: 200, error: false, data: { result: 'Order removed.' } }
Give an item to another player. Recipient can be specified as ID or username.
ck.give('W1601', 1, 57, function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
OR:
ck.give('W1601', 1, 'Riddick', function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: '1 units of W1601 given to Riddick.' } }
Consume an item. Item must be consumable.
ck.consume('W1604', 1, function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: '1 units of W1604 consumed.' } }
Create an item to recipient. Senior admin only.
ck.create('BEER', 1, 7, function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: '1 units of beer created to saddam' } }
Transfer an item from a character to another character. Senior admin only.
ck.transfer('BEER', 1, 7, 57, function(err, response){
if(err){
console.log(err);
}
console.log(response);
});
Example response:
{ status: 200,
error: false,
data: { result: '1 units of BEER transferred to Riddick.' } }