Quick Start
Environment
To complete this tutorial successfully, you must have Node.js 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: Relation API Access Request。
The following demo will introduce how to integrate Relation One.
Demo
Repository: https://github.com/relationlabs/relation-im-demo
Live Demo: https://app.relationlabs.ai/demo/im/
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:
IntroductionLast updated