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
- Ensure the "type" parameter in the package.json of your project's root directory is set to "module"
...
"type": "module",
...
- Import the package to your project
import BlockscanChat from 'blockscanchat-sdk';
- Initalize the SDK by passing in the Blockscan API_KEY and API_URL parameters specified as your environment variables
BlockscanChat.init(api_key, api_url)
- Generally, for all methods, the calling convention is
BlockscanChat.<MODULE_NAME>('METHOD_NAME', {PARAMETERS})
Example (if method does not require parameters):
BlockscanChat.message('getLocalMsgCount')
Example (if method requires parameters):
BlockscanChat.message('getExternalMsgCount', {address: 'EXTERNAL_WALLET_ADDRESS'})
Parameters: None
Usage:
BlockscanChat.message('getLocalMsgCount')
Parameters:
- address (REQUIRED) -> Address you want to check the number of messages for
Usage:
BlockscanChat.message('getExternalMsgCount', {address: 'WALLET_ADDRESS'})
Parameters: None
Usage:
BlockscanChat.message('getFirstMsgId')
Parameters: None
Usage:
BlockscanChat.message('getLastMsgId')
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.message('getAllMsg')
With parameters
BlockscanChat.message('getAllMsg', {startID: 539070, offset: 99, cType: 2})
Parameters:
- address (REQUIRED) -> Address you want to send the message to
- message (REQUIRED) -> Message you want to sent to that address
Usage:
BlockscanChat.message('sendMsg', {address: 'TARGET_ADDRESS', message: 'YOUR_MESSAGE'})
Parameters:
- address (REQUIRED) -> The address with which you want to mark the messages as read
Usage:
BlockscanChat.message('markAllMsgAsRead', {address: 'WALLET_ADDRESS'})