Skip to content

algolia/algoliasearch-client-csharp

Repository files navigation

Algolia for C#

The perfect starting point to integrate Algolia within your .NET project

Nuget Licence

DocumentationCommunity ForumStack OverflowReport a bugFAQSupport

✨ Features

  • Targets .NET Standard: .NET Standard 2.0 or .NET Standard 2.1.
  • For more details about supported .NET implementations, please see .NET Standard official page.
  • Asynchronous and synchronous methods to interact with Algolia's API.
  • Thread-safe clients.
  • No external dependencies.
  • Typed requests and responses.
  • Injectable HTTP client.
  • Retry strategy & Helpers.

Migration note from v5.x to v6.x

In January 2019, we released v6 of our .NET client. If you are using version 5.x of the client, read the migration guide to version 6.x. Version 5.x will no longer be under active development.

💡 Getting Started

To get started, first install the Algolia.Search client.

You can get the last version of the client from NuGet.

If you are using the .NET CLI, you can install the package using the following command:

dotnet add package Algolia.Search --version <The version you want to install>

Or directly in your .csproj file:

<PackageReference Include="Algolia.Search" Version=${versions.csharp} />

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

using Algolia.Search.Clients;
using Algolia.Search.Http;

var client = new SearchClient(new SearchConfig("YOUR_APP_ID", "YOUR_API_KEY"));

// Add a new record to your Algolia index
var response = await client.SaveObjectAsync(
  "<YOUR_INDEX_NAME>",
  new Dictionary<string, string> { { "objectID", "id" }, { "test", "val" } }
);

// Poll the task status to know when it has been indexed
await client.WaitForTaskAsync("<YOUR_INDEX_NAME>", response.TaskID);

// Fetch search results, with typo tolerance
var response = await client.SearchAsync<Object>(
  new SearchMethodParams
  {
    Requests = new List<SearchQuery>
    {
      new SearchQuery(
        new SearchForHits
        {
          IndexName = "<YOUR_INDEX_NAME>",
          Query = "<YOUR_QUERY>",
          HitsPerPage = 50,
        }
      )
    },
  }
);

For full documentation, visit the Algolia CSharp 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 CSharp, 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 .NET API Client is an open-sourced software licensed under the MIT license.