Skip to content

Commit

Permalink
Merge pull request #488 from bandada-infra/docs/update-api-sdk
Browse files Browse the repository at this point in the history
docs: update api sdk docs with the latest bandada changes
  • Loading branch information
vplasencia authored Apr 12, 2024
2 parents 6766a09 + 0ce4848 commit 3fd84eb
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 31 deletions.
165 changes: 155 additions & 10 deletions apps/docs/docs/api/api-sdk.md → apps/docs/docs/api-sdk.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 3
---

import Tabs from "@theme/Tabs"
Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -70,15 +70,15 @@ 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"

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"
Expand All @@ -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.

Expand All @@ -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>_
Expand Down Expand Up @@ -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 changes: 11 additions & 0 deletions apps/docs/docs/api.md
Original file line number Diff line number Diff line change
@@ -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/).
4 changes: 0 additions & 4 deletions apps/docs/docs/api/_category_.json

This file was deleted.

7 changes: 0 additions & 7 deletions apps/docs/docs/api/api-docs.md

This file was deleted.

26 changes: 24 additions & 2 deletions apps/docs/docs/faq.md
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions apps/docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**.
2 changes: 1 addition & 1 deletion apps/docs/docs/resources.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
---

import RenderArticles from "../src/components/RenderArticles"
Expand Down
Loading

0 comments on commit 3fd84eb

Please sign in to comment.