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
  • Environment
  • ApiKey
  • Demo
  • Features
  1. Developer Guide

Quick Start

PreviousJS-SDKNextIntroducing Relation ONE IM

Last updated 1 year ago

Environment

To complete this tutorial successfully, you must have installed on your machine.

ApiKey

The ApiKey is used to authenticate the application making the request. The following ApiKey sample is for testing purpose only(NOT for production environment): 581c6c4fa0b54912b00088aa563342a4 . If you need to use an ApiKey for production, please refer to this form: 。

The following demo will introduce how to integrate Relation One.

Demo

Repository:

Live Demo:

Guide:

run locally:

git clone https://github.com/relationlabs/relation-im-demo.git
cd relation-im-demo
npm install
npm run dev

Features

Acquire addressAuthToken

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

const { authResult } = await authByMetamask();

Acquire unifiedAuthToken

const { token, error } = await RelationIM.getRelationToken(
  authResult.token,
  APIKEY
)

UserInfo

const userInfoRes = await im.getUserInfo()

Following

const res = await im.getFollowing({
  address: relationId,
  limit,
  cursor
})

Follow/Unfollow

const res = await im.follow(relationId)
const res = await im.unfollow(relationId)

Init IM Instance

const im = RelationIM.init({ token, apiKey: APIKEY, connect: true })

Channel List

const res = await im.userChannelsList({
  cursor,
  limit
})

Receive Message

im.bind(Im.RECEIVE_MSG_OK,(event) => {...})

Messages

const res = await im.messageList({
  channelUuid,
  maxCreateAt: new Date().getTime(),
  limit
})

Send Message

const res = await im.sendMessage({
  channelUuid,
  content
})

Want to deep dive?

Dive a little deeper and start exploring our API reference to get an idea of everything that's possible with the API:

Introduction
Node.js
Relation API Access Request
https://github.com/relationlabs/relation-im-demo
https://app.relationlabs.ai/demo/im/