# searchSDK for C

C11 / POSIX; libcurl 7.85+ for HTTPS. 14 normalized web-search adapters and 493 retained native bindings across 13 providers; gateway client.

Canonical: https://searchsdk.dev/docs/sdks/c
Markdown: https://searchsdk.dev/docs/sdks/c.md

<a id="install"></a>

## Install from source

Package: `searchsdk::searchsdk / searchsdk::curl`, version `0.1.0-alpha.1`. This is an alpha source/local-artifact installation. No public registry release or release tag is assumed.

**Get the source**

```bash
git clone https://github.com/Belweave/searchSDK.git
cd searchSDK
# Record this revision with your application's dependency lock.
git rev-parse HEAD
```

**Build or install the local package**

```bash
cmake -S packages/c -B .local/c-build -DCMAKE_BUILD_TYPE=Release -DSEARCHSDK_TESTS=OFF
cmake --build .local/c-build --parallel 2
cmake --install .local/c-build --prefix "$PWD/.local/c-install"
```

Use find_package(searchsdk 0.1 CONFIG REQUIRED) and link searchsdk::curl for HTTPS. Point CMAKE_PREFIX_PATH at the installation prefix. The POSIX core can also use an injected transport; Windows is unsupported.

<a id="first-search"></a>

## Make a server-side search

Set provider keys in your application's server environment or secret store. The example below makes a real provider request when invoked and can incur charges. Use the package's fixture consumer for a key-free check.

**search.c**

```c
#include <searchsdk/searchsdk.h>
#include <searchsdk/curl.h>

/* Call after curl_global_init; caller supplies a server-held key. */
ssk_code search_example(const char *key) {
    ssk_config config;
    ssk_config_init(&config);
    config.provider = "exa";
    config.transport = ssk_curl_transport;
    ssk_client *client = NULL;
    ssk_error *error = NULL;
    ssk_response *response = NULL;
    ssk_code code = ssk_client_new(&config, &client, &error);
    if (code == SSK_OK) {
        ssk_call_options call;
        ssk_call_options_init(&call);
        call.credential = key;
        code = ssk_search(client,
            "{\"query\":\"SQLite write concurrency\",\"limit\":3}",
            &call, &response, &error);
        /* On success, consume ssk_response_json(response) here. */
    }
    ssk_response_free(response);
    ssk_error_free(error);
    ssk_client_free(client);
    return code;
}
```

This is a function for your server application. Initialize libcurl with curl_global_init(CURL_GLOBAL_DEFAULT) before worker threads, then call curl_global_cleanup after all calls finish. Response views are borrowed until the response is freed.

<a id="scope"></a>

## Supported surface and limits

14 normalized web-search adapters and 493 retained native bindings across 13 providers; gateway client.

- C11/POSIX, not a Windows portability claim. ABI version 1 has explicit ownership rules.
- No hidden executor: synchronous calls and streaming callbacks run on the caller's thread.

Preserve result order, provider-native scores and source provenance. Unknown usage is not zero cost. Cancellation and deadlines cannot undo a request already accepted by a remote system or guarantee exactly-once effects.

<a id="verify"></a>

## Verify without provider keys

**Repository checkout · local checks**

```bash
sh packages/c/scripts/verify-package.sh
```

Core assertions, ASan/UBSan, local TLS and installed/extracted-archive consumers; platform CI covers macOS and Linux.

These are deterministic contract and artifact checks. They do not establish live-provider or account-entitlement verification. Read the package README for precise commands, dependencies and runtime coverage.

<a id="next"></a>

## Continue in your language

- [C package reference](https://github.com/Belweave/searchSDK/tree/main/packages/c#readme): Complete API, errors, streaming, packaging and platform boundaries.
- [Compare SDKs](https://searchsdk.dev/docs/sdks)
- [Choose a provider](https://searchsdk.dev/docs/providers)
