Profile
Back to NewsBack
GitHub Trending 2 min
Reader Mode
algolia/algoliasearch-client-go: ⚡️ A fully-featured and blazing-fast Go API client to interact with Algolia.

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

9 hours ago

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 • 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:

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

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

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( "<YOUR_INDEX_NAME>", 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("<YOUR_INDEX_NAME>", 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("<YOUR_INDEX_NAME>").SetQuery("<YOUR_QUERY>").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.

❓ Troubleshooting

Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the client. You can also open a GitHub issue

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. You can also find contributing guides on our documentation website.

📄 License

The Algolia Go API Client is an open-sourced software licensed under the MIT license.

Chat with me