mirror of
https://github.com/AtHeartEngineering/bandada.git
synced 2026-01-08 03:53:59 -05:00
Merge pull request #488 from bandada-infra/docs/update-api-sdk
docs: update api sdk docs with the latest bandada changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs"
|
||||
@@ -50,7 +50,7 @@ pnpm add @bandada/api-sdk
|
||||
|
||||
Creates a new instance of ApiSdk using the API URL and the [config](https://axios-http.com/docs/req_config).
|
||||
|
||||
- Creates a new instance using the production Bandada API URL and the default config.
|
||||
- Create a new instance using the Bandada API URL and the default config.
|
||||
|
||||
This is what you need if you are using the production Bandada API.
|
||||
|
||||
@@ -60,7 +60,7 @@ import { ApiSdk } from "@bandada/api-sdk"
|
||||
const apiSdk = new ApiSdk()
|
||||
```
|
||||
|
||||
- Creates a new instance using a [Supported URL](https://github.com/bandada-infra/bandada/blob/main/libs/api-sdk/src/types/index.ts#L43).
|
||||
- Create a new instance using a [Supported URL](https://github.com/bandada-infra/bandada/blob/main/libs/api-sdk/src/types/index.ts#L43).
|
||||
|
||||
This is useful when working with the development environment.
|
||||
|
||||
@@ -70,7 +70,7 @@ import { ApiSdk, SupportedUrl } from "@bandada/api-sdk"
|
||||
const apiSdk = new ApiSdk(SupportedUrl.DEV)
|
||||
```
|
||||
|
||||
- Creates a new instance using a custom API URL.
|
||||
- Create a new instance using a custom API URL.
|
||||
|
||||
```ts
|
||||
import { ApiSdk } from "@bandada/api-sdk"
|
||||
@@ -78,7 +78,7 @@ 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.
|
||||
- Create a new instance using a custom API URL and config.
|
||||
|
||||
```ts
|
||||
import { ApiSdk } from "@bandada/api-sdk"
|
||||
@@ -92,19 +92,128 @@ const config = {
|
||||
const apiSdk = new ApiSdk(url, config)
|
||||
```
|
||||
|
||||
## Get groups
|
||||
## Create group
|
||||
|
||||
\# **getGroups**(): _Promise\<GroupResponse[]>_
|
||||
\# **createGroup**(): _Promise\<Group>_
|
||||
|
||||
Returns the list of groups.
|
||||
Creates a Bandada group.
|
||||
|
||||
```ts
|
||||
const groups = await apiSdk.getGroups()
|
||||
const groupCreateDetails = {
|
||||
name: "Group 1",
|
||||
description: "This is Group 1.",
|
||||
treeDepth: 16,
|
||||
fingerprintDuration: 3600
|
||||
}
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
const group = await apiSdk.createGroup(groupCreateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Create groups
|
||||
|
||||
\# **createGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Creates one or many Bandada groups.
|
||||
|
||||
```ts
|
||||
const groupsCreateDetails = [
|
||||
{
|
||||
name: "Group 1",
|
||||
description: "This is Group 1.",
|
||||
treeDepth: 16,
|
||||
fingerprintDuration: 3600
|
||||
},
|
||||
{
|
||||
name: "Group 2",
|
||||
description: "This is Group 2.",
|
||||
treeDepth: 16,
|
||||
fingerprintDuration: 3600
|
||||
}
|
||||
]
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
const groups = await apiSdk.createGroups(groupsCreateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Remove group
|
||||
|
||||
\# **removeGroup**(): _Promise\<void>_
|
||||
|
||||
Removes a specific Bandada group.
|
||||
|
||||
```ts
|
||||
const groupId = "10402173435763029700781503965100"
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
await apiSdk.removeGroup(groupId, apiKey)
|
||||
```
|
||||
|
||||
## Remove groups
|
||||
|
||||
\# **removeGroups**(): _Promise\<void>_
|
||||
|
||||
Removes one or many Bandada groups.
|
||||
|
||||
```ts
|
||||
const groupIds = [
|
||||
"10402173435763029700781503965100",
|
||||
"20402173435763029700781503965200"
|
||||
]
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
await apiSdk.removeGroups(groupIds, apiKey)
|
||||
```
|
||||
|
||||
## Update group
|
||||
|
||||
\# **updateGroup**(): _Promise\<Group>_
|
||||
|
||||
Updates a specific Bandada group.
|
||||
|
||||
```ts
|
||||
const groupId = "10402173435763029700781503965100"
|
||||
const groupUpdateDetails = {
|
||||
description: "This is a new group.",
|
||||
treeDepth: 20,
|
||||
fingerprintDuration: 4000
|
||||
}
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
await apiSdk.updateGroup(groupId, groupUpdateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Update groups
|
||||
|
||||
\# **updateGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Updates one or many Bandada groups.
|
||||
|
||||
```ts
|
||||
const groupIds = [
|
||||
"10402173435763029700781503965100",
|
||||
"20402173435763029700781503965200"
|
||||
]
|
||||
const updatedGroups: Array<GroupUpdateDetails> = [
|
||||
{
|
||||
description: "This is a new group1.",
|
||||
treeDepth: 32,
|
||||
fingerprintDuration: 7200
|
||||
},
|
||||
{
|
||||
description: "This is a new group2.",
|
||||
treeDepth: 32,
|
||||
fingerprintDuration: 7200
|
||||
}
|
||||
]
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
await apiSdk.updateGroups(groupId, groupUpdateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Get group
|
||||
|
||||
\# **getGroup**(): _Promise\<GroupResponse>_
|
||||
\# **getGroup**(): _Promise\<Group>_
|
||||
|
||||
Returns a specific group.
|
||||
|
||||
@@ -114,6 +223,16 @@ const groupId = "10402173435763029700781503965100"
|
||||
const group = await apiSdk.getGroup(groupId)
|
||||
```
|
||||
|
||||
## Get groups
|
||||
|
||||
\# **getGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Returns the list of groups.
|
||||
|
||||
```ts
|
||||
const groups = await apiSdk.getGroups()
|
||||
```
|
||||
|
||||
## Is group member
|
||||
|
||||
\# **isGroupMember**(): _Promise\<boolean>_
|
||||
@@ -209,3 +328,29 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
await apiSdk.removeMembersByApiKey(groupId, memberIds, apiKey)
|
||||
```
|
||||
|
||||
## Create invite
|
||||
|
||||
\# **createInvite**(): _Promise\<Invite>_
|
||||
|
||||
Creates a new group invite.
|
||||
|
||||
```ts
|
||||
const groupId = "10402173435763029700781503965100"
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
const invite = await apiSdk.createInvite(groupId, apiKey)
|
||||
```
|
||||
|
||||
## Get invite
|
||||
|
||||
\# **getInvite**(): _Promise\<Invite>_
|
||||
|
||||
Returns a specific invite.
|
||||
|
||||
```ts
|
||||
const inviteCode = "C5VAG4HD"
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
const invite = await apiSdk.getInvite(inviteCode)
|
||||
```
|
||||
11
apps/docs/docs/api.md
Normal file
11
apps/docs/docs/api.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# API
|
||||
|
||||
The API has a list of endpoints to interact with the Bandada infrastructure.
|
||||
|
||||
It is compatible with any programming language that supports REST API requests.
|
||||
|
||||
Read the documentation of the API and try it out: [Bandada API Docs](https://api.bandada.pse.dev/).
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"label": "API",
|
||||
"position": 2
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# API Docs
|
||||
|
||||
Read the documentation of the API and try it out: [Bandada API Docs](https://api.bandada.pse.dev/).
|
||||
@@ -1,5 +1,27 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# FAQ
|
||||
# FAQ
|
||||
|
||||
## Where can I ask questions about Bandada?
|
||||
|
||||
You can ask questions about Bandada in the [PSE Discord](https://discord.com/invite/sF5CT5rzrR), there is a channel for it called `bandada` or by opening a [Bandada Discussion](https://github.com/orgs/bandada-infra/discussions).
|
||||
|
||||
The most frequent asked questions will be listed below.
|
||||
|
||||
## How can I start a project using Bandada?
|
||||
|
||||
There are 3 ways you can start using Bandada in your project:
|
||||
|
||||
- [API](https://api.bandada.pse.dev/)
|
||||
|
||||
This is a good option if you are not using TypeScript/JavaScript and want to interact with the Bandada infrastructure.
|
||||
|
||||
- [API SDK](https://github.com/bandada-infra/bandada/tree/main/libs/api-sdk)
|
||||
|
||||
This is a good option if you are using TypeScript/JavaScript and want to interact with the Bandada infrastructure.
|
||||
|
||||
- [Boilerplate](https://github.com/bandada-infra/boilerplate)
|
||||
|
||||
This is a good option if you want to quickly create a Bandada project because you can fork it, clone it or use it as a template.
|
||||
|
||||
@@ -5,3 +5,8 @@ slug: /
|
||||
|
||||
# What is Bandada?
|
||||
|
||||
Bandada is an infrastructure to manage privacy-preserving groups. It also provides antisybil mechanisms by using credential groups so that you can only join a group if you meet a specific criteria.
|
||||
|
||||
Bandada is a public good project. It is free and open source. Everyone can use it and contribute to it.
|
||||
|
||||
- Bandada is a Spanish word that means **group of birds**. It is the same as the English word **flock**.
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
import RenderArticles from "../src/components/RenderArticles"
|
||||
|
||||
@@ -67,6 +67,8 @@ yarn add @bandada/api-sdk
|
||||
|
||||
## 📜 Usage
|
||||
|
||||
## 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](https://axios-http.com/docs/req_config).
|
||||
@@ -113,6 +115,8 @@ const config = {
|
||||
const apiSdk = new ApiSdk(url, config)
|
||||
```
|
||||
|
||||
## Create group
|
||||
|
||||
\# **createGroup**(): _Promise\<Group>_
|
||||
|
||||
Creates a Bandada group.
|
||||
@@ -129,6 +133,8 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
const group = await apiSdk.createGroup(groupCreateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Create groups
|
||||
|
||||
\# **createGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Creates one or many Bandada groups.
|
||||
@@ -153,6 +159,8 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
const groups = await apiSdk.createGroups(groupsCreateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Remove group
|
||||
|
||||
\# **removeGroup**(): _Promise\<void>_
|
||||
|
||||
Removes a specific Bandada group.
|
||||
@@ -164,6 +172,8 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
await apiSdk.removeGroup(groupId, apiKey)
|
||||
```
|
||||
|
||||
## Remove groups
|
||||
|
||||
\# **removeGroups**(): _Promise\<void>_
|
||||
|
||||
Removes one or many Bandada groups.
|
||||
@@ -178,6 +188,8 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
await apiSdk.removeGroups(groupIds, apiKey)
|
||||
```
|
||||
|
||||
## Update group
|
||||
|
||||
\# **updateGroup**(): _Promise\<Group>_
|
||||
|
||||
Updates a specific Bandada group.
|
||||
@@ -194,6 +206,8 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
await apiSdk.updateGroup(groupId, groupUpdateDetails, apiKey)
|
||||
```
|
||||
|
||||
## Update groups
|
||||
|
||||
\# **updateGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Updates one or many Bandada groups.
|
||||
@@ -220,13 +234,7 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
await apiSdk.updateGroups(groupId, groupUpdateDetails, apiKey)
|
||||
```
|
||||
|
||||
\# **getGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Returns the list of groups.
|
||||
|
||||
```ts
|
||||
const groups = await apiSdk.getGroups()
|
||||
```
|
||||
## Get group
|
||||
|
||||
\# **getGroup**(): _Promise\<Group>_
|
||||
|
||||
@@ -238,6 +246,18 @@ const groupId = "10402173435763029700781503965100"
|
||||
const group = await apiSdk.getGroup(groupId)
|
||||
```
|
||||
|
||||
## Get groups
|
||||
|
||||
\# **getGroups**(): _Promise\<Group[]>_
|
||||
|
||||
Returns the list of groups.
|
||||
|
||||
```ts
|
||||
const groups = await apiSdk.getGroups()
|
||||
```
|
||||
|
||||
## Is group member
|
||||
|
||||
\# **isGroupMember**(): _Promise\<boolean>_
|
||||
|
||||
Returns true if the member is in the group and false otherwise.
|
||||
@@ -249,6 +269,8 @@ 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.
|
||||
@@ -260,6 +282,8 @@ 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.
|
||||
@@ -272,6 +296,8 @@ 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.
|
||||
@@ -284,6 +310,8 @@ 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.
|
||||
@@ -296,6 +324,8 @@ 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.
|
||||
@@ -308,6 +338,8 @@ 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.
|
||||
@@ -320,6 +352,21 @@ const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
await apiSdk.removeMembersByApiKey(groupId, memberIds, apiKey)
|
||||
```
|
||||
|
||||
## Create invite
|
||||
|
||||
\# **createInvite**(): _Promise\<Invite>_
|
||||
|
||||
Creates a new group invite.
|
||||
|
||||
```ts
|
||||
const groupId = "10402173435763029700781503965100"
|
||||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"
|
||||
|
||||
const invite = await apiSdk.createInvite(groupId, apiKey)
|
||||
```
|
||||
|
||||
## Get invite
|
||||
|
||||
\# **getInvite**(): _Promise\<Invite>_
|
||||
|
||||
Returns a specific invite.
|
||||
|
||||
Reference in New Issue
Block a user