Skip to main content

API SDK

The API SDK JavaScript package provides a list of functions to make it easier to work with the Bandada API.

Example of project using the API SDK library: bandada-api-sdk-demo.

Install library

npm install @bandada/api-sdk

Create a new instance

# new ApiSdk(url: SupportedUrl | string, config?: object): ApiSdk

Creates a new instance of ApiSdk using the API URL and the config.

  • Creates a new instance using the production Bandada API URL and the default config.

This is what you need if you are using the production Bandada API.

import { ApiSdk } from "@bandada/api-sdk"

const apiSdk = new ApiSdk()

This is useful when working with the development environment.

import { ApiSdk, SupportedUrl } from "@bandada/api-sdk"

const apiSdk = new ApiSdk(SupportedUrl.DEV)
  • Creates a new instance using a custom API URL.
import { ApiSdk } from "@bandada/api-sdk"

const apiSdk = new ApiSdk("https://example.com/api")
  • Creates a new instance using a custom API URL and config.
import { ApiSdk } from "@bandada/api-sdk"

const url = "https://example.com/api"
const config = {
headers: {
"Content-Type": "text/html"
}
}
const apiSdk = new ApiSdk(url, config)

Get groups

# getGroups(): Promise<GroupResponse[]>

Returns the list of groups.

const groups = await apiSdk.getGroups()

Get group

# getGroup(): Promise<GroupResponse>

Returns a specific group.

const groupId = "10402173435763029700781503965100"

const group = await apiSdk.getGroup(groupId)

Is group member

# isGroupMember(): Promise<boolean>

Returns true if the member is in the group and false otherwise.

const groupId = "10402173435763029700781503965100"
const memberId = "1"

const isMember = await apiSdk.isGroupMember(groupId, memberId)

Generate merkle proof

# generateMerkleProof(): Promise<string>

Returns the Merkle Proof for a member in a group.

const groupId = "10402173435763029700781503965100"
const memberId = "1"

const proof = await apiSdk.generateMerkleProof(groupId, memberId)

Add member using an API Key

# addMemberByApiKey(): Promise<void>

Adds a member to a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberId = "1"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.addMemberByApiKey(groupId, memberId, apiKey)

Add members using an API Key

# addMembersByApiKey(): Promise<void>

Adds multiple members to a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberIds = ["1", "2", "3"]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.addMembersByApiKey(groupId, memberIds, apiKey)

Add member using an invite code

# addMemberByInviteCode(): Promise<void>

Adds a member to a group using an Invite Code.

const groupId = "10402173435763029700781503965100"
const memberId = "1"
const inviteCode = "MQYS4UR5"

await apiSdk.addMemberByInviteCode(groupId, memberId, inviteCode)

Remove member using an API Key

# removeMemberByApiKey(): Promise<void>

Removes a member from a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberId = "1"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.removeMemberByApiKey(groupId, memberId, apiKey)

Remove members using an API Key

# removeMembersByApiKey(): Promise<void>

Removes multiple members from a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberIds = ["1", "2", "3"]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.removeMembersByApiKey(groupId, memberIds, apiKey)