Sapling Logo
Grammar API quickstart

C# Grammar Checker

Add spelling and grammar suggestions to a C# application with Sapling's edits API.

  • HTTPS POST
  • HTTP API
  • API key required
POST C# logo C# /api/v1/edits

C# grammar checker quickstart

Send text to the edits endpoint. Sapling returns suggested replacements with character offsets so your application can review or apply each correction.

No language-specific SDK is required. The example uses a standard or commonly used HTTP client to call Sapling's JSON API.
C# /api/v1/edits
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    public static async Task Main()
    {
        string myJson = "{\"key\":\"<API_KEY>\",\"text\":\"Lets get started!\", \"session_id\":\"Test Document UUID\"}";

        HttpClient client = new HttpClient();

        var response = await client.PostAsync(
            "https://api.sapling.ai/api/v1/edits",
            new StringContent(myJson, Encoding.UTF8, "application/json"));

        var responseString = await response.Content.ReadAsStringAsync();

        Console.WriteLine(responseString);
    }
}
Example response application/json
{
  "edits": [
    {
      "start": 0,
      "end": 4,
      "replacement": "Let's",
      "sentence": "Lets get started!",
      "error_type": "R:OTHER"
    }
  ]
}

Each edit identifies the source range and replacement text. Preserve the original offsets when applying more than one edit.

About C#

C# is an object-oriented programming language for the Microsoft Windows platform. It is the primary language used for development inside the Windows ecosystem along with the .NET Framework and Visual Studio. This is also the language used by the cross-platform application framework Xamarin.