@buddies/sdk
v2.0.3
Published
Buddies SDK ===
Downloads
19
Readme
Buddies SDK
Accounts Resource
Get current user
const client = new Client({
accessToken
})
const myself = await client.accounts.getCurrentUser()
console.log(myself)
Get a user
const client = new Client()
const user = await client.accounts.getUser('user-id')
console.log(user)
Update profile of the current user
const client = new Client({
accessToken
})
const updatedUser = await client.accounts.updateCurrentUser({
biography: 'New biography 🤪'
})
console.log(updatedUser)
Update profile of a user
const client = new Client({
accessToken
})
const updatedUser = await client.accounts.updateUser('user-id', {
biography: 'New biography 🤪'
})
console.log(updatedUser)
Update interests of the current user
const client = new Client({
accessToken
})
const updatedUser = await client.accounts.updateCurrentUserInterests([
'interest-id-1', 'interest-id-2'
])
console.log(updatedUser)
Update interests of a user
const client = new Client({
accessToken
})
const updatedUser = await client.accounts.updateUserInterests('user-id', [
'interest-id-1', 'interest-id-2'
])
console.log(updatedUser)
Delete current user
const client = new Client({
accessToken
})
await client.accounts.deleteCurrentUser()
Delete a user
const client = new Client({
accessToken
})
await client.accounts.deleteUser('user-id')
Auth Resource
Signup with password
const client = new Client()
const { account, accessToken } = await client.auth.signupWithPassword({
email: '[email protected]',
password: '123456',
authTokenName: 'Android app, Login with password',
nickname: 'John Doe',
username: 'john',
biography: 'Hi i\'m John'
})
Login with password
const client = new Client()
const { account, accessToken } = await client.auth.loginWithPassword({
email: '[email protected]',
password: '123456',
authTokenName: 'IOS app, Login with password'
})
Signup with Google code
const client = new Client()
const { account, accessToken } = await client.auth.signupWithGoogleCode({
code: 'google-code',
authTokenName: 'Website, Login with Google (Chrome on Mac OS X)'
})
Login with Google code
const client = new Client()
const { account, accessToken } = await client.auth.loginWithGoogleCode({
code: 'google-code',
authTokenName: 'Website, Login with Google (Firefox on Windows)'
})
Signup with Google access token
const client = new Client()
const { account, accessToken } = await client.auth.signupWithGoogleAccessToken({
accessToken: 'google-access-token',
authTokenName: 'Android app, Login with Google'
})
Login with Google access token
const client = new Client()
const { account, accessToken } = await client.auth.loginWithGoogleAccessToken({
accessToken: 'google-access-token',
authTokenName: 'IOS app, Login with Google'
})
Auth Tokens Resource
Get auth tokens of the current user
const client = new Client({
accessToken
})
const authTokens = await client.authTokens.getCurrentUserAuthTokens()
console.log(authTokens)
Delete an auth token
const client = new Client({
accessToken
})
await client.authTokens.deleteAuthToken('auth-token-id')
Hashtags Resource
Get feed from a hashtag
const client = new Client()
const page1 = await client.hashtags.getFeed('sport')
console.log(page1.items)
if (page1.hasNext()) {
const page2 = await page1.next()
console.log(page2.items)
}
Interests Resource
Get all interest families with associated interests
const client = new Client()
const families = await client.interests.getInterestFamilies()
for (const family of families) {
console.log(`--- ${family.name} ---`)
for (const interest of family.interests) {
console.log(` -> ${interest.name}`)
}
}
Lists Resource
Get liked videos of the current user
const client = new Client({
accessToken
})
const page1 = await client.lists.getCurrentUserLikedList()
console.log(page1.items)
if (page1.hasNext()) {
const page2 = await page1.next()
console.log(page2.items)
}
Get liked videos of a user
const client = new Client({
accessToken
})
const page1 = await client.lists.getUserLikedList('user-id')
console.log(page1.items)
if (page1.hasNext()) {
const page2 = await page1.next()
console.log(page2.items)
}
Videos Resource
Get feed from a video
const client = new Client()
const page1 = await client.videos.getFeed('video-id')
console.log(page1.items)
if (page1.hasNext()) {
const page2 = await page1.next()
console.log(page2.items)
}
Like a video
const client = new Client({
accessToken
})
await client.videos.like('video-id')
Unlike a video
const client = new Client({
accessToken
})
await client.videos.unlike('video-id')