A Blockscan Chat API wrapper written in NodeJS
- NodeJS
node -v
winget install OpenJS.NodeJS
- Blockscan Chat API Key and URL (Apply at https://chat.blockscan.com/apis)
- Install this package in your project directory
npm i blockscanchat-sdk
- Import the package to your project
const BlockscanChat = require('blockscanchat-sdk');
let blockscanchat = new BlockscanChat();
- Initalize the SDK by passing in the Blockscan API_KEY and API_URL parameters specified as your environment variables
blockscanchat.init('YOUR_API_KEY');
- Generally, for all methods, the calling convention is
blockscanchat.<METHOD_NAME>(PARAMETERS)
Example (if method does not require parameters):
blockscanchat.<METHOD_NAME>()
Example (if method requires parameters):
blockscanchat.getExternalMsgCount('EXTERNAL_WALLET_ADDRESS')
Parameters: None
Usage:
blockscanchat.getLocalMsgCount().then((response) => {
console.log(response);
});
Retrieves the unread message count of an external address. (you must have additional apikey permissions)
Parameters:
- address (REQUIRED) - The external wallet address.
Usage:
blockscanchat.getExternalMsgCount('WALLET_ADDRESS').then((response) => {
console.log(response);
});
Parameters: None
Usage:
blockscanchat.getFirstMsgId().then((response) => {
console.log(response);
});
Parameters: None
Usage:
blockscanchat.getLastMsgId().then((response) => {
console.log(response);
});
Parameters:
- startID (OPTIONAL) -> Integer message ID to start searching for chats
- offset (OPTIONAL) -> Number of chats displayed per page, maximum is 100
- cType (OPTIONAL) -> Chat Type, 0 = All, 1 = Incoming Messages, 2 = Outgoing Messages
Usage:
No parameters
blockscanchat.getAllMsg().then((response) => {
console.log(response);
});
With parameters
blockscanchat.getAllMsg({startID: 539070, offset: 99, cType: 2}).then((response) => {
console.log(response);
});
Parameters:
- address (REQUIRED) -> Address you want to send the message to
- message (REQUIRED) -> Message you want to sent to that address
Usage:
blockscanchat.sendMsg('TARGET_ADDRESS', 'YOUR_MESSAGE').then((response) => {
console.log(response);
});
Parameters:
- address (REQUIRED) -> The address with which you want to mark the messages as read
Usage:
blockscanchat.markAllMsgAsRead('WALLET_ADDRESS').then((response) => {
console.log(response);
});