Sapling Logo

Grammar Checking in C


The programming language C is well known for its performance and widespread usage across all platforms and systems for multiple decades.

Sapling: AI Writing Assistant

With Sapling, you can add grammar or spell checking functionality to an existing C application.

This page demonstrates a quick way to integrate grammar and spell checking functionality into a C application using Sapling's API. If you are not looking for a C guide, click here for guides for other programming languages.

Sapling does not currently maintain a C-specific SDK, but you can access the Sapling Grammar Checking HTTP API using any programming language that supports HTTP POST requests. An example is shown below.

Setup Steps

C Grammar Check Quickstart

C does not have a standard HTTP or socket library. HTTP POST requests in C require an HTTP library like libcurl.

#include <stdio.h>
#include <curl/curl.h>

int main(void) {
      char* jsonObj = "{\"key\":\"<API_KEY>\", \"text\":\"Lets get started!\", \"session_id\":\"Test Document UUID\"}";

      struct curl_slist *headers = NULL;
      curl_slist_append(headers, "Accept: application/json");
      curl_slist_append(headers, "Content-Type: application/json");
      curl_slist_append(headers, "charset: utf-8");

      curl_easy_setopt(curl, CURLOPT_URL, "");

      curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
      curl_easy_setopt(curl, CURLOPT_POSTFIELDS, jsonObj);
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
      curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcrp/0.1");

      res = curl_easy_perform(curl);

Returned result:

          "sentence":"Lets get started!",


Addtional parameters and Sapling's full API documentation can be accessed here: