Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aliml92 committed Oct 6, 2024
1 parent 6b675cb commit 1c03af6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ go get github.com/aliml92/go-typesense
## Usage
The `go-typesense` package provides a `Client` for accessing typesense server.
```go
client, _ := typesense.NewClient(nil, "http://localhost:8108")
client = client.WithAPIKey("xyz")
client, _ := typesense.NewClient(nil, "http://localhost:8108", "xyz")
```
### Create a collection
```go
Expand Down Expand Up @@ -90,11 +89,14 @@ The official documentation for the [Bootstrap API Key](https://typesense.org/doc
Here is how you can achive this with `go-typesense` library. Let's say `xyz` is
the bootstrap API key
```go

baseClient, _ := typesense.NewClient(nil, "http://localhost:8108")
bootstrapAPIKey := "xyz"
serverURL := "http://localhost:8108"

// rootClient is admin client with all persmissions and has no expiration.
rootClient := baseClient.WithAPIKey("xyz")
// rootClient is admin client with all persmissions and has no expiration.
rootClient, _ := typesense.NewClient(nil, serverURL, bootstrapAPIKey)
if err != nil {
log.Fatal(err)
}

// create an admin key with one-month expiration
ctx := context.Background()
Expand All @@ -114,7 +116,7 @@ the bootstrap API key
}

// revocable admin client for day-to-day operations
adminClient := baseClient.WithAPIKey(*key.Value)
adminClient, _ := typesense.NewClient(nil, serverURL, *key.Value)
```
#### Search-only API key
```go
Expand All @@ -131,9 +133,8 @@ the bootstrap API key
}

// soClient is a Search-only client
soClient := baseClient.WithAPIKey(*key.Value)
soClient, _ := typesense.NewClient(nil, serverURL, *key.Value)
```
>Note: `Client` instances with an API key must be derived from `baseClient` (a client with no API key set).

### Rate limiting
The `/limits` API endpoint allows setting rate limits based on client's API key
Expand Down

0 comments on commit 1c03af6

Please sign in to comment.