Developer Hub
Relation ProtocolRelation ONE APIRelation Graph API
English
English
  • Overview
    • RelationONE
  • Developer Guide
    • Glossary
    • Service Address
    • Rate Limits
    • JS-SDK
    • Quick Start
  • Introducing Relation ONE IM
  • API
    • Introduction
    • Signature
    • Auth
    • Profile
      • Bind Address
      • Unbind Address
      • User Info
      • List Address
      • Web2 Account
    • Follows
      • Follow
      • Unfollow
      • Follower
      • Following
      • Web3 Follower
      • Web3 Following
    • Recommendation
    • Groups
      • Create
      • Join
      • Remove Members
      • Leave
      • Disband
      • Transfer Owner
      • Info
      • Members
      • Is Admin
      • Get Announcement
      • Update Announcement
    • Chats
      • Pin
      • Mute
      • List
      • Hide
    • Message
      • Send
      • Read
      • Hide
      • List
      • Unread Count
  • JS-SDK
    • Relation-Auth
      • Quick Start
      • Method
    • IM-JS-SDK
      • Quick Start
      • Static Method
      • Events
      • Method
      • Parse Message
    • Plugin-JS-SDK
      • Quick Start
  • Appendix
    • Error Code
    • Contract Address
Powered by GitBook
On this page
  1. JS-SDK
  2. IM-JS-SDK

Quick Start

JS SDK for relation IM: A simple API for building IM services.

Quick start

Download using NPM

npm install --save @relationlabs/im
npm install --save @relationlabs/auth

then

use authByMetamask to activate Metamask signing and acquire an addressAuthToken

import { authByMetamask } from "@relationlabs/auth";

const { error, token: addressAuthToken } = await authByMetamask()

then

use getRelationToken to acquire unifiedAuthToken. The APIKEY should be acquired from the Admin.

import RelationIM from "@relationlabs/im";
import { authByMetamask } from "@relationlabs/auth";

const { error, token: addressAuthToken } = await authByMetamask()

const APIKEY = '581c6c4fa0b54912b00088aa563342a4'

if (!error && addressAuthToken) {
    const { error, token: unifiedAuthToken } = await RelationIM.getRelationToken(addressAuthToken, APIKEY)
    if (!error && unifiedAuthToken) {

    }
}

then

instantiate an im instance

const myIm = RelationIM.init({token: unifiedAuthToken, apiKey: APIKEY, connect: true})
PreviousIM-JS-SDKNextStatic Method

Last updated 2 years ago