bocco emo Platform API client library for node.js
npm install @ux-xu/emo-platform-api-nodejs
npm i emo-platform-api-nodejs
`Usage
Set
ACCESS_TOKEN environment variable.
You can get your access token at the dashboard`ts
import type { AxiosError } from 'axios'
import { EmoApiClient } from '@ux-xu/emo-platform-api-nodejs'const apiClient = new EmoApiClient({
accessToken: 'YOUR ACCESS TOKEN',
refreshToken: 'YOUR REFRESH TOKEN',
})
// Get my account information
apiClient.getMe()
.then(response => {
console.log(response)
})
.catch((error: AxiosError) => {
console.error(
Status code: ${error?.response?.status})
console.error(error?.response?.data)
console.log(error)
})// Get my rooms
apiClient.getRooms()
.then(response => {
console.log(response)
})
.catch((error: AxiosError) => {
console.error(
Status code: ${error?.response?.status})
console.error(error?.response?.data)
})// response example
{
listing: { offset: 0, limit: 50, total: 1 },
rooms: [
{
uuid: 'bcbcbcbc-1234-5678-abcd-aaaaaaaaaaaa',
name: 'My first room',
roomType: 'normal',
roomMembers: [Array]
}
]
}
// Post a message
// You can obtain uuids of rooms from
getRooms API.
const roomUuid = 'bcbcbcbc-1234-5678-abcd-aaaaaaaaaaaa'
apiClient
.postTextMessage(roomUuid, {
text: 'Hello, BOCCO!',
})
.then(response => {
console.log(response)
})
.catch((error: AxiosError) => {
console.error(Status code: ${error?.response?.status})
console.error(error?.response?.data)
})
`
Then you will see the response of GET /v1/mePlease see further documentation at
docs/index.htmlLibrary development
$3
- Node.js 16+ required.
`
yarn install
`$3
`
yarn build
`
Output will be placed under /dist.
$3
`
yarn build:watch
`$3
`
yarn doc
`
Documentation will be placed under docs/.$3
To call SDK functions, modifying
dev.ts would be easy.`
yarn dev:watch
`
Whenever you save dev.ts`, it's recompiled and run.