/blockscanchat-sdk

NPM Package for Blockscan Chat APIs

Primary LanguageJavaScriptMIT LicenseMIT

Blockscan Chat SDK

A Blockscan Chat API wrapper written in NodeJS

Prerequisites

Set Up

  1. Install this package in your project directory
npm i blockscanchat-sdk
  1. Ensure the "type" parameter in the package.json of your project's root directory is set to "module"
...
  "type": "module",
...

Usage

  1. Import the package to your project
import BlockscanChat from 'blockscanchat-sdk'; 
  1. 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)
  1. 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'})

MESSAGE ENDPOINT

getLocalMsgCount

Gets unread message count of your apikey address

Parameters: None
Usage:

BlockscanChat.message('getLocalMsgCount')

getExternalMsgCount

Gets unread message count of external address (you must have additional apikey permissions)

Parameters:

  • address (REQUIRED) -> Address you want to check the number of messages for
    Usage:
BlockscanChat.message('getExternalMsgCount', {address: 'WALLET_ADDRESS'})

getFirstMsgId

Gets the First Message ID

Parameters: None
Usage:

BlockscanChat.message('getFirstMsgId')

getLastMsgId

Gets the Last Message ID

Parameters: None
Usage:

BlockscanChat.message('getLastMsgId')

getAllMsg

Gets unread message count of your apikey address

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})

sendMsg

Sends a message to a wallet address

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'})

markAllMsgAsRead

All messages with a particular address will be marked as read

Parameters:

  • address (REQUIRED) -> The address with which you want to mark the messages as read
    Usage:
BlockscanChat.message('markAllMsgAsRead', {address: 'WALLET_ADDRESS'})