Sapling Logo
Tone API quickstart

C# Tone Checker

Analyze overall and sentence-level tone from a C# application across 28 fine-grained categories.

  • HTTPS POST
  • JSON HTTP API
  • Bearer API key
POST C# logo C# /api/v1/tone

C# tone checker quickstart

Send text to the tone endpoint. The response ranks overall tones and returns a separate probability breakdown for every sentence.

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/tone

This example uses the HTTP and JSON libraries included with modern .NET.

using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

var apiKey = Environment.GetEnvironmentVariable("SAPLING_API_KEY")
    ?? throw new InvalidOperationException("Set SAPLING_API_KEY first.");

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);

var response = await client.PostAsJsonAsync(
    "https://api.sapling.ai/api/v1/tone",
    new { text = "Really stoked about this! Will it be ready by next week?" });

response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(JsonSerializer.Serialize(result, new JsonSerializerOptions {
    WriteIndented = true
}));
Example response application/json
{
  "overall": [
    [0.9247, "curious", "🤓"],
    [0.0455, "excited", "😀"],
    [0.0057, "confused", "😕"]
  ],
  "results": [
    [[0.9937, "excited", "😀"]],
    [[0.5469, "confused", "😕"], [0.3993, "curious", "🤓"]]
  ],
  "sents": [
    "Really stoked about this!",
    "Will it be ready by next week?"
  ]
}

Probabilities are returned in descending order as probability, tone, and emoji tuples. Use sentence results when a message contains mixed tones.

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.