# Client SDKs

> One page of the LogDuck documentation. Every page is listed in https://logduck.com/llms.txt, and https://logduck.com/llms-full.txt is all of them in one file.

Official SDKs wrap POST /v1/events so you do not have to. Every one of them behaves the same way: the same validation limits, one retry on 5xx and network failures, and an Idempotency-Key generated per event and reused across that retry so a retry can never double-post.

None of them are required. The API is plain JSON over HTTPS and works from any language — see the [API Reference](https://logduck.com/docs/api-reference.md).

## Installation

**.NET**

```bash
dotnet add package LogDuck
```

**npm**

```bash
npm install logduck
```

**Python**

```bash
pip install logduck
```

**Swift**

```swift
.package(url: "https://github.com/Log-Duck/logduck-swift.git", from: "2.0.0")
```

**Gradle**

```kotlin
dependencies {
    implementation("com.logduck:logduck:1.0.0")
}
```

## Sending your first event

**C#**

```csharp
// Registered once at startup, then injected wherever you need it.
public class CheckoutService(ILogDuckClient logDuck)
{
    public async Task OnOrderPlaced(string orderId) =>
        await logDuck.SendEventAsync(new LogDuckEvent
        {
            Type = "order.placed",
            Subject = orderId
        });
}
```

**TypeScript**

```typescript
import { LogDuckClient } from 'logduck';

const logduck = new LogDuckClient({
  apiKey: process.env.LOGDUCK_API_KEY!,
  source: 'checkout-api',
});

await logduck.send({ type: 'order.placed', subject: 'order_9127' });
```

**Python**

```python
import os

from logduck import LogDuckClient

logduck = LogDuckClient(
    api_key=os.environ["LOGDUCK_API_KEY"],
    source="checkout-api",
)

logduck.send("order.placed", subject="order_9127")
```

**Swift**

```swift
import LogDuck

let logduck = LogDuckClient(
    options: LogDuckOptions(apiKey: "ld_your_key_here", source: "ios-app")
)

try await logduck.send(LogDuckEvent(type: "order.placed", subject: "order_9127"))
```

**Kotlin**

```kotlin
import com.logduck.LogDuckClient
import com.logduck.LogDuckEvent
import com.logduck.LogDuckOptions

val logduck = LogDuckClient(
    LogDuckOptions(apiKey = System.getenv("LOGDUCK_API_KEY"), source = "checkout-api")
)

logduck.send(LogDuckEvent(type = "order.placed"))
```

> **Note: Naming your event type**
> The server lowercases `type` and requires it to match `^[a-z][a-z0-9_.]*$` — letters, digits, underscores and dots, starting with a letter. So `order.placed` works and `order-placed` is rejected with a 400. Dots are the conventional separator.
