Skip to main content
This page documents an earlier version of the API client. For the latest version, see Install API clients (current).
  • C#
  • Go
  • Java
  • JavaScript
  • Kotlin
  • PHP
  • Python
  • Ruby
  • Scala
  • Swift
Latest version: The C# API client v6 supports .NET Standard versions 1.3 to 2.1.To install version 6 of the C#/.NET API clients, add the Algolia.Search package from NuGet as a dependency to your project. For example:
dotnet add package Algolia.Search --version 6.*
The C#/.NET API clients are open source. View the source code on GitHub.

Test your installation

To test your installation, try running a short program that adds a record to a test index, searches your index, and prints the results.
1

Create account

If you haven’t already, create an Algolia account
2

Copy code

Copy the following code into a new project or file. Replace ALGOLIA_APPLICATION_ID and ALGOLIA_API_KEY with values from your account. Make sure to use an API key with addObject and search permissions.
using System;
using System.Linq;
using System.Collections.Generic;
using Algolia.Search.Clients;
using Algolia.Search.Models.Search;

namespace HelloAlgolia
{
  // a simple record in your index
  class Record
  {
    public string Name { get; set; }
    public string ObjectID { get; set; }
    public override string ToString()
    {
       return $"Name: {Name}, ObjectID: {ObjectID}";
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
       // Connect and authenticate with your Algolia app
       var client = new SearchClient(
          "ALGOLIA_APPLICATION_ID",
          "ALGOLIA_API_KEY"
       );

       // Create a new index and add a record
       var index = client.InitIndex("test_index");
       var record = new Record{ ObjectID = "1", Name = "test_record" };
       index.SaveObject(record).Wait();

       // Search the index and print the results
       var results = index.Search<Record>(new Query("test_record"));
       Console.WriteLine(results.Hits.ElementAt(0).ToString());
    }
  }
}
In production, use environment variables for your credentials.
3

Run code

Run the code, depending on your development environment.
# For example:
dotnet run
If the command is successful, you should see:
Name: test_record, ObjectID: 1
I