Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/algolia/algoliasearch-client-go

⚡️ A fully-featured and blazing-fast Go API client to interact with Algolia.
https://github.com/algolia/algoliasearch-client-go

algolia algolia-search api-client go search

Last synced: about 1 month ago
JSON representation

⚡️ A fully-featured and blazing-fast Go API client to interact with Algolia.

Awesome Lists containing this project

README

        



Algolia for Go

The perfect starting point to integrate Algolia within your Go project


Github Releases
GoDoc
Go Report Card
License
Supported version


Documentation
Community Forum
Stack Overflow
Report a bug
FAQ
Support

## ✨ Features

* Support Go 1.19 and above
* Typed requests and responses
* First-class support for user-defined structures
* Injectable HTTP client

## 💡 Getting Started

First, install the Algolia API Go Client via the go get command:

```bash
go get github.com/algolia/algoliasearch-client-go/v4
```

You can now import the Algolia API client in your project and play with it.

```go
import "github.com/algolia/algoliasearch-client-go/v4/algolia/search"

client, err := search.NewClient("YOUR_APP_ID", "YOUR_API_KEY")

// Add a new record to your Algolia index
response, err := client.SaveObject(client.NewApiSaveObjectRequest(
"", map[string]any{"objectID": "id", "test": "val"},
))
if err != nil {
// handle the eventual error
panic(err)
}

// use the model directly
print(response)

// Poll the task status to know when it has been indexed
taskResponse, err := searchClient.WaitForTask("", response.TaskID, nil, nil, nil)
if err != nil {
panic(err)
}

// Fetch search results, with typo tolerance
response, err := client.Search(client.NewApiSearchRequest(

search.NewEmptySearchMethodParams().SetRequests(
[]search.SearchQuery{*search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("").SetQuery("").SetHitsPerPage(50))}),
))
if err != nil {
// handle the eventual error
panic(err)
}

// use the model directly
print(response)
```

For full documentation, visit the **[Algolia Go API Client](https://www.algolia.com/doc/libraries/go/)**.

## ❓ Troubleshooting

Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/go/) where you will find answers for the most common issues and gotchas with the client. You can also open [a GitHub issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&projects=&template=Bug_report.md)

## Contributing

This repository hosts the code of the generated Algolia API client for Go, if you'd like to contribute, head over to the [main repository](https://github.com/algolia/api-clients-automation). You can also find contributing guides on [our documentation website](https://api-clients-automation.netlify.app/docs/introduction).

## 📄 License

The Algolia Go API Client is an open-sourced software licensed under the [MIT license](LICENSE).